-
Notifications
You must be signed in to change notification settings - Fork 867
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
fix: Use actual weight from status field on rollout object #1937
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
39b0fca
fix: Use actual weight from status field on rollout object
zachaller 94ccef6
Per feedback setting to actual weight to roInfo.SetWeight when not av…
zachaller 9c655e8
fix: add test cases
zachaller 37a33fa
fix: move to own test
zachaller d6df60a
fix: have unique names
zachaller 16e59f5
fix: correct all names in resources
zachaller daac8a0
fix: cleanup copy duplicate test from when I created TestCanaryRollou…
zachaller 72b65f5
fix: add comment and cleanup code
zachaller 93c20eb
fix: nest testing to provide more detail information around tests
zachaller c8095b8
fix: spelling
zachaller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,11 @@ func NewRolloutInfo( | |
} | ||
} | ||
} else { | ||
roInfo.ActualWeight = roInfo.SetWeight | ||
if ro.Status.Canary.Weights != nil { | ||
roInfo.ActualWeight = fmt.Sprintf("%d", ro.Status.Canary.Weights.Canary.Weight) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks good..what happens for bluegreen ? is there a different object with weight? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} else { | ||
roInfo.ActualWeight = roInfo.SetWeight | ||
} | ||
} | ||
} | ||
} else if ro.Spec.Strategy.BlueGreen != nil { | ||
|
96 changes: 96 additions & 0 deletions
96
pkg/kubectl-argo-rollouts/info/testdata/canary/canary-rollout5.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Rollout | ||
metadata: | ||
annotations: | ||
rollout.argoproj.io/revision: "31" | ||
creationTimestamp: "2019-10-25T06:07:18Z" | ||
generation: 429 | ||
labels: | ||
app: canary-demo-weights | ||
app.kubernetes.io/instance: jesse-test | ||
name: canary-demo-weights | ||
namespace: jesse-test | ||
resourceVersion: "28253567" | ||
selfLink: /apis/argoproj.io/v1alpha1/namespaces/jesse-test/rollouts/canary-demo-weights | ||
uid: b350ba76-f6ed-11e9-a15b-42010aa80033 | ||
spec: | ||
progressDeadlineSeconds: 30 | ||
replicas: 5 | ||
revisionHistoryLimit: 3 | ||
selector: | ||
matchLabels: | ||
app: canary-demo-weights | ||
strategy: | ||
canary: | ||
canaryService: canary-demo-preview | ||
stableService: canary-demo-stable | ||
trafficRouting: | ||
smi: | ||
rootService: root-svc # optional | ||
trafficSplitName: rollout-example-traffic-split # optional | ||
steps: | ||
- setWeight: 20 | ||
- pause: {} | ||
- setWeight: 40 | ||
- pause: | ||
duration: 10s | ||
- setWeight: 60 | ||
- pause: | ||
duration: 10s | ||
- setWeight: 80 | ||
- pause: | ||
duration: 10s | ||
template: | ||
metadata: | ||
creationTimestamp: null | ||
labels: | ||
app: canary-demo-weights | ||
spec: | ||
containers: | ||
- image: argoproj/rollouts-demo:does-not-exist | ||
imagePullPolicy: Always | ||
name: canary-demo | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP | ||
resources: | ||
requests: | ||
cpu: 5m | ||
memory: 32Mi | ||
status: | ||
HPAReplicas: 6 | ||
availableReplicas: 5 | ||
blueGreen: {} | ||
canary: | ||
weights: | ||
canary: | ||
podTemplateHash: 868d98998a | ||
serviceName: canary-demo | ||
weight: 20 | ||
stable: | ||
podTemplateHash: 877894d5b | ||
serviceName: canary-demo | ||
weight: 60 | ||
stableRS: 877894d5b | ||
conditions: | ||
- lastTransitionTime: "2019-10-25T06:07:29Z" | ||
lastUpdateTime: "2019-10-25T06:07:29Z" | ||
message: Rollout has minimum availability | ||
reason: AvailableReason | ||
status: "True" | ||
type: Available | ||
- lastTransitionTime: "2019-10-28T04:52:55Z" | ||
lastUpdateTime: "2019-10-28T04:52:55Z" | ||
message: ReplicaSet "canary-demo-65fb5ffc84" has timed out progressing. | ||
reason: ProgressDeadlineExceeded | ||
status: "False" | ||
type: Progressing | ||
currentPodHash: 65fb5ffc84 | ||
currentStepHash: f64cdc9d | ||
currentStepIndex: 0 | ||
observedGeneration: "429" | ||
readyReplicas: 5 | ||
replicas: 6 | ||
selector: app=canary-demo-weights | ||
updatedReplicas: 1 |
87 changes: 87 additions & 0 deletions
87
pkg/kubectl-argo-rollouts/info/testdata/canary/canary-rollout6.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Rollout | ||
metadata: | ||
annotations: | ||
rollout.argoproj.io/revision: "31" | ||
creationTimestamp: "2019-10-25T06:07:18Z" | ||
generation: 429 | ||
labels: | ||
app: canary-demo-weights-na | ||
app.kubernetes.io/instance: jesse-test | ||
name: canary-demo-weights-na | ||
namespace: jesse-test | ||
resourceVersion: "28253567" | ||
selfLink: /apis/argoproj.io/v1alpha1/namespaces/jesse-test/rollouts/canary-demo-weights-na | ||
uid: b350ba76-f6ed-11e9-a15b-42010aa80033 | ||
spec: | ||
progressDeadlineSeconds: 30 | ||
replicas: 5 | ||
revisionHistoryLimit: 3 | ||
selector: | ||
matchLabels: | ||
app: canary-demo-weights-na | ||
strategy: | ||
canary: | ||
canaryService: canary-demo-preview | ||
stableService: canary-demo-stable | ||
trafficRouting: | ||
smi: | ||
rootService: root-svc # optional | ||
trafficSplitName: rollout-example-traffic-split # optional | ||
steps: | ||
- setWeight: 20 | ||
- pause: {} | ||
- setWeight: 40 | ||
- pause: | ||
duration: 10s | ||
- setWeight: 60 | ||
- pause: | ||
duration: 10s | ||
- setWeight: 80 | ||
- pause: | ||
duration: 10s | ||
template: | ||
metadata: | ||
creationTimestamp: null | ||
labels: | ||
app: canary-demo-weights-na | ||
spec: | ||
containers: | ||
- image: argoproj/rollouts-demo:does-not-exist | ||
imagePullPolicy: Always | ||
name: canary-demo | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP | ||
resources: | ||
requests: | ||
cpu: 5m | ||
memory: 32Mi | ||
status: | ||
HPAReplicas: 6 | ||
availableReplicas: 5 | ||
blueGreen: {} | ||
canary: {} | ||
stableRS: 877894d5b | ||
conditions: | ||
- lastTransitionTime: "2019-10-25T06:07:29Z" | ||
lastUpdateTime: "2019-10-25T06:07:29Z" | ||
message: Rollout has minimum availability | ||
reason: AvailableReason | ||
status: "True" | ||
type: Available | ||
- lastTransitionTime: "2019-10-28T04:52:55Z" | ||
lastUpdateTime: "2019-10-28T04:52:55Z" | ||
message: ReplicaSet "canary-demo-65fb5ffc84" has timed out progressing. | ||
reason: ProgressDeadlineExceeded | ||
status: "False" | ||
type: Progressing | ||
currentPodHash: 65fb5ffc84 | ||
currentStepHash: f64cdc9d | ||
currentStepIndex: 0 | ||
observedGeneration: "429" | ||
readyReplicas: 5 | ||
replicas: 6 | ||
selector: app=canary-demo-weights-na | ||
updatedReplicas: 1 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
More as a suggestion but there is a more interesting pattern to use in tests when you want to validate 2 different scenarios like what you are doing. Instead of mixing the 2 scenarios in one single test case we can leverage
testing.Run
to run nested executions making more evident what exactly your are testing. See this example.Advantages are: