Skip to content

Commit

Permalink
Add V0.8 changes to Rollouts healthcheck (#3331)
Browse files Browse the repository at this point in the history
  • Loading branch information
dthomson25 authored and alexmt committed Apr 2, 2020
1 parent a12b7bd commit 2faa5c8
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 3 deletions.
13 changes: 12 additions & 1 deletion resource_customizations/argoproj.io/Rollout/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ function checkReplicasStatus(obj)
return nil
end

-- In Argo Rollouts v0.8 we depreciate .status.canary.stableRS for .status.stableRS this func grabs the correct one
function getStableRS(obj)
if obj.status.stableRS ~= nil then
return obj.status.stableRS
end
if obj.status.canary ~= nil then
return obj.status.canary.stableRS
end
return ""
end

function getNumberValueOrDefault(field)
if field ~= nil then
return field
Expand Down Expand Up @@ -87,7 +98,7 @@ if obj.status ~= nil then
return hs
end
if obj.spec.strategy.canary ~= nil then
currentRSIsStable = obj.status.canary.stableRS == obj.status.currentPodHash
currentRSIsStable = getStableRS(obj) == obj.status.currentPodHash
if obj.spec.strategy.canary.steps ~= nil and table.getn(obj.spec.strategy.canary.steps) > 0 then
stepCount = table.getn(obj.spec.strategy.canary.steps)
if obj.status.currentStepIndex ~= nil then
Expand Down
4 changes: 4 additions & 0 deletions resource_customizations/argoproj.io/Rollout/health_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ tests:
- healthStatus:
status: Healthy
message: The rollout has completed all steps
inputPath: testdata/canary/healthy_executedAllStepsPreV0.8.yaml
- healthStatus:
status: Healthy
message: The rollout has completed all steps
inputPath: testdata/canary/healthy_executedAllSteps.yaml
- healthStatus:
status: Progressing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ status:
HPAReplicas: 5
availableReplicas: 5
blueGreen: {}
canary:
stableRS: 84ccfddd66
canary: {}
conditions:
- lastTransitionTime: '2019-05-01T21:55:30Z'
lastUpdateTime: '2019-05-01T21:55:58Z'
Expand All @@ -70,4 +69,5 @@ status:
readyReplicas: 5
replicas: 5
selector: app=guestbook-canary
stableRS: 84ccfddd66
updatedReplicas: 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: >
{"apiVersion":"argoproj.io/v1alpha1","kind":"Rollout","metadata":{"annotations":{},"labels":{"app.kubernetes.io/instance":"guestbook-canary","ksonnet.io/component":"guestbook-ui"},"name":"guestbook-canary","namespace":"default"},"spec":{"minReadySeconds":10,"replicas":5,"selector":{"matchLabels":{"app":"guestbook-canary"}},"strategy":{"canary":{"maxSurge":1,"maxUnavailable":0,"steps":[{"setWeight":20},{"pause":{"duration":30}},{"setWeight":40},{"pause":{}}]}},"template":{"metadata":{"labels":{"app":"guestbook-canary"}},"spec":{"containers":[{"image":"gcr.io/heptio-images/ks-guestbook-demo:0.1","name":"guestbook-canary","ports":[{"containerPort":80}]}]}}}}
rollout.argoproj.io/revision: '1'
clusterName: ''
creationTimestamp: '2019-05-01T21:55:30Z'
generation: 1
labels:
app.kubernetes.io/instance: guestbook-canary
ksonnet.io/component: guestbook-ui
name: guestbook-canary
namespace: default
resourceVersion: '955764'
selfLink: /apis/argoproj.io/v1alpha1/namespaces/default/rollouts/guestbook-canary
uid: d6105ccd-6c5b-11e9-b8d7-025000000001
spec:
minReadySeconds: 10
replicas: 5
selector:
matchLabels:
app: guestbook-canary
strategy:
canary:
maxSurge: 1
maxUnavailable: 0
steps:
- setWeight: 20
- pause:
duration: 30
- setWeight: 40
- pause: {}
template:
metadata:
creationTimestamp: null
labels:
app: guestbook-canary
spec:
containers:
- image: 'gcr.io/heptio-images/ks-guestbook-demo:0.1'
name: guestbook-canary
ports:
- containerPort: 80
resources: {}
status:
HPAReplicas: 5
availableReplicas: 5
blueGreen: {}
canary:
stableRS: 84ccfddd66
conditions:
- lastTransitionTime: '2019-05-01T21:55:30Z'
lastUpdateTime: '2019-05-01T21:55:58Z'
message: ReplicaSet "guestbook-canary-84ccfddd66" has successfully progressed.
reason: NewReplicaSetAvailable
status: 'True'
type: Progressing
- lastTransitionTime: '2019-05-01T21:55:58Z'
lastUpdateTime: '2019-05-01T21:55:58Z'
message: Rollout has minimum availability
reason: AvailableReason
status: 'True'
type: Available
currentPodHash: 84ccfddd66
currentStepHash: 5f8fbdf7bb
currentStepIndex: 4
observedGeneration: c45557fd9
readyReplicas: 5
replicas: 5
selector: app=guestbook-canary
updatedReplicas: 5

0 comments on commit 2faa5c8

Please sign in to comment.