-
Notifications
You must be signed in to change notification settings - Fork 115
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
[master] Do not remove the supervisor container before every start #544
Conversation
SUPERVISOR_CONTAINER_IMAGE_ID=$(docker inspect resin_supervisor | jq '.[0].Image') | ||
|
||
if [ "$SUPERVISOR_IMAGE_ID" -eq "$SUPERVISOR_CONTAINER_IMAGE_ID" ]; then | ||
docker start resin_supervisor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like a fallback to removing the container if starting it fails - it can help with auto-recovery in some cases (I think that's why we initially switched to always removing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -133,6 +133,7 @@ fi | |||
# Try to stop old supervisor to prevent it deleting the intermediate images while downloading the new one | |||
echo "Stop supervisor..." | |||
systemctl stop resin-supervisor | |||
$DOCKER rm --force resin_supervisor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be moved to after the successful pull, so that we don't remove the container if the pull fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but I also moved the supervisor.conf change so that it is only changed after a successful pull
|
||
source /usr/sbin/resin-vars | ||
|
||
SUPERVISOR_IMAGE_ID=$(docker inspect $SUPERVISOR_IMAGE | jq '.[0].Id') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth using the --format
option, although I'm not certain what version of docker it was introduced in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done.
(It is indeed supported in 1.10.3)
6ed8090
to
f279abc
Compare
@@ -46,6 +47,7 @@ RDEPENDS_${PN} = " \ | |||
systemd \ | |||
curl \ | |||
resin-device-uuid \ | |||
jq \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this RDEPENDS added? I do not see any jq invocation in the start script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I had added it because I used it in the start-resin-supervisor script, but it's not necessary anymore. Removed.
f279abc
to
452b251
Compare
@@ -0,0 +1,34 @@ | |||
#!/bin/bash | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be useful to set a error out flag on exit code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
SUPERVISOR_CONTAINER_IMAGE_ID=$(docker inspect --format='{{.Image}}' resin_supervisor) | ||
|
||
runSupervisor() { | ||
docker rm --force resin_supervisor || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we try to start it afterwards if it cannot remove the old supervisor? Should we error out if we need to start a new supervisor but we can't remove the current container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The container might not be there at all, that's why (and it's how the service used to work, as it had a -
in the ExecStartPre)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also,if the removal failed and there is actually a container there (which would only happen with a docker bug or some other weird corruption), then the docker run command that follows will fail anyways (with the good old "name already taken" error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha.
@@ -0,0 +1,34 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need bash for this script. POSIX should should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
3 more comments:
|
5e45953
to
79877f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but needs testing
Something related was done as some point: #281 |
7c74ad4
to
15ddf28
Compare
…in every start We add a start-resin-supervisor script that checks whether the existing container's image matches the one specified in supervisor.conf, and just starts that container in that case. It falls back to the docker run command that creates and starts the supervisor container. Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
…update script Also, only write /tmp/supervisor.conf after the image has been successfully pulled and the old container has been removed. Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
15ddf28
to
bb7c26f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased over current HEAD>
[Untested, this is my first attempt]
Instead, we add a start-resin-supervisor script that checks
whether the existing container's image matches the one specified
in supervisor.conf, and just starts that container in that case.
It falls back to the docker run command that creates and starts
the supervisor container.
We also add the container removal in the update-resin-supervisor script,
after stopping the resin-supervisor service.
Closes #184
Also connects to #280 as it should make the issue appear way less often.
Signed-off-by: Pablo Carranza Velez pablo@resin.io