forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom resource health through lua
- Loading branch information
1 parent
cefa9d9
commit 00421bb
Showing
18 changed files
with
833 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,51 @@ | ||
hs = {} | ||
if obj.status ~= nil then | ||
if obj.status.conditions ~= nil then | ||
for i, condition in ipairs(obj.status.conditions) do | ||
if condition.type == "InvalidSpec" then | ||
hs.status = "Degraded" | ||
hs.message = condition.message | ||
return hs | ||
end | ||
end | ||
end | ||
if obj.status.currentPodHash ~= nil then | ||
if obj.spec.replicas ~= nil and obj.status.updatedReplicas < obj.spec.replicas then | ||
hs.status = "Progressing" | ||
hs.message = "Waiting for roll out to finish: More replicas need to be updated" | ||
return hs | ||
end | ||
local verifyingPreview = false | ||
if obj.status.verifyingPreview ~= nil then | ||
verifyingPreview = obj.status.verifyingPreview | ||
end | ||
if verifyingPreview and obj.status.previewSelector ~= nil and obj.status.previewSelector == obj.status.currentPodHash then | ||
hs.status = "Healthy" | ||
hs.message = "The preview Service is serving traffic to the current pod spec" | ||
return hs | ||
end | ||
|
||
if obj.status.replicas > obj.status.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 | ||
hs.status = "Progressing" | ||
hs.message = "Waiting for roll out to finish: updated replicas are still becoming available" | ||
return hs | ||
end | ||
|
||
if obj.status.activeSelector ~= nil and obj.status.activeSelector == obj.status.currentPodHash then | ||
hs.status = "Healthy" | ||
hs.message = "The active Service is serving traffic to the current pod spec" | ||
return hs | ||
end | ||
hs.status = "Progressing" | ||
hs.message = "The current pod spec is not receiving traffic from the active service" | ||
return hs | ||
end | ||
end | ||
hs.status = "Unknown" | ||
hs.message = "Rollout should not reach here. Please file a bug at https://github.com/argoproj/argo-cd/issues/new" | ||
return hs |
25 changes: 25 additions & 0 deletions
25
resource_customizations/argoproj.io/Rollout/health_test.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,25 @@ | ||
tests: | ||
- healthStatus: | ||
status: Healthy | ||
message: The active Service is serving traffic to the current pod spec | ||
inputPath: testdata/healthy_servingActiveService.yaml | ||
- healthStatus: | ||
status: Healthy | ||
message: The preview Service is serving traffic to the current pod spec | ||
inputPath: testdata/healthy_servingPreviewService.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Waiting for roll out to finish: More replicas need to be updated" | ||
inputPath: testdata/progressing_addingMoreReplicas.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Waiting for roll out to finish: old replicas are pending termination" | ||
inputPath: testdata/progressing_killingOldReplicas.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Waiting for roll out to finish: updated replicas are still becoming available" | ||
inputPath: testdata/progressing_waitingUntilAvailable.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: Rollout has missing field '.Spec.Strategy.Type' | ||
inputPath: testdata/degraded_invalidSpec.yaml |
12 changes: 12 additions & 0 deletions
12
resource_customizations/argoproj.io/Rollout/testdata/degraded_invalidSpec.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,12 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Rollout | ||
metadata: | ||
name: invalidSpec | ||
status: | ||
conditions: | ||
- type: AnotherValidCondition | ||
status: true | ||
- type: InvalidSpec | ||
status: true | ||
message: Rollout has missing field '.Spec.Strategy.Type' | ||
reason: MissingStrategy |
57 changes: 57 additions & 0 deletions
57
resource_customizations/argoproj.io/Rollout/testdata/healthy_servingActiveService.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,57 @@ | ||
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-default","ksonnet.io/component":"guestbook-ui"},"name":"ks-guestbook-ui","namespace":"default"},"spec":{"minReadySeconds":30,"replicas":1,"selector":{"matchLabels":{"app":"ks-guestbook-ui"}},"strategy":{"blueGreen":{"activeService":"ks-guestbook-ui-active","previewService":"ks-guestbook-ui-preview"},"type":"BlueGreenUpdate"},"template":{"metadata":{"labels":{"app":"ks-guestbook-ui"}},"spec":{"containers":[{"image":"gcr.io/heptio-images/ks-guestbook-demo:0.2","name":"ks-guestbook-ui","ports":[{"containerPort":80}]}]}}}} | ||
rollout.argoproj.io/revision: "1" | ||
clusterName: "" | ||
creationTimestamp: 2019-01-22T16:52:54Z | ||
generation: 1 | ||
labels: | ||
app.kubernetes.io/instance: guestbook-default | ||
ksonnet.io/component: guestbook-ui | ||
name: ks-guestbook-ui | ||
namespace: default | ||
resourceVersion: "153353" | ||
selfLink: /apis/argoproj.io/v1alpha1/namespaces/default/rollouts/ks-guestbook-ui | ||
uid: 29802403-1e66-11e9-a6a4-025000000001 | ||
spec: | ||
minReadySeconds: 30 | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: ks-guestbook-ui | ||
strategy: | ||
blueGreen: | ||
activeService: ks-guestbook-ui-active | ||
previewService: ks-guestbook-ui-preview | ||
type: BlueGreenUpdate | ||
template: | ||
metadata: | ||
creationTimestamp: null | ||
labels: | ||
app: ks-guestbook-ui | ||
spec: | ||
containers: | ||
- image: gcr.io/heptio-images/ks-guestbook-demo:0.2 | ||
name: ks-guestbook-ui | ||
ports: | ||
- containerPort: 80 | ||
resources: {} | ||
status: | ||
activeSelector: dc689d967 | ||
availableReplicas: 1 | ||
conditions: | ||
- lastTransitionTime: 2019-01-24T09:51:02Z | ||
lastUpdateTime: 2019-01-24T09:51:02Z | ||
message: Rollout is serving traffic from the active service. | ||
reason: Available | ||
status: "True" | ||
type: Available | ||
currentPodHash: dc689d967 | ||
observedGeneration: 77646c9d4c | ||
previewSelector: "" | ||
readyReplicas: 1 | ||
replicas: 1 | ||
updatedReplicas: 1 |
55 changes: 55 additions & 0 deletions
55
resource_customizations/argoproj.io/Rollout/testdata/healthy_servingPreviewService.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,55 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Rollout | ||
metadata: | ||
annotations: | ||
rollout.argoproj.io/revision: "7" | ||
clusterName: "" | ||
creationTimestamp: 2019-01-22T16:52:54Z | ||
generation: 1 | ||
labels: | ||
app.kubernetes.io/instance: guestbook-default | ||
name: ks-guestbook-ui | ||
namespace: default | ||
resourceVersion: "164113" | ||
selfLink: /apis/argoproj.io/v1alpha1/namespaces/default/rollouts/ks-guestbook-ui | ||
uid: 29802403-1e66-11e9-a6a4-025000000001 | ||
spec: | ||
minReadySeconds: 30 | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: ks-guestbook-ui | ||
strategy: | ||
blueGreen: | ||
activeService: ks-guestbook-ui-active | ||
previewService: ks-guestbook-ui-preview | ||
type: BlueGreenUpdate | ||
template: | ||
metadata: | ||
creationTimestamp: null | ||
labels: | ||
app: ks-guestbook-ui | ||
spec: | ||
containers: | ||
- image: gcr.io/heptio-images/ks-guestbook-demo:0.1 | ||
name: ks-guestbook-ui | ||
ports: | ||
- containerPort: 83 | ||
resources: {} | ||
status: | ||
activeSelector: 85f9884f5d | ||
availableReplicas: 6 | ||
conditions: | ||
- lastTransitionTime: 2019-01-25T07:44:26Z | ||
lastUpdateTime: 2019-01-25T07:44:26Z | ||
message: Rollout is serving traffic from the active service. | ||
reason: Available | ||
status: "True" | ||
type: Available | ||
currentPodHash: 697fb9575c | ||
observedGeneration: 767f98959f | ||
previewSelector: 697fb9575c | ||
readyReplicas: 6 | ||
replicas: 6 | ||
updatedReplicas: 3 | ||
verifyingPreview: true |
54 changes: 54 additions & 0 deletions
54
resource_customizations/argoproj.io/Rollout/testdata/progressing_addingMoreReplicas.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,54 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Rollout | ||
metadata: | ||
annotations: | ||
rollout.argoproj.io/revision: "7" | ||
clusterName: "" | ||
creationTimestamp: 2019-01-22T16:52:54Z | ||
generation: 1 | ||
labels: | ||
app.kubernetes.io/instance: guestbook-default | ||
name: ks-guestbook-ui | ||
namespace: default | ||
resourceVersion: "164023" | ||
selfLink: /apis/argoproj.io/v1alpha1/namespaces/default/rollouts/ks-guestbook-ui | ||
uid: 29802403-1e66-11e9-a6a4-025000000001 | ||
spec: | ||
minReadySeconds: 30 | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: ks-guestbook-ui | ||
strategy: | ||
blueGreen: | ||
activeService: ks-guestbook-ui-active | ||
previewService: ks-guestbook-ui-preview | ||
type: BlueGreenUpdate | ||
template: | ||
metadata: | ||
creationTimestamp: null | ||
labels: | ||
app: ks-guestbook-ui | ||
spec: | ||
containers: | ||
- image: gcr.io/heptio-images/ks-guestbook-demo:0.1 | ||
name: ks-guestbook-ui | ||
ports: | ||
- containerPort: 83 | ||
resources: {} | ||
status: | ||
activeSelector: 85f9884f5d | ||
availableReplicas: 3 | ||
conditions: | ||
- lastTransitionTime: 2019-01-25T07:44:26Z | ||
lastUpdateTime: 2019-01-25T07:44:26Z | ||
message: Rollout is serving traffic from the active service. | ||
reason: Available | ||
status: "True" | ||
type: Available | ||
currentPodHash: 697fb9575c | ||
observedGeneration: 767f98959f | ||
previewSelector: "" | ||
readyReplicas: 3 | ||
replicas: 3 | ||
updatedReplicas: 0 |
Oops, something went wrong.