Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: finish upgrade interface #923

Merged

Conversation

HusterWan
Copy link
Contributor

Signed-off-by: Michael Wan zirenwan@gmail.com

Ⅰ. Describe what this PR did

finish upgrade interface daemon part

root@osboxes:wanziren -> pouch upgrade --name test1 registry.hub.docker.com/library/busybox:latest
test1

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

    1. Create a new container
root@osboxes:pouch (zr/finish-upgrade) -> pouch inspect test2
{
    "Args": null,
    "Config": {
        "Cmd": [
            "sh"
        ],
        "Entrypoint": null,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "Image": "registry.hub.docker.com/library/busybox:latest",
        "OnBuild": null,
        "Shell": null
    },
    "Created": "2018-03-20T02:19:05.418084614Z",
    "HostConfig": {
        "NetworkMode": "bridge",
        "RestartPolicy": {
            "Name": "no"
        },
        "Runtime": "runc",
        "BlkioDeviceReadBps": null,
        "BlkioDeviceReadIOps": null,
        "BlkioDeviceWriteBps": null,
        "BlkioDeviceWriteIOps": null,
        "BlkioWeightDevice": null,
        "CgroupParent": "default",
        "DeviceCgroupRules": null,
        "Devices": [],
        "Memory": 20971520,
        "MemoryExtra": 0,
        "MemorySwappiness": -1,
        "MemoryWmarkRatio": 0,
        "Ulimits": null
    },
    "Id": "4c58d27f58d38776dda31c01c897bbf554c802a9b80ae4dc20be1337f8a969f2",
    "Image": "registry.hub.docker.com/library/busybox:latest",
    "Mounts": null,
    "Name": "test2",
    "NetworkSettings": {
        "Networks": {
            "bridge": {
                "Aliases": null,
                "EndpointID": "e3845861204350e6ec1ac2fbfaece7d3fe384ed0f5c01b41b53478d89b70a131",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.2/24",
                "IPPrefixLen": 24,
                "Links": null,
                "MacAddress": "02:42:ac:11:00:02",
                "NetworkID": "59a8a8a365171ea1862f11534be913a81a6b4fc39f516b3121fb71c52b3dc2f8"
            }
        },
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null
    },
    "State": {
        "Pid": 4895,
        "StartedAt": "2018-03-20T02:19:05.780853724Z",
        "Status": "running"
    }
}
    1. Update container's image
root@osboxes:pouch (zr/finish-upgrade) -> pouch upgrade --name test2 registry.hub.docker.com/library/ubuntu:14.04
test2
    1. Check the container's status
root@osboxes:pouch (zr/finish-upgrade) -> pouch ps
Name    ID       Status          Created          Image                                                Runtime
test2   4c58d2   Up 2 minutes    15 minutes ago   registry.hub.docker.com/library/ubuntu:14.04         runc
    1. Inspect the container's meta info
root@osboxes:pouch (zr/finish-upgrade) -> pouch inspect test2
{
    "Args": null,
    "Config": {
        "Cmd": [
            "sh"
        ],
        "Entrypoint": null,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
        ],
        "Image": "registry.hub.docker.com/library/ubuntu:14.04",
        "OnBuild": null,
        "Shell": null
    },
    "Created": "2018-03-20T02:19:05.418084614Z",
    "HostConfig": {
        "NetworkMode": "bridge",
        "RestartPolicy": {
            "Name": "no"
        },
        "Runtime": "runc",
        "BlkioDeviceReadBps": null,
        "BlkioDeviceReadIOps": null,
        "BlkioDeviceWriteBps": null,
        "BlkioDeviceWriteIOps": null,
        "BlkioWeightDevice": null,
        "CgroupParent": "default",
        "DeviceCgroupRules": null,
        "Devices": [],
        "Memory": 20971520,
        "MemoryExtra": 0,
        "MemorySwappiness": -1,
        "MemoryWmarkRatio": 0,
        "Ulimits": null
    },
    "Id": "4c58d27f58d38776dda31c01c897bbf554c802a9b80ae4dc20be1337f8a969f2",
    "Image": "registry.hub.docker.com/library/ubuntu:14.04",
    "Mounts": null,
    "Name": "test2",
    "NetworkSettings": {
        "Networks": {
            "bridge": {
                "Aliases": null,
                "EndpointID": "e3845861204350e6ec1ac2fbfaece7d3fe384ed0f5c01b41b53478d89b70a131",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.2/24",
                "IPPrefixLen": 24,
                "Links": null,
                "MacAddress": "02:42:ac:11:00:02",
                "NetworkID": "59a8a8a365171ea1862f11534be913a81a6b4fc39f516b3121fb71c52b3dc2f8"
            }
        },
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null
    },
    "State": {
        "Pid": 8251,
        "StartedAt": "2018-03-20T02:32:43.874327747Z",
        "Status": "running"
    }
}

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Mar 20, 2018

Codecov Report

Merging #923 into master will decrease coverage by 0.14%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #923      +/-   ##
==========================================
- Coverage   13.06%   12.92%   -0.15%     
==========================================
  Files         123      123              
  Lines        8235     8325      +90     
==========================================
  Hits         1076     1076              
- Misses       7063     7153      +90     
  Partials       96       96
Impacted Files Coverage Δ
pkg/utils/utils.go 82.08% <ø> (ø) ⬆️
client/container.go 0% <0%> (ø) ⬆️
cli/upgrade.go 0% <0%> (ø) ⬆️
daemon/mgr/container.go 2.06% <0%> (-0.19%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9f3816...c26160c. Read the comment docs.

@allencloud
Copy link
Collaborator

Thanks a lot for the work you made. I am wondering adding some integration test will guarantee this much better. @HusterWan 💟

@HusterWan HusterWan changed the title [WIP] feature: finish upgrade interface feature: finish upgrade interface Mar 23, 2018
// check the image existed or not, and convert image id to image ref
image, err := mgr.ImageMgr.GetImage(ctx, config.Image)
if err != nil {
return errors.Wrap(err, "get image failed")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failed to get image

if len(image.RepoTags) > 0 {
ref = image.RepoTags[0]
} else {
ref = image.RepoDigests[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there possibility that this image.RepoDigests has a length of 0?
also ping @YaoZengzeng @zeppp

if needRollback {
c.meta = &backupContainerMeta
if err := mgr.Client.CreateSnapshot(ctx, c.ID(), c.meta.Image); err != nil {
logrus.Errorf("Upgrade rollback failed to create snapshot: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failed to create snapshot when rollback upgrade: %v

time.Sleep(100 * time.Millisecond)

msg, err := mgr.Client.GetSnapshot(ctx, c.ID())
logrus.Info("snapshots %+v", msg)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If err != nil, just double check whether msg has data in itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if error occured , msg will be a empty Snapshot.Info{}

command.PouchRun("run", "-d", "--name", name, busyboxImage).Assert(c, icmd.Success)

res := command.PouchRun("upgrade", "--name", name, busyboxImage)
c.Assert(res.Error, check.IsNil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we do not upgrade anything, should we return an error indicating nothing to upgrade and no status update happens in daemon side. @HusterWan WDYT

@allencloud
Copy link
Collaborator

CI fails:

FAIL: /go/src/github.com/alibaba/pouch/test/cli_upgrade_test.go:58: PouchUpgradeSuite.TestPouchUpgradeNoChange
/go/src/github.com/alibaba/pouch/test/cli_upgrade_test.go:64:
    c.Assert(res.Error, check.NotNil)
... value = nil

@HusterWan

Signed-off-by: Michael Wan <zirenwan@gmail.com>
@allencloud
Copy link
Collaborator

LGTM
And I think we need to add a document to tell users how to take advantages of this API. WDYT? @HusterWan

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Mar 25, 2018
@allencloud allencloud merged commit 5b6ed3e into AliyunContainerService:master Mar 25, 2018
@HusterWan
Copy link
Contributor Author

And I think we need to add a document to tell users how to take advantages of this API. WDYT? @HusterWan

Yes, i will add the doc after i have a tiime, but i will create a issue to reminder me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants