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

feat: Add name attribute to ServicePort #2572

Merged
merged 9 commits into from
Feb 9, 2023

Conversation

daniddelrio
Copy link
Contributor

@daniddelrio daniddelrio commented Feb 7, 2023

We encountered this error when we tried to run an Experiment for a service with multiple named ports:

Failed to create Service for template 'smoketest': Service
    is invalid: [spec.ports[0].name: Required value,
    spec.ports[1].name: Required value, spec.ports[2].name:
    Required value]

Argo Rollouts currently only copies the port number and protocol from the Rollout to the service it creates during experiments, but not the name. This PR addresses this issue by also including the port name when copying.

Relates to: #2397

fixes: #2599

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional with a list of types and scopes found here, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed my commits with DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

@daniddelrio daniddelrio changed the title Add name attribute to ServicePort feat: Add name attribute to ServicePort Feb 7, 2023
Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>
Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

Go Published Test Results

1 850 tests   1 850 ✔️  2m 31s ⏱️
   112 suites         0 💤
       1 files           0

Results for commit 96a9313.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

E2E Tests Published Test Results

    2 files      2 suites   1h 35m 9s ⏱️
  96 tests   91 ✔️ 3 💤 2
194 runs  186 ✔️ 6 💤 2

For more details on these failures, see this check.

Results for commit 96a9313.

♻️ This comment has been updated with latest results.

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>
@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Base: 81.60% // Head: 81.60% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (96a9313) compared to base (24c9621).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2572   +/-   ##
=======================================
  Coverage   81.60%   81.60%           
=======================================
  Files         130      130           
  Lines       19481    19483    +2     
=======================================
+ Hits        15898    15900    +2     
  Misses       2766     2766           
  Partials      817      817           
Impacted Files Coverage Δ
experiments/experiment.go 89.93% <100.00%> (+0.04%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -290,6 +290,7 @@ func (ec *experimentContext) createTemplateService(template *v1alpha1.TemplateSp
for _, ctr := range rs.Spec.Template.Spec.Containers {
for _, port := range ctr.Ports {
servicePort := corev1.ServicePort{
Name: port.Name,
Copy link
Member

Choose a reason for hiding this comment

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

I believe ports can also be unnamed. what is the default value here, is it compatible? (ideally type's default which is "")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Documentation says it will be omitted if the name is not given. Should we make it by default an empty string if not given?

Copy link
Member

Choose a reason for hiding this comment

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

I would not set it at all

@@ -26,5 +26,6 @@ spec:
memory: 16Mi
cpu: 1m
ports:
- protocol: TCP
- name: testport
Copy link
Member

Choose a reason for hiding this comment

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

does the test fail when name is not present? can we rather have two tests, one with single, unnamed port, another one with two named ports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, test fails when name isn't present. I'll try that out

Copy link
Member

Choose a reason for hiding this comment

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

okay, so let's make sure the test doesn't fails without name first

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>
Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>
@daniddelrio daniddelrio marked this pull request as ready for review February 8, 2023 13:16
@@ -70,6 +70,7 @@ func setExperimentService(template *v1alpha1.TemplateSpec) {
template.Service = &v1alpha1.TemplateService{}
template.Template.Spec.Containers[0].Ports = []corev1.ContainerPort{
{
Name: "testport",
Copy link
Member

Choose a reason for hiding this comment

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

this is not needed any more

@alexef alexef requested a review from zachaller February 8, 2023 13:45
@alexef alexef added the enhancement New feature or request label Feb 8, 2023
Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>
g.ApplyManifests("@functional/experiment-with-multiport-service.yaml")
g.When().
WaitForExperimentPhase("experiment-with-multiport-service", "Running").
Sleep(time.Second*5).
Copy link
Collaborator

@zachaller zachaller Feb 8, 2023

Choose a reason for hiding this comment

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

Suggested change
Sleep(time.Second*5).
WaitForExperimentCondition("experiment-with-service", func(ex *rov1.Experiment) bool {
return s.GetReplicaSetFromExperiment(ex, "test").Status.Replicas == 1
}, "number-of-rs-pods-meet", fixtures.E2EWaitTimeout).

I saw a few test have these long waits I would rather not slow down the e2e tests any more, I think this is what you where trying to accomplish if so could you switch to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexef what do you think about this?

Copy link
Member

Choose a reason for hiding this comment

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

the proposed change makes sense, most of the time rs gets ready in less than 5 seconds

ExpectExperimentServiceCount("experiment-with-multiport-service", 1).
When().
WaitForExperimentPhase("experiment-with-multiport-service", "Successful").
Sleep(time.Second*15).
Copy link
Collaborator

@zachaller zachaller Feb 8, 2023

Choose a reason for hiding this comment

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

Suggested change
Sleep(time.Second*15).
WaitForExperimentCondition("experiment-with-service", func(ex *rov1.Experiment) bool {
return s.GetReplicaSetFromExperiment(ex, "test").Status.Replicas == 0
}, "number-of-rs-pods-meet", fixtures.E2EWaitTimeout).

I saw a few test have these long waits I would rather not slow down the e2e tests any more, I think this is what you where trying to accomplish if so could you switch to it?

@sonarcloud
Copy link

sonarcloud bot commented Feb 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
5.1% 5.1% Duplication

@zachaller zachaller merged commit 0450778 into argoproj:master Feb 9, 2023
@zachaller
Copy link
Collaborator

Thanks for contributing!

kaldorn pushed a commit to getoutreach/argoproj-argo-rollouts that referenced this pull request Feb 9, 2023
* Add name attribute to ServicePort

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Format with gofmt

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Update experiment test by adding port name

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Include port name only when given

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Implement separate e2e tests for single unnamed port and two named ports

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Remove port name in experiment_test.go

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Replace Sleep in new multiport service experiment

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

---------

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>
Signed-off-by: kaldorn <nate.kaldor@outreach.io>
@zachaller zachaller added cherry-pick/release-1.4 cherry-pick-completed Used once we have cherry picked the PR to all requested releases labels Feb 23, 2023
zachaller pushed a commit that referenced this pull request Feb 24, 2023
* Add name attribute to ServicePort

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Format with gofmt

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Update experiment test by adding port name

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Include port name only when given

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Implement separate e2e tests for single unnamed port and two named ports

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Remove port name in experiment_test.go

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

* Replace Sleep in new multiport service experiment

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>

---------

Signed-off-by: Daniel Del Rio <daniel.delrio@getyourguide.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick/release-1.4 cherry-pick-completed Used once we have cherry picked the PR to all requested releases enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v1.4.0 Failed to create Service for template -- port.Name not being passed to CreateService
3 participants