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.
feat: support Knative Serving 1.5 Custom Health Checks (argoproj#9719)
* fix: Update account.proto annotaion for gen grpc gateway Signed-off-by: wei840222 <wei840222@gmail.com> * fix: Changes from codegen Signed-off-by: wei840222 <wei840222@gmail.com> * Retrigger CI pipeline Signed-off-by: wei.wan <wei.wan@linecorp.com> * Retrigger CI pipeline Signed-off-by: wei.wan <wei.wan@linecorp.com> * fix: Changes from codegen Signed-off-by: wei <wei840222@gmail.com> * Retrigger CI pipeline Signed-off-by: wei.wan <wei.wan@linecorp.com> * Retrigger CI pipeline Signed-off-by: wei <wei840222@gmail.com> * feat: support Knative Serving 1.5 Custom Health Checks Signed-off-by: wei.wan <wei.wan@linecorp.com> * fix: fix test fail Signed-off-by: wei.wan <wei.wan@linecorp.com> * feat: support Knative Serving 1.5 Custom Health Checks Signed-off-by: wei840222 <wei840222@gmail.com> Signed-off-by: wei840222 <wei840222@gmail.com> Signed-off-by: wei.wan <wei.wan@linecorp.com> Signed-off-by: wei <wei840222@gmail.com> Co-authored-by: wei.wan <wei.wan@linecorp.com> Signed-off-by: emirot <emirot.nolan@gmail.com>
- Loading branch information
Showing
5 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
resource_customizations/serving.knative.dev/Service/health.lua
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,40 @@ | ||
health_status = {} | ||
health_status.status = "Progressing" | ||
health_status.message = "Waiting for status update." | ||
if obj.status ~= nil and obj.status.conditions ~= nil then | ||
status_true = 0 | ||
status_false = 0 | ||
status_unknown = 0 | ||
health_status.message = "" | ||
for i, condition in pairs(obj.status.conditions) do | ||
if condition.status == "True" and (condition.type == "ConfigurationsReady" or condition.type == "RoutesReady" or condition.type == "Ready") then | ||
status_true = status_true + 1 | ||
elseif condition.status == "False" or condition.status == "Unknown" then | ||
msg = condition.type .. " is " .. condition.status | ||
if condition.reason ~= nil and condition.reason ~= "" then | ||
msg = msg .. ", since " .. condition.reason .. "." | ||
end | ||
if condition.message ~= nil and condition.message ~= "" then | ||
msg = msg .. " " .. condition.message | ||
end | ||
health_status.message = health_status.message .. msg .. "\n" | ||
if condition.status == "False" then | ||
status_false = status_false + 1 | ||
else | ||
status_unknown = status_unknown + 1 | ||
end | ||
end | ||
end | ||
if status_true == 3 and status_false == 0 and status_unknown == 0 then | ||
health_status.message = "Knative Service is healthy." | ||
health_status.status = "Healthy" | ||
return health_status | ||
elseif status_false > 0 then | ||
health_status.status = "Degraded" | ||
return health_status | ||
else | ||
health_status.status = "Progressing" | ||
return health_status | ||
end | ||
end | ||
return health_status |
13 changes: 13 additions & 0 deletions
13
resource_customizations/serving.knative.dev/Service/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,13 @@ | ||
tests: | ||
- healthStatus: | ||
status: Progressing | ||
message: "Ready is Unknown, since RolloutInProgress. A gradual rollout of the latest revision(s) is in progress.\nRoutesReady is Unknown, since RolloutInProgress. A gradual rollout of the latest revision(s) is in progress.\n" | ||
inputPath: testdata/progressing.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "ConfigurationsReady is False, since RevisionFailed. Revision \"helloworld-00002\" failed with message: Container failed with: container exited with no error.\nReady is False, since RevisionFailed. Revision \"helloworld-00002\" failed with message: Container failed with: container exited with no error.\n" | ||
inputPath: testdata/degraded.yaml | ||
- healthStatus: | ||
status: Healthy | ||
message: Knative Service is healthy. | ||
inputPath: testdata/healthy.yaml |
21 changes: 21 additions & 0 deletions
21
resource_customizations/serving.knative.dev/Service/testdata/degraded.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,21 @@ | ||
apiVersion: serving.knative.dev/v1 | ||
kind: Service | ||
metadata: | ||
name: helloworld | ||
namespace: default | ||
spec: {} | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2022-06-14T03:45:38Z" | ||
message: 'Revision "helloworld-00002" failed with message: Container failed with: container exited with no error.' | ||
reason: RevisionFailed | ||
status: "False" | ||
type: ConfigurationsReady | ||
- lastTransitionTime: "2022-06-14T03:45:38Z" | ||
message: 'Revision "helloworld-00002" failed with message: Container failed with: container exited with no error.' | ||
reason: RevisionFailed | ||
status: "False" | ||
type: Ready | ||
- lastTransitionTime: "2022-06-16T09:35:11Z" | ||
status: "True" | ||
type: RoutesReady |
17 changes: 17 additions & 0 deletions
17
resource_customizations/serving.knative.dev/Service/testdata/healthy.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,17 @@ | ||
apiVersion: serving.knative.dev/v1 | ||
kind: Service | ||
metadata: | ||
name: helloworld | ||
namespace: default | ||
spec: {} | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2022-06-20T03:52:41Z" | ||
status: "True" | ||
type: ConfigurationsReady | ||
- lastTransitionTime: "2022-06-20T03:52:41Z" | ||
status: "True" | ||
type: Ready | ||
- lastTransitionTime: "2022-06-20T03:52:41Z" | ||
status: "True" | ||
type: RoutesReady |
21 changes: 21 additions & 0 deletions
21
resource_customizations/serving.knative.dev/Service/testdata/progressing.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,21 @@ | ||
apiVersion: serving.knative.dev/v1 | ||
kind: Service | ||
metadata: | ||
name: helloworld | ||
namespace: default | ||
spec: {} | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2022-06-20T04:14:22Z" | ||
status: "True" | ||
type: ConfigurationsReady | ||
- lastTransitionTime: "2022-06-20T04:14:22Z" | ||
message: A gradual rollout of the latest revision(s) is in progress. | ||
reason: RolloutInProgress | ||
status: Unknown | ||
type: Ready | ||
- lastTransitionTime: "2022-06-20T04:14:22Z" | ||
message: A gradual rollout of the latest revision(s) is in progress. | ||
reason: RolloutInProgress | ||
status: Unknown | ||
type: RoutesReady |