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

use endpoint name as container port name and service port name #128

Merged
merged 1 commit into from
Jan 21, 2022

Conversation

yangcao77
Copy link
Collaborator

Signed-off-by: Stephanie yangcao@redhat.com

What does this PR do?:

use endpoint name as container port name and service port name if <= 15 chars. if > 15 chars (devfile spec before the change to shorten endpoint name limit), use port-<portNumber>

Which issue(s) this PR fixes:

Fixes devfile/api#700

PR acceptance criteria:

Testing and documentation do not need to be complete in order for this PR to be approved. We just need to ensure tracking issues are opened.

  • Open new test/doc issues under the devfile/api repo
  • Check each criteria if:
  • There is a separate tracking issue. Add the issue link under the criteria
    or
  • test/doc updates are made as part of this PR
  • If unchecked, explain why it's not needed

How to test changes / Special notes to the reviewer:

…15chars

Signed-off-by: Stephanie <yangcao@redhat.com>
@yangcao77
Copy link
Collaborator Author

@valaparthvi can you also help verify this PR fixes the Odo issue?

@valaparthvi
Copy link
Contributor

valaparthvi commented Jan 18, 2022

@yangcao77 It works like magic! Thank you for fixing it.
So far I've tested with the following cases, and all seem to work as expected.

  1. passing custom names as mentioned in port names should match endpoint names redhat-developer/odo#4737
  2. without passing any name
  3. with duplicate endpoints
  4. passing a very long name

The svc port names, endpoint port names, and container port names are updated as expected.
I hope I didn't miss out on any case.

@kadel Since you raised the original issue, give it a go if you please.

@@ -347,7 +347,7 @@ const JsonSchema220 = `{
},
"name": {
"type": "string",
"maxLength": 63,
"maxLength": 15,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have corresponding updates in our API docs to show the new max length?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the spec is the api doc

@@ -663,7 +679,7 @@ func TestGetServiceSpec(t *testing.T) {
wantPorts []corev1.ServicePort
}{
{
name: "multiple endpoints share the same port",
name: "multiple endpoints have different ports",
Copy link
Contributor

Choose a reason for hiding this comment

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

This test should cover most of our scenarios since we have validation on unique ports but should we handle the exception case as well where dedicatedPod=true? https://github.com/devfile/api/blob/main/pkg/validation/validation-rule.md#endpoints

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we do not specifially do tests for deficatedPod in library, since it is currently not supported in library. see devfile/api#670

@@ -46,7 +46,12 @@ func convertPorts(endpoints []v1.Endpoint) []corev1.ContainerPort {
} else {
portProtocol = corev1.ProtocolTCP
}
name := fmt.Sprintf("%d-%s", portNumber, strings.ToLower(string(portProtocol)))
name := endpoint.Name
Copy link
Contributor

Choose a reason for hiding this comment

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

We are changing a user provided name underneath the covers if length exceeds 15 characters. It'll be good to warn them of these changes ahead of time (via cmd line, log, and/or doc)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes. This change is because we want to unify the service port name & the container port name. since service port does not accept starting with a number (has to be alphabet), thus we use the convention port-<number>
@valaparthvi FYI.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does the warning need to happen on the odo side?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

correct

@openshift-ci
Copy link

openshift-ci bot commented Jan 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kim-tsao, yangcao77

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@yangcao77 yangcao77 merged commit 2e92729 into devfile:main Jan 21, 2022
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.

container & service port name should use endpoint name
3 participants