Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

GRPC interface for Start/Remove container #469

Merged
merged 9 commits into from
Dec 19, 2016

Conversation

gnawux
Copy link
Member

@gnawux gnawux commented Dec 13, 2016

Test results list in following comments.

For #462

Signed-off-by: Wang Xu <gnawux@gmail.com>
Signed-off-by: Wang Xu <gnawux@gmail.com>
@gnawux gnawux self-assigned this Dec 13, 2016
@gnawux gnawux added this to the v0.8.0 milestone Dec 13, 2016
Signed-off-by: Wang Xu <gnawux@gmail.com>
- dm remove root device, file mode check, it looks it had never worked well
- remove container entry in pod

Signed-off-by: Wang Xu <gnawux@gmail.com>
@gnawux
Copy link
Member Author

gnawux commented Dec 13, 2016

gnawux@h8s-single:~/Workspace/src/github.com/hyperhq/hyperd$ sudo ./hyperctl run -d nginx
[sudo] password for gnawux:
POD id is nginx-3997343532
Time to run a POD is 2939 ms
gnawux@h8s-single:~/Workspace/src/github.com/hyperhq/hyperd$ sudo ./hyperctl list
POD ID              POD Name            VM name             Status
nginx-3997343532    nginx-3997343532    vm-MKgkSlpPnC       running
1 gnawux@h8s-single:~/Workspace/src/github.com/hyperhq/hyperd$ sudo ./hyperctl list container
Container ID                                                       Name                POD ID              Status
45bde7faac604712b16cdf9b77de9b54d582ab32a2d7123da248402ba8e48f5e   nginx-3997343532    nginx-3997343532    running
gnawux@h8s-single:~/Workspace/src/github.com/hyperhq/hyperd$ sudo ./hyperctl stop -c nginx-3997343532
gnawux@h8s-single:~/Workspace/src/github.com/hyperhq/hyperd$ sudo ./hyperctl list container
Container ID                                                       Name                POD ID              Status
45bde7faac604712b16cdf9b77de9b54d582ab32a2d7123da248402ba8e48f5e   nginx-3997343532    nginx-3997343532    succeeded
gnawux@h8s-single:~/Workspace/src/github.com/hyperhq/hyperd$ sudo ./hyperctl list pod
POD ID              POD Name            VM name             Status
nginx-3997343532    nginx-3997343532    vm-MKgkSlpPnC       running
gnawux@h8s-single:~/Workspace/src/github.com/hyperhq/hyperd$ sudo ./hyperctl rm -c nginx-3997343532
container nginx-3997343532 is successfully deleted!
gnawux@h8s-single:~/Workspace/src/github.com/hyperhq/hyperd$ sudo ./hyperctl list pod
POD ID              POD Name            VM name             Status
nginx-3997343532    nginx-3997343532    vm-MKgkSlpPnC       running
gnawux@h8s-single:~/Workspace/src/github.com/hyperhq/hyperd$ sudo ./hyperctl list container
Container ID        Name                POD ID              Status

container remove works

- and fix create/start container procedures

Signed-off-by: Wang Xu <gnawux@gmail.com>
@gnawux
Copy link
Member Author

gnawux commented Dec 13, 2016

➜ sudo ./hyperctl run -d nginx
POD id is nginx-6924339727
Time to run a POD is 2939 ms
➜ sudo ./hyperctl list container
Container ID                                                       Name                POD ID              Status
6be159032b84b712a481182ec7e31647e3228c644aa219296206bc43ae5e801f   nginx-6924339727    nginx-6924339727    running
➜ sudo ./hyperctl create -c -t -d nginx-6924339727 busybox
Container ID is 237e923d66d07a6405581b02f429017aa436d95b1347947099c50a490c053329
➜ sudo ./hyperctl list container
Container ID                                                       Name                 POD ID              Status
237e923d66d07a6405581b02f429017aa436d95b1347947099c50a490c053329   busybox-8257013083   nginx-6924339727    pending
6be159032b84b712a481182ec7e31647e3228c644aa219296206bc43ae5e801f   nginx-6924339727     nginx-6924339727    running
➜ sudo ./hyperctl start nginx-6924339727 busybox-8257013083
Successfully started container busybox-8257013083 in pod nginx-6924339727
➜ sudo ./hyperctl list container
Container ID                                                       Name                 POD ID              Status
6be159032b84b712a481182ec7e31647e3228c644aa219296206bc43ae5e801f   nginx-6924339727     nginx-6924339727    running
237e923d66d07a6405581b02f429017aa436d95b1347947099c50a490c053329   busybox-8257013083   nginx-6924339727    running
➜ sudo ./hyperctl stop -c nginx-6924339727
➜ sudo ./hyperctl stop -c busybox-8257013083
fail to stop container busybox-8257013083: Error from daemon's response: timeout while waiting containers: map[string]bool{"237e923d66d07a6405581b02f429017aa436d95b1347947099c50a490c053329":true} of [[237e923d66d07a6405581b02f429017aa436d95b1347947099c50a490c053329]]
➜ sudo ./hyperctl list container
Container ID                                                       Name                 POD ID              Status
6be159032b84b712a481182ec7e31647e3228c644aa219296206bc43ae5e801f   nginx-6924339727     nginx-6924339727    succeeded
237e923d66d07a6405581b02f429017aa436d95b1347947099c50a490c053329   busybox-8257013083   nginx-6924339727    running
➜ sudo ./hyperctl kill --signal=9 busybox-8257013083
➜ sudo ./hyperctl list container
Container ID                                                       Name                 POD ID              Status
237e923d66d07a6405581b02f429017aa436d95b1347947099c50a490c053329   busybox-8257013083   nginx-6924339727    succeeded
6be159032b84b712a481182ec7e31647e3228c644aa219296206bc43ae5e801f   nginx-6924339727     nginx-6924339727    succeeded
➜ sudo ./hyperctl rm -c busybox-8257013083  nginx-6924339727
container busybox-8257013083 is successfully deleted!
container nginx-6924339727 is successfully deleted!
➜ sudo ./hyperctl rm  nginx-6924339727
Pod(nginx-6924339727) is successfully deleted!

In the above op list, there is an failure of stop. It is not a bug, the busybox with -t option will ignore its StopSignal SIGTERM, and could be killed with SIGKILL.

@gnawux
Copy link
Member Author

gnawux commented Dec 13, 2016

With carefully operation, you may add, start, stop, kill, remove a container inside a pod now @feiskyer

