Skip to content

Commit

Permalink
fix: rollout health could incorrectly report v0.9 rollouts as Progres…
Browse files Browse the repository at this point in the history
…sing (#4949)

Signed-off-by: Jesse Suen <Jesse_Suen@intuit.com>
  • Loading branch information
jessesuen authored and alexmt committed Dec 2, 2020
1 parent 0f0b6ce commit f479639
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ actions["retry"] = {["disabled"] = fullyPromoted or not(obj.status.abort)}
actions["promote-full"] = {["disabled"] = true}
if obj.status ~= nil and not(fullyPromoted) then
generation = tonumber(obj.status.observedGeneration)
if generation == nil then
if generation == nil or generation > obj.metadata.generation then
-- rollouts v0.9 - full promotion only supported for canary
actions["promote-full"] = {["disabled"] = obj.spec.strategy.blueGreen ~= nil}
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if obj.status ~= nil then
generation = tonumber(obj.status.observedGeneration)
if generation == nil then
if generation == nil or generation > obj.metadata.generation then
-- rollouts v0.9 and below
obj.status.abort = nil
if obj.spec.strategy.canary.steps ~= nil then
Expand Down
22 changes: 15 additions & 7 deletions resource_customizations/argoproj.io/Rollout/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,23 @@ function checkPaused(obj)
return nil
end

hs = {}
if obj.status == nil or obj.status.observedGeneration == nil then
hs.status = "Progressing"
hs.message = "Waiting for rollout spec update to be observed"
return hs
-- isGenerationObserved determines if the rollout spec has been observed by the controller. This
-- only applies to v0.10 rollout which uses a numeric status.observedGeneration. For v0.9 rollouts
-- and below this function always returns true.
function isGenerationObserved(obj)
if obj.status == nil then
return false
end
observedGeneration = tonumber(obj.status.observedGeneration)
if observedGeneration == nil or observedGeneration > obj.metadata.generation then
-- if we get here, the rollout is a v0.9 rollout
return true
end
return observedGeneration == obj.metadata.generation
end

generation = tonumber(obj.status.observedGeneration)
if generation ~= nil and generation ~= obj.metadata.generation then
hs = {}
if not isGenerationObserved(obj) then
hs.status = "Progressing"
hs.message = "Waiting for rollout spec update to be observed"
return hs
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 @@ -11,6 +11,10 @@ tests:
status: Healthy
message: ""
inputPath: testdata/healthy_legacy_v0.9_observedGeneration.yaml
- healthStatus:
status: Healthy
message: ""
inputPath: testdata/healthy_legacy_v0.9_observedGeneration_numeric.yaml
- healthStatus:
status: Degraded
message: "The Rollout \"basic\" is invalid: spec.strategy.strategy: Required value: Rollout has missing field '.spec.strategy.canary or .spec.strategy.blueGreen'"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
creationTimestamp: "2020-11-13T00:44:55Z"
generation: 1
name: basic
namespace: argocd-e2e
resourceVersion: "182108"
selfLink: /apis/argoproj.io/v1alpha1/namespaces/argocd-e2e/rollouts/basic
uid: 34e4bbfc-222c-4968-bd60-2b30ae81110d
spec:
replicas: 1
selector:
matchLabels:
app: basic
strategy:
canary:
steps:
- setWeight: 50
- pause: {}
template:
metadata:
creationTimestamp: null
labels:
app: basic
spec:
containers:
- image: nginx:1.19-alpine
name: basic
resources:
requests:
cpu: 1m
memory: 16Mi
status:
HPAReplicas: 1
availableReplicas: 1
blueGreen: {}
canary: {}
conditions:
- lastTransitionTime: "2020-11-13T00:48:20Z"
lastUpdateTime: "2020-11-13T00:48:22Z"
message: ReplicaSet "basic-754cb84d5" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
- lastTransitionTime: "2020-11-13T00:48:22Z"
lastUpdateTime: "2020-11-13T00:48:22Z"
message: Rollout has minimum availability
reason: AvailableReason
status: "True"
type: Available
currentPodHash: 754cb84d5
currentStepHash: 757f5f97b
currentStepIndex: 2
observedGeneration: "8575574967" ## <---- uses legacy observedGeneration hash which are numbers
readyReplicas: 1
replicas: 1
selector: app=basic
stableRS: 754cb84d5
updatedReplicas: 1

0 comments on commit f479639

Please sign in to comment.