-
Notifications
You must be signed in to change notification settings - Fork 243
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 duplicate port validation, update devfile libraries, and add tests to check port name matches endpoint name #5407
Add duplicate port validation, update devfile libraries, and add tests to check port name matches endpoint name #5407
Conversation
✔️ Deploy Preview for odo-docusaurus-preview canceled. 🔨 Explore the source changes: 034f7ed 🔍 Inspect the deploy log: https://app.netlify.com/sites/odo-docusaurus-preview/deploys/62037b9e857193000826d26a |
pkg/envinfo/url.go
Outdated
return fmt.Errorf("url %v already exists in devfile endpoint entry under container %q", url.Name, component.Name) | ||
} | ||
// Check for a duplicate port entry | ||
if endpoint.TargetPort == url.Port { |
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'm not sure to understand when updateURL is set to true. Do you think it could be needed to test its value here also?
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 it is set to true when you do not pass a URL name, and an invalid endpoint exists in the devfile. I'm not sure why it is as such, but that is my understanding.
Lines 117 to 131 in b75fa55
// get the name for the URL if not provided | |
if len(url.Name) == 0 { | |
foundURL, err := findInvalidEndpoint(ei, url.Port) | |
if err != nil { | |
return err | |
} | |
if foundURL.Name != "" { | |
// found an URL that can be overridden or more info can be added to it | |
url.Name = foundURL.Name | |
ei.updateURL = true | |
} else { | |
url.Name = util.GetURLName(ei.GetName(), url.Port) | |
} | |
} |
It seems you will have to adapt some tests that are using duplicated port numbers: https://s3.eu-de.cloud-object-storage.appdomain.cloud/odo-tests-openshift-logs/pr-5407-openshift-tests-441.html |
96422d9
to
4a8122b
Compare
@feloy Please hold your review on this one for now. |
cbed450
to
c767702
Compare
/retest-required |
f0f6806
to
df5a550
Compare
…s to check port name matches endpoint name
df5a550
to
ce1a190
Compare
/lgtm |
This case is detected by tests on IBMCloud/Kubernetes but not on Prow tests:
|
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@feloy Can you review it again? |
/lgtm |
Doesn't seem to work, or am I doing it incorrect? git clone https://github.com/odo-devfiles/nodejs-ex
odo create nodejs foobar
odo push=
odo url create --port 3000 foobar --host k8s.land
✗ URL creation failed:
- port 3000 already exists in devfile endpoint entry under container "runtime" |
The error is expected, as the nodejs devfile already contains an endpoint for this specific port and you cannot create several endpoints with same port anymore:
|
after discussion with @valaparthvi this /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cdrage 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 |
…s to check port name matches endpoint name (redhat-developer#5407) * Add duplicate port validation, update devfile libraries, and add tests to check port name matches endpoint name * Fix k8s test
/cherrypick v2 |
@valaparthvi: new pull request created: #5475 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. |
…s to check port name matches endpoint name (redhat-developer#5407) * Add duplicate port validation, update devfile libraries, and add tests to check port name matches endpoint name * Fix k8s test
What type of PR is this:
/kind bug
What does this PR do / why we need it:
This PR adds duplicate port validation, updates devfile libraries, and adds tests to ensure port name matches endpoint names.
Which issue(s) this PR fixes:
Fixes #4737
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer:
Port name matches endpoint name validation
Duplicate port validation