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

Fix stack deploy re-deploying service after --force #963

Merged
merged 1 commit into from
Apr 13, 2018

Conversation

thaJeztah
Copy link
Member

When updating a service with the --force option, the ForceUpdate property of the taskspec is incremented.

Stack deploy did not take this into account, and reset this field to its default value (0), causing the service to be re-deployed.

This patch copies the existing value before updating the service.

fixes moby/moby#36028

- Description for the changelog

* Fix docker stack deploy re-deploying services after the service was updated with `--force` []()

When updating a service with the `--force` option, the `ForceUpdate`
property of the taskspec is incremented.

Stack deploy did not take this into account, and reset this
field to its default value (0), causing the service to be
re-deployed.

This patch copies the existing value before updating the service.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐯

// Stack deploy does not have a `--force` option. Preserve existing ForceUpdate
// value so that tasks are not re-deployed if not updated.
// TODO move this to API client?
serviceSpec.TaskTemplate.ForceUpdate = service.Spec.TaskTemplate.ForceUpdate
Copy link
Member Author

Choose a reason for hiding this comment

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

I was also comparing serviceSpec with service.Spec here, and noticed there's quite some other properties that differ; not sure if those are expected;

{"Name":"test_redis","Labels":{"com.docker.stack.image":"redis:3.2.8","com.docker.stack.namespace":"test"},"TaskTemplate":{"ContainerSpec":{"Image":"redis:3.2.8@sha256:8eb0cd22644dc1218680db876411f45baac493ac9a0bfd391d6efdef0767ea6b","Labels":{"com.docker.stack.namespace":"test"},"Privileges":{"CredentialSpec":null,"SELinuxContext":null},"Isolation":"default"},"Resources":{},"Placement":{"Platforms":[{"Architecture":"amd64","OS":"linux"}]},"Networks":[{"Target":"x5ce5v6s4fzjdd6eavt9njahb","Aliases":["redis"]}],"ForceUpdate":1,"Runtime":"container"},"Mode":{"Replicated":{"Replicas":1}},"EndpointSpec":{"Mode":"vip"}}
{"Name":"test_redis","Labels":{"com.docker.stack.image":"redis:3.2.8","com.docker.stack.namespace":"test"},"TaskTemplate":{"ContainerSpec":{"Image":"redis:3.2.8                                                                        ","Labels":{"com.docker.stack.namespace":"test"},"Privileges":{"CredentialSpec":null,"SELinuxContext":null}                      },"Resources":{},"Placement":{                                                   },"Networks":[{"Target":"test_default"             ,"Aliases":["redis"]}],"ForceUpdate":1                      },"Mode":{"Replicated":{            }},"EndpointSpec":{            }}

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM

@tiborvass
Copy link
Collaborator

LGTM

@tiborvass tiborvass merged commit 6b31ea0 into docker:master Apr 13, 2018
@GordonTheTurtle GordonTheTurtle added this to the 18.05.0 milestone Apr 13, 2018
@thaJeztah thaJeztah deleted the fix-stack-deploy-after-force branch April 13, 2018 23:14
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.

swarm: stack deploy needlessly updates service which was force-updated before
5 participants