-
Notifications
You must be signed in to change notification settings - Fork 294
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
Fixes #38269 - fix container-image-name #11336
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -950,6 +950,11 @@ def self.safe_render_container_name(repository, pattern = nil) | |
env_exists = repository.environment.present? | ||
is_env_pattern_provided = env_exists && repository.environment.registry_name_pattern.present? | ||
is_cv_default = repository.content_view.default? | ||
items = if Validators::ContainerImageNameValidator.validate_name(repository.organization.label) | ||
[repository.organization.label] | ||
else | ||
['id', repository.organization.id] | ||
end | ||
|
||
if is_env_pattern_provided || (is_pattern_provided && env_exists) | ||
pattern ||= repository.environment.registry_name_pattern | ||
|
@@ -968,11 +973,11 @@ def self.safe_render_container_name(repository, pattern = nil) | |
pattern = box.eval(erb.src, allowed_vars, scope_variables) | ||
return Repository.clean_container_name(pattern) | ||
elsif is_cv_default && !is_pattern_provided | ||
items = [repository.organization.label, repository.product.label, repository.label] | ||
items += [repository.product.label, repository.label] | ||
elsif env_exists | ||
items = [repository.organization.label, repository.environment.label, repository.content_view.label, repository.product.label, repository.label] | ||
items += [repository.environment.label, repository.content_view.label, repository.product.label, repository.label] | ||
else | ||
items = [repository.organization.label, repository.content_view.label, repository.content_view_version.version, repository.product.label, repository.label] | ||
items += [repository.content_view.label, repository.content_view_version.version, repository.product.label, repository.label] | ||
end | ||
Repository.clean_container_name(items.compact.join("/")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see why the VCR tests are failing now. The label needs to have In fact, this raises the question if we even need to use this ID method at all. We already seem to have a precedent for cleaning up container names, which could cause them to clash. So, the question is then, what is missing from this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think what is missing is a check for an underscore before a forward slash, like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but the question is: what should it do with it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the collision is okay since it's the current norm. If an organization label contained any of the characters that are cleaned up today, it could already collide, which we have handling for. Theoretically, the error will then bubble up to the user that they need to update their name. In this case, it could mean removing the organization name from the lifecycle environment container naming pattern. It's likely that the error won't immediately tell users what the issue is, but it would also (hopefully) be super rare that a user would have two organizations where the only difference is a special character at the end. And in that case, we have a workaround that they can apply (change the name pattern) once they dig into it. The error would be The message could potentially be improved to guide the users to the fix. The reason I'm thinking hard about the above is that this new logic would probably have users wondering why
On top of that, since it's a very rare case, it makes me wonder if the regression risk is work the gain. All that said, it's better for users if they have more flexibility. I think, if we go the ID route, we'll want to have it work as well for content views, repositories, lifecycle environments, and products. All of these records could suffer from the same collision issue.
Edit: the naming pattern can't include IDs, but the pattern could be modified to not have the organization in it at least (or provide a custom label) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One more thought, even if the orgs are the same, the other parts that make up the name would also have to collide for it to be a problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
end | ||
|
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.
Here is the official regex from the OCI spec:
https://specs.opencontainers.org/distribution-spec/?v=v1.0.0#DISTRIBUTION-SPEC-27
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.
There seems to be a small difference to how pulp_container defines it, they do a
split('/')
first and check each element separately:https://github.com/pulp/pulp_container/blob/main/pulp_container/app/serializers.py#L39
The official regex would suggest that
.
,-
, and_
must be followed by alphanumerical character soa__b
orc---d
would not be allowed. While pulp seems to explicitly allow them 😵If we choose the official Regexp we should make sure that pulp uses that one as well.
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 mostly posted this in case it was interesting, we don't need to open this can of worms yet :)
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.
Nice catch though, I can ask them why their regex is different from the OCI one. Maybe the OCI spec changed at some point.