@feiskyer feiskyer self-assigned this Dec 13, 2016
@feiskyer feiskyer self-requested a review December 13, 2016 10:50
Signed-off-by: Wang Xu <gnawux@gmail.com>
@@ -788,13 +801,17 @@ service PublicAPI {
rpc ContainerLogs(ContainerLogsRequest) returns (stream ContainerLogsResponse) {}
// ContainerCreate creates a container in specified pod
rpc ContainerCreate(ContainerCreateRequest) returns (ContainerCreateResponse) {}
// ContainerStart start a container in a specified pod
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/start/starts

}
if len(args) == 0 {
return fmt.Errorf("\"create\" requires a minimum of 1 argument, please provide POD spec file.\n")
if copt.Remove || copt.Attach {
Copy link
Contributor

Choose a reason for hiding this comment

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

Check whether copt is nil before this.

Copy link
Contributor

Choose a reason for hiding this comment

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

For help subcommand, both copt and err are nil.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about change if err != nil { to if copt == nil {

if err == nil {
fmt.Fprintf(cli.out, "container %s is successfully deleted!\n", id)
} else {
fmt.Fprintf(cli.err, "%v\n", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: also logs the container id for clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will update this. Actually this is copied from the original one, I don't know if you are depends on this behavior.

if err == nil {
fmt.Fprintf(cli.out, "Pod(%s) is successfully deleted!\n", id)
} else {
fmt.Fprintf(cli.err, "%v\n", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: also logs the pod id for clear.

var parser = gflag.NewParser(&opts, gflag.Default)
parser.Usage = "start [-c 1 -m 128]| POD_ID \n\nLaunch a 'pending' pod"
var parser = gflag.NewParser(nil, gflag.Default)
parser.Usage = "start POD_ID [CONTAINER_ID]\n\nLaunch a created pod or container"
Copy link
Contributor

Choose a reason for hiding this comment

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

podId is not required when starting a created container, add a new -c option for containers?

@@ -99,13 +99,14 @@ func (daemon *Daemon) CmdCreateContainer(podId string, containerArgs []byte) (st
return daemon.CreateContainerInPod(podId, &c)
}

func (daemon *Daemon) CmdStartContainer(podId, containerId string) error {
err := daemon.StartContainer(podId, containerId)
func (daemon *Daemon) CmdStartContainer(podId, containerId string) (*engine.Env, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove podId from params.

return err
}

pod := r.Form.Get("podId")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove podId

@feiskyer
Copy link
Contributor

# hyperctl create -c nginx-5665882047 nginx
hyperctl ERROR: "create" does not support attach and rm parameter

attach/rm should be set to false by default.

@gnawux
Copy link
Member Author

gnawux commented Dec 13, 2016

attach/rm should be set to false by default.

Hmm... you are right

and some other fix based on the review comments

Signed-off-by: Wang Xu <gnawux@gmail.com>
@gnawux
Copy link
Member Author

gnawux commented Dec 13, 2016

@feiskyer updated

➜ sudo ./hyperctl run -d nginx
[sudo] password for gnawux:
POD id is nginx-8530075287
Time to run a POD is 2884 ms
➜ sudo ./hyperctl list container
Container ID                                                       Name                POD ID              Status
6e8c08420389a165682586380fa35432f5922287b9aec34059ed1ff68b3f1623   nginx-8530075287    nginx-8530075287    running
➜ sudo ./hyperctl create -c -d nginx-8530075287 busybox
Container ID is a8fd34f686e6587979936df880b9e9144fefd895d19560493d2028aa82c47f0c
➜ sudo ./hyperctl list container
Container ID                                                       Name                 POD ID              Status
6e8c08420389a165682586380fa35432f5922287b9aec34059ed1ff68b3f1623   nginx-8530075287     nginx-8530075287    running
a8fd34f686e6587979936df880b9e9144fefd895d19560493d2028aa82c47f0c   busybox-2602968228   nginx-8530075287    pending
➜ sudo ./hyperctl start -c busybox-2602968228
Successfully started container busybox-2602968228
➜ sudo ./hyperctl list container
Container ID                                                       Name                 POD ID              Status
a8fd34f686e6587979936df880b9e9144fefd895d19560493d2028aa82c47f0c   busybox-2602968228   nginx-8530075287    running
6e8c08420389a165682586380fa35432f5922287b9aec34059ed1ff68b3f1623   nginx-8530075287     nginx-8530075287    running
➜ sudo ./hyperctl stop -c busybox-2602968228 nginx-8530075287
➜ sudo ./hyperctl list container
Container ID                                                       Name                 POD ID              Status
6e8c08420389a165682586380fa35432f5922287b9aec34059ed1ff68b3f1623   nginx-8530075287     nginx-8530075287    succeeded
a8fd34f686e6587979936df880b9e9144fefd895d19560493d2028aa82c47f0c   busybox-2602968228   nginx-8530075287    succeeded
➜ sudo ./hyperctl rm -c busybox-2602968228 nginx-8530075287
container busybox-2602968228 is successfully deleted!
container nginx-8530075287 is successfully deleted!
➜ sudo ./hyperctl list container
Container ID        Name                POD ID              Status
➜ sudo ./hyperctl list
POD ID              POD Name            VM name             Status
nginx-8530075287    nginx-8530075287    vm-pqEnBvQVdS       running
➜ sudo ./hyperctl rm nginx-8530075287
Pod(nginx-8530075287) is successfully deleted!
➜ sudo ./hyperctl list
POD ID              POD Name            VM name             Status
➜

@feiskyer
Copy link
Contributor

@gnawux Still same errors on creating a new container, blocks on wait for volumes:

I1214 02:20:34.275461   21026 server.go:152] Calling POST /v0.7.0/container/create
I1214 02:20:34.275539   21026 container_routes.go:123] Create container {"name":"nginx-4959865160","image":"nginx","restartPolicy":"never"} in pod nginx-0861304337
I1214 02:20:34.280807   21026 container.go:488] Pod[nginx-0861304337] Con[(nginx-4959865160)] create container d39bc20cb9c2d54499e2135fc624cf78e29558fda4ab754eb49d2a325645a269 (w/: [])
I1214 02:20:34.280903   21026 container.go:505] Pod[nginx-0861304337] Con[d39bc20cb9c2(nginx-4959865160)] container info config &container.Config{Hostname:"d39bc20cb9c2", Domainname:"", User:"", AttachStdin:false, AttachStdout:false, AttachStderr:false, ExposedPorts:map[nat.Port]struct {}{"443/tcp":struct {}{}, "80/tcp":struct {}{}}, PublishService:"", Tty:false, OpenStdin:false, StdinOnce:false, Env:[]string{"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "NGINX_VERSION=1.11.6-1~jessie"}, Cmd:(*strslice.StrSlice)(0xc420f81360), ArgsEscaped:false, Image:"nginx", Volumes:map[string]struct {}(nil), WorkingDir:"", Entrypoint:(*strslice.StrSlice)(nil), NetworkDisabled:true, MacAddress:"", OnBuild:[]string(nil), Labels:map[string]string{}, StopSignal:""}, Cmd [nginx -g daemon off;], Args [-g daemon off;]
I1214 02:20:34.281489   21026 container.go:510] Pod[nginx-0861304337] Con[d39bc20cb9c2(nginx-4959865160)] describe container
I1214 02:20:34.281547   21026 container.go:518] Pod[nginx-0861304337] Con[d39bc20cb9c2(nginx-4959865160)] mount id: 436515018fc23f22495e0b69973eec62a9c0500cc01030f4778c7709765b28a3
I1214 02:20:34.281584   21026 container.go:581] Pod[nginx-0861304337] Con[d39bc20cb9c2(nginx-4959865160)] Container Info is
&api.ContainerDescription{Id:"d39bc20cb9c2d54499e2135fc624cf78e29558fda4ab754eb49d2a325645a269", Name:"/nginx-4959865160", Image:"sha256:abf312888d132e461c61484457ee9fd0125d666672e22f972f3b8c9a0ed3f0a1", Labels:map[string]string(nil), Tty:false, StopSignal:"TERM", RootVolume:(*api.VolumeDescription)(0xc42088d3b0), MountId:"436515018fc23f22495e0b69973eec62a9c0500cc01030f4778c7709765b28a3", RootPath:"rootfs", UGI:(*api.UserGroupInfo)(nil), Envs:map[string]string{"PATH":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "NGINX_VERSION":"1.11.6-1~jessie"}, Workdir:"/", Path:"nginx", Args:[]string{"-g", "daemon off;"}, Rlimits:[]*api.Rlimit{}, Sysctl:map[string]string(nil), Volumes:map[string]*api.VolumeReference(nil), Initialize:false}
I1214 02:20:34.281595   21026 container.go:728] Pod[nginx-0861304337] Con[d39bc20cb9c2(nginx-4959865160)] configure dns
I1214 02:20:34.281609   21026 container.go:786] Pod[nginx-0861304337] Con[d39bc20cb9c2(nginx-4959865160)] inject file /etc/resolv.conf
I1214 02:20:34.282103   21026 container.go:845] Pod[nginx-0861304337] Con[d39bc20cb9c2(nginx-4959865160)] begin add to sandbox
I1214 02:20:34.287811   21026 container.go:867] Pod[nginx-0861304337] Con[d39bc20cb9c2(nginx-4959865160)] finished container prepare, wait for volumes

