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

sort secrets and configs to ensure idempotence #509

Merged

Conversation

xificurC
Copy link

@xificurC xificurC commented Sep 7, 2017

docker stack deploy keeps restarting services it doesn't need to (no changes)
because the entries' order gets randomized at some previous (de)serialization.
Maybe it would be worth looking into this at a higher level and ensure
all (de)serialization happens in an ordered collection.

This quick fix sorts secrets and configs (in place, mutably) which ensures the
same order for each run.

Based on
moby/moby#30506

Fixes
moby/moby#34746

@codecov-io
Copy link

codecov-io commented Sep 7, 2017

Codecov Report

Merging #509 into master will decrease coverage by 0.02%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master     #509      +/-   ##
==========================================
- Coverage   49.01%   48.99%   -0.03%     
==========================================
  Files         199      199              
  Lines       16392    16402      +10     
==========================================
+ Hits         8035     8036       +1     
- Misses       7939     7948       +9     
  Partials      418      418

Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Thanks. It looks like ParseSecrets() and ParseConfigs() do randomize the order of these unfortunately.

I think sorting is the correct solution, but I don't think the sort belongs in this function. Could you please move it to convertServiceSecrets() and convertServiceConfigObjs()

@xificurC xificurC force-pushed the fix-secrets-and-configs-idempotence branch from b03cbbb to 34f8c0f Compare September 8, 2017 13:53
`docker stack deploy` keeps restarting services it doesn't need to (no changes)
because the entries' order gets randomized at some previous (de)serialization.
Maybe it would be worth looking into this at a higher level and ensure
all (de)serialization happens in an ordered collection.

This quick fix sorts secrets and configs (in place, mutably) which ensures the
same order for each run.

Based on
moby/moby#30506

Fixes
moby/moby#34746

Signed-off-by: Peter Nagy <xificurC@gmail.com>
@xificurC xificurC force-pushed the fix-secrets-and-configs-idempotence branch from 34f8c0f to 27e8bdf Compare September 8, 2017 14:10
@xificurC
Copy link
Author

xificurC commented Sep 8, 2017

refactored as requested

Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

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 🐮

@mghazizadeh
Copy link

How's this tested?

@vieux
Copy link
Contributor

vieux commented Nov 15, 2017

@mghazizadeh the steps are given on the upstream PR: moby/moby#34746

vdemeester added a commit to vdemeester/docker-cli that referenced this pull request Nov 30, 2017
Related PR : docker#509

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
vdemeester added a commit to vdemeester/docker-cli that referenced this pull request Nov 30, 2017
Related PR : docker#509

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
vdemeester added a commit to vdemeester/docker-cli that referenced this pull request Nov 30, 2017
Related PR : docker#509

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
vdemeester added a commit to vdemeester/docker-cli that referenced this pull request Nov 30, 2017
Related PR : docker#509

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
vdemeester added a commit to vdemeester/docker-cli that referenced this pull request Nov 30, 2017
Related PR : docker#509

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
@vieux
Copy link
Contributor

vieux commented Nov 30, 2017

@mghazizadeh test was added in #719

andrewhsu pushed a commit to docker-archive/docker-ce that referenced this pull request Dec 1, 2017
Related PR : docker/cli#509

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 5ed399e58873944bf5e992284c751a200417318c
Component: cli
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.

8 participants