Skip to content

Update RestartPolicy of container#19116

Merged
vdemeester merged 1 commit intomoby:masterfrom
WeiZhang555:19025-update-restart
Feb 20, 2016
Merged

Update RestartPolicy of container#19116
vdemeester merged 1 commit intomoby:masterfrom
WeiZhang555:19025-update-restart

Conversation

@WeiZhang555
Copy link
Contributor

Fixes #19025

Add --restart flag for update command, so we can change restart
policy for a running/stopped container.

Signed-off-by: Zhang Wei zhangwei555@huawei.com

@thaJeztah
Copy link
Member

Thanks @WeiZhang555! I guess we should look at this, together with @vdemeester's proposal for #19104 ?

@WeiZhang555
Copy link
Contributor Author

@thaJeztah Yes, I also noticed #19104, it hides hostConfig from user and exposes a new API structure, that's good.
I think this PR can refactor based on @vdemeester 's very easily. 😄

@thaJeztah
Copy link
Member

I think this PR can refactor based on @vdemeester 's very easily. 😄

@WeiZhang555 ah, great!

@tianon
Copy link
Member

tianon commented Jan 6, 2016

😍 This is the thing I want to change about existing containers most often! (Usually because I was a dummy and forgot to specify one on an important container...)

@WeiZhang555
Copy link
Contributor Author

Just made some updates to adapt newly introduced UpdateConfig structure.

@calavera Could you help vendor the engine-api? Because it's necessary to add a RestartPolicy into UpdateConfig. See docker-archive-public/docker.engine-api#41

I know I shouldn't add codes to vendor/ package directly, just copy the changes of engine-api here for better review, after vendoring I'll remove that part, also it seems impossible to pass Janky test without vendoring.

Thanks!

@WeiZhang555
Copy link
Contributor Author

Updated, wait for vendoring of engine-api

@icecrime
Copy link
Contributor

I agree it's super useful, I'm just slightly confused:

root@c6f01a629a55:/# docker update --help

Usage:  docker update [OPTIONS] CONTAINER [CONTAINER...]

Update resources of one or more containers

So update is broader then resources after all? (cc @vdemeester @calavera @tiborvass)

@tiborvass
Copy link
Contributor

@icecrime the idea was to have update be only about ressources for 1.10, while continuing the discussion about updating restart policy and labels. We should just be unusually conservative with update and make sure we try to think as much as possible about the downsides. If we decide that it's very useful, and has barely any downsides, we should accept it.

@vdemeester
Copy link
Member

@icecrime @tiborvass said it all 👍

@icecrime
Copy link
Contributor

OK, moving to code review I guess 😉

Copy link
Member

Choose a reason for hiding this comment

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

lower case maximumRetryCount, err := please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@cpuguy83
Copy link
Member

Do you have a PR into engine-api already?

@WeiZhang555
Copy link
Contributor Author

@cpuguy83 Yes, I just checked and found that it's already merged and vendored, I'll do a rebase to make use of it.

@WeiZhang555
Copy link
Contributor Author

Updated.

Copy link
Member

Choose a reason for hiding this comment

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

This one is flakey because the container is not going to be running for a very long time so it may be difficult to catch (And is probably why it's currently failed on gccgo).

Maybe checking just the RestartCount hits 5, like below, and then verify that it is in a stopped state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, checking RestartCount hits 5 may bring new problem, if docker update fails to update the RestartPolicy of a running container, it will never hits 5...Besides that, we still need to waitInspect the RestartCount in timeout.

I'll try to give it a larger timeout, maybe 60 seconds? If the container can't stop in 60 seconds, I think some real problem happens.

Copy link
Member

Choose a reason for hiding this comment

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

Yep that's great.

@WeiZhang555
Copy link
Contributor Author

Ping @thaJeztah @moxiegirl for docs review.

@calavera
Copy link
Contributor

The docs should explain what policyCOLONnumber means, or point to a place where we already explain it.

@WeiZhang555
Copy link
Contributor Author

@calavera OK, I'll change the docs together with @thaJeztah / @moxiegirl 's review result.

Copy link
Member

Choose a reason for hiding this comment

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

I think "update configuration of one or more containers" ("configuration" instead of "configs")

@thaJeztah
Copy link
Member

Some nits, but overall looking good.

Can you add a mention to the API changes; https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api.md#v123-api-changes ?

Add `--restart` flag for `update` command, so we can change restart
policy for a container no matter it's running or stopped.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
@GordonTheTurtle
Copy link

Job: Docker-PRs-WoW-TP4 FAILED:

---
0T09:09:03Z" level=error msg="hcsshim::DestroyLayer - Win32 API call returned error r1=0x80070020 err=The process cannot access the file because it is being used by another process.id=CI flavour=0" 
ERROR:  hcsshim::DestroyLayer - Win32 API call returned error r1=0x80070020 err=The process cannot access the file because it is being used by another process.id=CI flavour=0
INFO: End of cleanup
INFO: Ended at Sat Feb 20 09:09:03 CUT 2016 (1m 23s)
Build step 'Execute shell' marked build as failure
[PostBuildScript] - Execution post build scripts.
[docker] $ sh -xe C:\Users\jenkins\hudson8046814883113902440.sh
+ set +e
+ set +x
INFO: Nuking /d/CI
time="2016-02-20T09:09:07Z" level=error msg="hcsshim::DestroyLayer - Win32 API call returned error r1=0x80070020 err=The process cannot access the file because it is being used by another process.id=CI flavour=0" 
ERROR:  hcsshim::DestroyLayer - Win32 API call returned error r1=0x80070020 err=The process cannot access the file because it is being used by another process.id=CI flavour=0
INFO: End
---

@WeiZhang555
Copy link
Contributor Author

@thaJeztah update, PTAL.

@thaJeztah
Copy link
Member

Thanks @WeiZhang555, LGTM

ping @vdemeester ptal

@vdemeester
Copy link
Member

LGTM 🐼

vdemeester added a commit that referenced this pull request Feb 20, 2016
@vdemeester vdemeester merged commit fe27541 into moby:master Feb 20, 2016
@thaJeztah
Copy link
Member

Woohoo! 🎉 love this feature 😄

@WeiZhang555
Copy link
Contributor Author

Finally! 🎉
Also thank everybody for help reviewing! 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.