Signed-off-by: Wang Xu <gnawux@gmail.com>
@gnawux
Copy link
Member Author

gnawux commented Dec 15, 2016

@feiskyer I pushed a new commit with more verbose logs, the successful log should be like this

I1215 04:12:47.374338  110567 container_routes.go:123] Create container {"name":"busybox-1897372744","image":"busybox","restartPolicy":"never"} in pod nginx-5903557292
DEBU[0060] container mounted via layerStore: /var/lib/hyper/overlay/3f0f58765e5f569b821dbbe72caf4d1e079d94782e3b3b8aeeec1ca5e376153b/merged
I1215 04:12:47.379800  110567 container.go:488] Pod[nginx-5903557292] Con[(busybox-1897372744)] create container aaf2a98749108503bdee8f502931447cb1f2cef088aeee487af1df272a056a72 (w/: [])
I1215 04:12:47.380009  110567 container.go:505] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] container info config &container.Config{Hostname:"aaf2a9874910", Domainname:"", User:"", AttachStdin:false, AttachStdout:false, At
tachStderr:false, ExposedPorts:map[nat.Port]struct {}(nil), PublishService:"", Tty:false, OpenStdin:false, StdinOnce:false, Env:[]string{"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, Cmd:(*strslice.StrSlice)(0xc820
7fd400), ArgsEscaped:false, Image:"busybox", Volumes:map[string]struct {}(nil), WorkingDir:"", Entrypoint:(*strslice.StrSlice)(nil), NetworkDisabled:true, MacAddress:"", OnBuild:[]string(nil), Labels:map[string]string{}, StopSignal:""}, C
md [sh], Args []
I1215 04:12:47.380020  110567 container.go:510] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] describe container
I1215 04:12:47.380039  110567 container.go:518] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] mount id: 3f0f58765e5f569b821dbbe72caf4d1e079d94782e3b3b8aeeec1ca5e376153b
I1215 04:12:47.380071  110567 container.go:581] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] Container Info is
&api.ContainerDescription{Id:"aaf2a98749108503bdee8f502931447cb1f2cef088aeee487af1df272a056a72", Name:"/busybox-1897372744", Image:"sha256:e02e811dd08fd49e7f6032625495118e63f597eb150403d02e3238af1df240ba", Labels:map[string]string(nil), T
ty:false, StopSignal:"TERM", RootVolume:(*api.VolumeDescription)(0xc8207c9d60), MountId:"3f0f58765e5f569b821dbbe72caf4d1e079d94782e3b3b8aeeec1ca5e376153b", RootPath:"rootfs", UGI:(*api.UserGroupInfo)(nil), Envs:map[string]string{"PATH":"/
usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, Workdir:"/", Path:"sh", Args:[]string{}, Rlimits:[]*api.Rlimit{}, Sysctl:map[string]string(nil), Volumes:map[string]*api.VolumeReference(nil), Initialize:false}
I1215 04:12:47.380082  110567 container.go:728] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] configure dns
I1215 04:12:47.380091  110567 container.go:786] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] inject file /etc/resolv.conf
I1215 04:12:47.380549  110567 provision.go:146] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] volume etchosts-volume has already been included, don't need to be inserted again
I1215 04:12:47.380557  110567 provision.go:152] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] volumes to be added: []
I1215 04:12:47.380584  110567 container.go:845] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] begin add to sandbox
I1215 04:12:47.380592  110567 volume.go:180] Pod[nginx-5903557292] Vol[etchosts-volume] subcribe volume insert
I1215 04:12:47.380601  110567 volume.go:184] Pod[nginx-5903557292] Vol[etchosts-volume] the subscribed volume has been inserted, need nothing.
I1215 04:12:47.380814  110567 container.go:867] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] finished container prepare, wait for volumes
I1215 04:12:47.380822  110567 container.go:876] Pod[nginx-5903557292] Con[aaf2a9874910(busybox-1897372744)] resources ready, insert container to sandbox
I1215 04:12:47.380880  110567 context.go:261] SB[vm-PvYdiuMhuV] add container &api.ContainerDescription{Id:"aaf2a98749108503bdee8f502931447cb1f2cef088aeee487af1df272a056a72", Name:"/busybox-1897372744", Image:"sha256:e02e811dd08fd49e7f603
2625495118e63f597eb150403d02e3238af1df240ba", Labels:map[string]string(nil), Tty:false, StopSignal:"TERM", RootVolume:(*api.VolumeDescription)(0xc8207c9f40), MountId:"3f0f58765e5f569b821dbbe72caf4d1e079d94782e3b3b8aeeec1ca5e376153b", Root
Path:"rootfs", UGI:(*api.UserGroupInfo)(nil), Envs:map[string]string{"PATH":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, Workdir:"/", Path:"sh", Args:[]string{}, Rlimits:[]*api.Rlimit{}, Sysctl:map[string]string(nil),
Volumes:map[string]*api.VolumeReference{}, Initialize:true}```

In which shows, the `/etc/hosts` has been inserted by the first container, and the second one does not need to insert it again... Could you help reproduce the error again and put the `-v=4` logs here? Thank you very much.

@feiskyer feiskyer closed this Dec 16, 2016
@feiskyer feiskyer reopened this Dec 16, 2016
@laijs
Copy link
Contributor

laijs commented Dec 19, 2016

LGTM

1 similar comment
@feiskyer
Copy link
Contributor

LGTM

@feiskyer feiskyer merged commit 90cf14d into hyperhq:master Dec 19, 2016
@gnawux gnawux deleted the start_container branch December 21, 2016 05:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants