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

Issue #91 - Ability to specify canaryService Service object to reach only canary pods #100

Merged
merged 3 commits into from
Jun 12, 2019

Conversation

alexmt
Copy link
Contributor

@alexmt alexmt commented Jun 7, 2019

Closes #91

@alexmt alexmt requested review from dthomson25 and jessesuen June 7, 2019 20:51
@codecov-io
Copy link

codecov-io commented Jun 7, 2019

Codecov Report

Merging #100 into master will increase coverage by 0.11%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #100      +/-   ##
==========================================
+ Coverage   78.97%   79.09%   +0.11%     
==========================================
  Files          15       15              
  Lines        1798     1808      +10     
==========================================
+ Hits         1420     1430      +10     
  Misses        278      278              
  Partials      100      100
Impacted Files Coverage Δ
controller/service.go 87.07% <100%> (+0.74%) ⬆️
controller/canary.go 82.41% <100%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a16fdc2...8ef477d. Read the comment docs.

svc.Spec.Selector = make(map[string]string)
}

hash := controller.ComputeHash(&r.Spec.Template, r.Status.CollisionCount)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of calculating the hash from the template, we should use calculate the hash from the newRS podSpec to protect against the k8s dependency change (#88).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


hash := controller.ComputeHash(&r.Spec.Template, r.Status.CollisionCount)
if svc.Spec.Selector[v1alpha1.DefaultRolloutUniqueLabelKey] != hash {
patch := fmt.Sprintf(switchSelectorPatch, v1alpha1.DefaultRolloutUniqueLabelKey, hash)
Copy link
Member

Choose a reason for hiding this comment

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

Can you use the c.switchServiceSelector method to patch the service?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

func TestCanaryRolloutWithCanaryService(t *testing.T) {
f := newFixture(t)

canarySvc := newService("canary", 80, make(map[string]string))
Copy link
Member

Choose a reason for hiding this comment

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

What is there a reason that you instantiate the selector to nothing? If we don't, that will allow us to also test the case where the selector is nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Changed make(map[string]string) to nil.

newStatus := r.Status.DeepCopy()
cond := conditions.NewRolloutCondition(v1alpha1.RolloutProgressing, corev1.ConditionFalse, conditions.ServiceNotFoundReason, msg)
conditions.SetRolloutCondition(newStatus, *cond)
c.persistRolloutStatus(r, newStatus, &r.Spec.Paused)
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we should abstract this logic into a separate method because we have this code repeated 3 times. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch! done

controller/service.go Show resolved Hide resolved
@alexmt alexmt force-pushed the 91-canary-preview branch 2 times, most recently from 7072113 to a017bd9 Compare June 11, 2019 19:50
@@ -155,6 +156,35 @@ func (c *Controller) getPreviewAndActiveServices(r *v1alpha1.Rollout) (*corev1.S
return previewSvc, activeSvc, nil
}

func (c *Controller) reconcileCanaryService(r *v1alpha1.Rollout, newRS *appsv1.ReplicaSet) error {
if r.Spec.Strategy.CanaryStrategy != nil && r.Spec.Strategy.CanaryStrategy.CanaryService != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Style nit, we would save a block of indentation with:

if r.Spec.Strategy.CanaryStrategy == nil || r.Spec.Strategy.CanaryStrategy.CanaryService == "" {
    return nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@alexmt alexmt force-pushed the 91-canary-preview branch 2 times, most recently from 60d9612 to 9919549 Compare June 11, 2019 22:15
@alexmt
Copy link
Contributor Author

alexmt commented Jun 11, 2019

Addressed review comments. Also discovered that tests became flaky after merging #95: additional service index requires run syncronize informers in test. The 9919549 fixes it

@@ -3,17 +3,16 @@ package controller
import (
"fmt"

"github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
"github.com/argoproj/argo-rollouts/utils/conditions"
logutil "github.com/argoproj/argo-rollouts/utils/log"
Copy link
Member

Choose a reason for hiding this comment

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

Style nix: can we move this back below the external lib imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@alexmt alexmt force-pushed the 91-canary-preview branch from 9919549 to ad9a918 Compare June 11, 2019 23:49
Copy link
Member

@dthomson25 dthomson25 left a comment

Choose a reason for hiding this comment

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

LGTM

@alexmt alexmt force-pushed the 91-canary-preview branch from ad9a918 to 8ef477d Compare June 11, 2019 23:53
@alexmt alexmt merged commit 89dc7be into argoproj:master Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to specify canaryService Service object to reach only canary pods
4 participants