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: Istio implementation #341

Merged
merged 10 commits into from
Jan 9, 2020
Merged

feat: Istio implementation #341

merged 10 commits into from
Jan 9, 2020

Conversation

dthomson25
Copy link
Member

Integrates Istio with Rollouts based on https://github.com/argoproj/argo-rollouts/blob/master/docs/features/traffic-management/istio.md.

Future work:

  • validation on the virtual Service (i.e. ensuring the virtual service has only 2 destinations)
  • Storing a status based on the Virtual Service
  • Integrating with the CLI

@codecov
Copy link

codecov bot commented Jan 2, 2020

Codecov Report

Merging #341 into master will increase coverage by 0.05%.
The diff coverage is 86.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #341      +/-   ##
==========================================
+ Coverage   83.95%   84.01%   +0.05%     
==========================================
  Files          67       69       +2     
  Lines        6215     6350     +135     
==========================================
+ Hits         5218     5335     +117     
- Misses        711      721      +10     
- Partials      286      294       +8
Impacted Files Coverage Δ
utils/log/log.go 100% <ø> (ø) ⬆️
rollout/controller.go 74.39% <100%> (+0.47%) ⬆️
rollout/canary.go 86.34% <100%> (+0.11%) ⬆️
rollout/sync.go 74.93% <33.33%> (-0.65%) ⬇️
utils/replicaset/canary.go 79.45% <50%> (-0.83%) ⬇️
rollout/trafficrouting/istio/istio.go 89.01% <89.01%> (ø)
rollout/trafficrouting.go 93.1% <93.1%> (ø)

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 0866322...0979a53. Read the comment docs.

@dthomson25 dthomson25 changed the title Istio implemenation feature: Istio implemenation Jan 2, 2020
@dthomson25 dthomson25 changed the title feature: Istio implemenation enhancement: Istio implementation Jan 2, 2020
@dthomson25 dthomson25 changed the title enhancement: Istio implementation feat: Istio implementation Jan 3, 2020
@@ -37,6 +37,10 @@ func DesiredReplicaCountsForCanary(rollout *v1alpha1.Rollout, newRS, stableRS *a
desiredNewRSReplicaCount = rolloutSpecReplica
desiredStableRSReplicaCount = 0
}
if rollout.Spec.Strategy.Canary.TrafficRouting != nil {
desiredStableRSReplicaCount = rolloutSpecReplica
Copy link
Member

Choose a reason for hiding this comment

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

This probably needs some explanation/comment here that unlike the replicaset based weighted canary, a service mesh / ingress based canary leaves the stable as 100% scaled until the rollout completes.


// TrafficRoutingReconciler common function across all TrafficRouting implementation
type TrafficRoutingReconciler interface {
Reconcile() error
Copy link
Member

@jessesuen jessesuen Jan 7, 2020

Choose a reason for hiding this comment

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

The TrafficRoutingReconciler interface containing a Reconcile() method which takes no args (since the args for reconcilation were supplied as part of the constructor) is a little odd. I would expect the interface to be flipped, more like:

type TrafficRoutingReconciler interface {
    Reconcile(roCtx rolloutContext, desiredWeight int32) error
}

This makes the interface more extensible if there are additional methods that need to be added which take different set of args.

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 fine too:

type TrafficRoutingReconciler interface {
    Reconcile(desiredWeight int32) error
}

_, index := replicasetutil.GetCurrentCanaryStep(rollout)
desiredWeight := int32(0)
if !atDesiredReplicaCount {
//Use the previous weight since the new RS is not ready for neww weight
Copy link
Member

Choose a reason for hiding this comment

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

  1. Typo neww
  2. space after //
  3. grammar is not ready for a new

olderRS := roCtx.OlderRSs()

atDesiredReplicaCount := replicasetutil.AtDesiredReplicaCountsForCanary(rollout, newRS, stableRS, olderRS)
_, index := replicasetutil.GetCurrentCanaryStep(rollout)
Copy link
Member

Choose a reason for hiding this comment

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

Can index be nil? If yes, it's possible to get nil pointer dereference below.

}
// This if statement prevents the desiredWeight being set to 100
// when the rollout has progressed through all the steps. The rollout
// should send all traffic to the stable service by using a weight of 0
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 this comment is actually referring to the following else if on line 51, but is included in the previous if block, which confused me. I think it should be moved under else if *index != int32(len(rollout.Spec.Strategy.Canary.Steps)), and explained what it means if we are there.

Copy link
Member

@jessesuen jessesuen left a comment

Choose a reason for hiding this comment

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

Logic looks correct. Just some style issues.

Also, I think with this approach, we should in the future consider adding an istio virtual service informer which will react immediately to out-of-band changes of the weights.

}
patches = append(patches, patch)
}
if host == stableSvc && weight != int64(100-desiredWeight) {

Choose a reason for hiding this comment

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

unnecessary conversion (from unconvert)

patch := virtualServicePatch{
routeIndex: i,
destinationIndex: j,
weight: int64(100 - desiredWeight),

Choose a reason for hiding this comment

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

unnecessary conversion (from unconvert)

@dthomson25 dthomson25 force-pushed the istio branch 2 times, most recently from 325aff9 to c6d6591 Compare January 8, 2020 00:59
@dthomson25 dthomson25 merged commit 3b4b31d into master Jan 9, 2020
@dthomson25 dthomson25 deleted the istio branch January 9, 2020 02:19
@dthomson25
Copy link
Member Author

addresses #40

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.

3 participants