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

Add randomly generated slug to container names to prevent collisions #6140

Merged
merged 2 commits into from Sep 19, 2018

Conversation

shin-
Copy link

@shin- shin- commented Aug 15, 2018

Fixes #4688

@shin- shin- force-pushed the 4688_no_sequential_ids branch 2 times, most recently from 69be0a3 to 554eca2 Compare August 16, 2018 00:07
@shin- shin- added this to the 1.23.0 milestone Aug 16, 2018
@shin- shin- force-pushed the 4688_no_sequential_ids branch 3 times, most recently from 3a19eeb to 1165301 Compare September 1, 2018 00:02
@shin- shin- requested a review from mnottale September 4, 2018 18:38
Signed-off-by: Joffrey F <joffrey@docker.com>
@shin- shin- changed the title Replace sequential container indexes with randomly generated IDs Add randomly generated slug to container names to prevent collisions Sep 11, 2018
@shin-
Copy link
Author

shin- commented Sep 11, 2018

Relating to #1516 , this fixes concerns 2 and 3. The costly queries are unfortunately still there, but this PR is a compromise intended to cause minimal disruption to existing workflows.

While this can be seen as a breaking change in the sense that container names can no longer be inferred the way they could before, it should be noted that

  1. Compose never made any guarantees about the naming pattern of the containers it creates
  2. Relying on inferred patterns can result in unexpected errors when the sequentiality breaks, making it something to avoid wherever possible
  3. In the rare cases where it is necessary, scripts will still be able to fetch individual containers based on the predictable prefix (the part before the slug), with the caveats mentioned above. The prefix is also backward-compatible.

Copy link

@Dimrok Dimrok left a comment

Choose a reason for hiding this comment

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

LGTM except for a few minor questions.

compose/service.py Outdated Show resolved Hide resolved
@@ -151,3 +152,21 @@ def unquote_path(s):
if s[0] == '"' and s[-1] == '"':
return s[1:-1]
return s


def generate_random_id():
Copy link

Choose a reason for hiding this comment

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

Why do we use such a complicated algorithm to generate a random identifier? And is there any specific reason we don't want a fully numerical ID?

Otherwise uuid.uuid4().hex sounds good to generate a hexadecimal identifier, no?

Copy link
Author

Choose a reason for hiding this comment

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

The code is a transposition of https://github.com/moby/moby/blob/master/pkg/stringid/stringid.go ; we could go with a UUID instead.

assert 'Removing v2-full_web_' in result.stderr
assert 'Removing v2-full_other_' in result.stderr
assert 'Removing v2-full_web_run_' in result.stderr
assert 'Removing v2-full_web_run_' in result.stderr
Copy link

Choose a reason for hiding this comment

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

Duplicated.

tests/acceptance/cli_test.py Show resolved Hide resolved
Signed-off-by: Joffrey F <joffrey@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants