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

Account for missing fields in Rollout HealthStatus #1699

Merged
merged 1 commit into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions resource_customizations/argoproj.io/Rollout/health.lua
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
function checkReplicasStatus(obj)
hs = {}
if obj.spec.replicas ~= nil and obj.status.updatedReplicas < obj.spec.replicas then
replicasCount = getNumberValueOrDefault(obj.spec.replicas)
replicasStatus = getNumberValueOrDefault(obj.status.replicas)
updatedReplicas = getNumberValueOrDefault(obj.status.updatedReplicas)
availableReplicas = getNumberValueOrDefault(obj.status.availableReplicas)

if updatedReplicas < replicasCount then
hs.status = "Progressing"
hs.message = "Waiting for roll out to finish: More replicas need to be updated"
return hs
end
if obj.status.replicas > obj.status.updatedReplicas then
if replicasStatus > updatedReplicas then
hs.status = "Progressing"
hs.message = "Waiting for roll out to finish: old replicas are pending termination"
return hs
end
if obj.status.availableReplicas < obj.status.updatedReplicas then
if availableReplicas < updatedReplicas then
hs.status = "Progressing"
hs.message = "Waiting for roll out to finish: updated replicas are still becoming available"
return hs
end
if obj.spec.replicas ~= nil and obj.status.updatedReplicas < obj.spec.replicas then
if updatedReplicas < replicasCount then
hs.status = "Progressing"
hs.message = "Waiting for roll out to finish: More replicas need to be updated"
return hs
end
if obj.status.replicas > obj.status.updatedReplicas then
if replicasStatus > updatedReplicas then
hs.status = "Progressing"
hs.message = "Waiting for roll out to finish: old replicas are pending termination"
return hs
end
if obj.status.availableReplicas < obj.status.updatedReplicas then
if availableReplicas < updatedReplicas then
hs.status = "Progressing"
hs.message = "Waiting for roll out to finish: updated replicas are still becoming available"
return hs
end
return nil
end

function getNumberValueOrDefault(field)
if field ~= nil then
return field
end
return 0
end

function checkPaused(obj)
hs = {}
local paused = false
Expand Down Expand Up @@ -76,7 +88,7 @@ if obj.status ~= nil then
if replicasHS ~= nil then
return replicasHS
end
if obj.status.blueGreen.activeSelector ~= nil and obj.status.blueGreen.activeSelector == obj.status.currentPodHash then
if obj.status.blueGreen ~= nil and obj.status.blueGreen.activeSelector ~= nil and obj.status.currentPodHash ~= nil and obj.status.blueGreen.activeSelector == obj.status.currentPodHash then
hs.status = "Healthy"
hs.message = "The active Service is serving traffic to the current pod spec"
return hs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
tests:
- healthStatus:
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I an idiot - is this the test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this is the test. We have that documented here: https://argoproj.github.io/argo-cd/operator-manual/health/#way-2-contribute-a-custom-health-check but I can see how that can be confusing. Honestly, I think we may want to rethink this testing framework. The current tests are valuable but I found it difficult to maintain.

Copy link
Contributor

Choose a reason for hiding this comment

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

cool - you still need to sync with master

status: Progressing
message: "Waiting for roll out to finish: More replicas need to be updated"
inputPath: testdata/newRolloutWithoutStatus.yaml
- healthStatus:
status: Degraded
message: Rollout has missing field '.Spec.Strategy.Type'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"argoproj.io/v1alpha1","kind":"Rollout","metadata":{"annotations":{},"labels":{"app":"helm-guestbook","app.kubernetes.io/instance":"bluegreen","chart":"helm-guestbook-0.1.0","heritage":"Tiller","release":"bluegreen"},"name":"bluegreen-helm-guestbook","namespace":"default"},"spec":{"replicas":1,"revisionHistoryLimit":3,"selector":{"matchLabels":{"app":"helm-guestbook","release":"bluegreen"}},"strategy":{"blueGreen":{"activeService":"bluegreen-helm-guestbook","previewService":"bluegreen-helm-guestbook-preview"}},"template":{"metadata":{"labels":{"app":"helm-guestbook","release":"bluegreen"}},"spec":{"containers":[{"image":"gcr.io/heptio-images/ks-guestbook-demo:0.1","imagePullPolicy":"IfNotPresent","livenessProbe":{"httpGet":{"path":"/","port":"http"}},"name":"helm-guestbook","ports":[{"containerPort":80,"name":"http","protocol":"TCP"}],"readinessProbe":{"httpGet":{"path":"/","port":"http"}},"resources":{}}]}}}}
rollout.argoproj.io/revision: "1"
creationTimestamp: 2019-06-05T21:26:38Z
generation: 1
labels:
app: helm-guestbook
app.kubernetes.io/instance: bluegreen
chart: helm-guestbook-0.1.0
heritage: Tiller
release: bluegreen
name: bluegreen-helm-guestbook
namespace: default
resourceVersion: "150297"
selfLink: /apis/argoproj.io/v1alpha1/namespaces/default/rollouts/bluegreen-helm-guestbook
uid: 9a560c89-87d8-11e9-a97d-080027da2583
spec:
replicas: 1
revisionHistoryLimit: 3
selector:
matchLabels:
app: helm-guestbook
release: bluegreen
strategy:
blueGreen:
activeService: bluegreen-helm-guestbook
previewService: bluegreen-helm-guestbook-preview
template:
metadata:
creationTimestamp: null
labels:
app: helm-guestbook
release: bluegreen
spec:
containers:
- image: gcr.io/heptio-images/ks-guestbook-demo:0.1
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /
port: http
name: helm-guestbook
ports:
- containerPort: 80
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /
port: http
resources: {}
status:
blueGreen: {}
canary: {}
conditions:
- lastTransitionTime: 2019-06-05T21:26:38Z
lastUpdateTime: 2019-06-05T21:26:38Z
message: Created new replica set "bluegreen-helm-guestbook-7c4599cc5b"
reason: NewReplicaSetCreated
status: "True"
type: Progressing
- lastTransitionTime: 2019-06-05T21:26:38Z
lastUpdateTime: 2019-06-05T21:26:38Z
message: Rollout does not have minimum availability
reason: AvailableReason
status: "False"
type: Available
currentPodHash: 7c4599cc5b
observedGeneration: 78597c98fd
selector: app=helm-guestbook,release=bluegreen