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
Bug 1970805: Replace slashes in suggested ImageStream name #922
Conversation
|
@alicerum: This pull request references Bugzilla bug 1970805, which is invalid:
Comment In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/bugzilla refresh |
|
@alicerum: This pull request references Bugzilla bug 1970805, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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
|
/retest |
pkg/helpers/newapp/app/imageref.go
Outdated
| if r.AsImageStream { | ||
| // in some certain situations, suggested ImageStream name might contain slashes | ||
| // in this case we want to replace it with dashes, referenced object might | ||
| // contain said dashes, but imagestream must cannot | ||
| // example: https://bugzilla.redhat.com/show_bug.cgi?id=1970805 | ||
| name = strings.ReplaceAll(name, "/", "-") | ||
| } |
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 think we could future-proof this some by eliminating the r.AsImageStream check and just always replacing slashes with dashes.
| if r.AsImageStream { | |
| // in some certain situations, suggested ImageStream name might contain slashes | |
| // in this case we want to replace it with dashes, referenced object might | |
| // contain said dashes, but imagestream must cannot | |
| // example: https://bugzilla.redhat.com/show_bug.cgi?id=1970805 | |
| name = strings.ReplaceAll(name, "/", "-") | |
| } | |
| // in some certain situations, suggested ImageStream name might contain slashes | |
| // in this case we want to replace it with dashes, referenced object might | |
| // contain said dashes, but imagestream must cannot | |
| // example: https://bugzilla.redhat.com/show_bug.cgi?id=1970805 | |
| name = strings.ReplaceAll(name, "/", "-") |
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.
At first I was going to argue that this is only the ImageStream issue, and other types of image references must be left intact, but after giving it a thought, I realized that you are right.
SuggestedName is used to generate names or part of names for internal k8s objects, and those names must follow the DNS standard, hence, no slashes. I think it is safe to assume we will never need slashes in any names here.
Do you think we might go even further and replace all the non[alphanumeric, dash or dot] symbols here?
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.
So, basically replace this with a regexp that replaces all non-valid characters with dashes? I think that sounds like a great idea.
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.
@coreydaley yeah, [^0-9a-zA-Z-.] should do the trick. From what I read, k8s names should go along with rfc1123, which references rfc952, which says, only alphanumeric, dots and dashes are allowed in a hostname. So, I thought it might be better to go with this more uniform approach rather than just slashes.
f7df518
to
3f63f26
Compare
|
/retest |
| switch { | ||
| case r.Stream != nil: | ||
| name = r.Stream.Name | ||
| case len(r.ObjectName) > 0: | ||
| name = r.ObjectName | ||
| case len(r.Reference.Name) > 0: | ||
| name = r.Reference.Name |
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.
+1, love seeing switch statements instead of multiple if or if/else
3f63f26
to
2f53c08
Compare
pkg/helpers/newapp/app/imageref.go
Outdated
| ) | ||
|
|
||
| func init() { | ||
| dnsNamePattern = regexp.MustCompile("[^a-zA-Z0-9-.]") |
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 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.
ah, so no dots either. thanks.
2f53c08
to
e1add72
Compare
|
/lgtm |
|
/assign @adambkaplan |
|
/retest |
pkg/helpers/newapp/app/imageref.go
Outdated
| var ( | ||
| dnsNamePattern *regexp.Regexp | ||
| ) | ||
|
|
||
| func init() { | ||
| dnsNamePattern = regexp.MustCompile("[^a-zA-Z0-9-]") | ||
| } | ||
|
|
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.
| var ( | |
| dnsNamePattern *regexp.Regexp | |
| ) | |
| func init() { | |
| dnsNamePattern = regexp.MustCompile("[^a-zA-Z0-9-]") | |
| } | |
| var ( | |
| dnsNamePattern *regexp.Regexp = regexp.MustCompile("[^a-zA-Z0-9-]") | |
| ) | |
I don't think you need this init here, the regexp can just be a var, unless there is a specific reason to use init that I am missing?
e1add72
to
39ec815
Compare
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
10 similar comments
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/hold Something appears to be broken; |
|
/retest |
1 similar comment
|
/retest |
|
@soltysh looks like another broken test for e2e-agnostic-cmd |
|
/retest |
1 similar comment
|
/retest |
|
@adambkaplan finally test has passed |
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.
/hold cancel
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adambkaplan, alicerum, coreydaley, gabemontero, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
5 similar comments
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
/retest-required Please review the full test history for this PR and help us cut down flakes. |
|
@alicerum: All pull requests linked via external trackers have merged: Bugzilla bug 1970805 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
When figuring out an image stream name for created build objects,
SuggestNamefunction can return name with slashes in some situations.It is important to hold correct data (that including slashes, too) in the
ImageRefobject, because it is used in other places and can lead to errors.SuggestNamemethod of theImageRefhowever, should return name without slashes when suggesting name for anImageStream.