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: Implement karmada CRD health checks (argoproj#11192)
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com> Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
- Loading branch information
1 parent
f297763
commit 05f23ad
Showing
20 changed files
with
923 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
resource_customizations/work.karmada.io/ClusterResourceBinding/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,37 @@ | ||
health_status = {} | ||
if obj.status == nil then | ||
health_status.status = "Progressing" | ||
health_status.message = "Current resource status is insufficient" | ||
return health_status | ||
end | ||
|
||
if obj.spec.clusters == nil or #obj.spec.clusters == 0 then | ||
health_status.status = "Progressing" | ||
health_status.message = "Current resource status is insufficient" | ||
return health_status | ||
end | ||
|
||
if obj.status.aggregatedStatus == nil or #obj.spec.clusters ~= #obj.status.aggregatedStatus then | ||
health_status.status = "Progressing" | ||
health_status.message = "Current resource status is insufficient" | ||
return health_status | ||
end | ||
|
||
for i, status in ipairs(obj.status.aggregatedStatus) do | ||
if status.health == "Unhealthy" then | ||
health_status.status = "Degraded" | ||
health_status.message = "Current resource status is unhealthy" | ||
return health_status | ||
end | ||
|
||
if status.health == "Unknown" then | ||
if status.applied ~= true then | ||
health_status.status = "Degraded" | ||
health_status.message = "Current resource status is unhealthy" | ||
return health_status | ||
end | ||
end | ||
end | ||
|
||
health_status.status = "Healthy" | ||
return health_status |
31 changes: 31 additions & 0 deletions
31
resource_customizations/work.karmada.io/ClusterResourceBinding/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,31 @@ | ||
tests: | ||
- healthStatus: | ||
status: Progressing | ||
message: "Current resource status is insufficient" | ||
inputPath: testdata/progressing.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Current resource status is insufficient" | ||
inputPath: testdata/progressing_aggregatedStatus.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Current resource status is insufficient" | ||
inputPath: testdata/progressing_cluster.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "Current resource status is unhealthy" | ||
inputPath: testdata/degraded_unapplied.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "Current resource status is unhealthy" | ||
inputPath: testdata/degraded_unknown.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "Current resource status is unhealthy" | ||
inputPath: testdata/degraded_unhealth.yaml | ||
- healthStatus: | ||
status: Healthy | ||
inputPath: testdata/health.yaml | ||
- healthStatus: | ||
status: Healthy | ||
inputPath: testdata/health_unknown.yaml |
46 changes: 46 additions & 0 deletions
46
...ce_customizations/work.karmada.io/ClusterResourceBinding/testdata/degraded_unapplied.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,46 @@ | ||
apiVersion: work.karmada.io/v1alpha2 | ||
kind: ClusterResourceBinding | ||
metadata: | ||
finalizers: | ||
- karmada.io/binding-controller | ||
generation: 5 | ||
labels: | ||
clusterpropagationpolicy.karmada.io/name: service-testk4j5t | ||
name: test-service | ||
namespace: default | ||
ownerReferences: | ||
- apiVersion: v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: Service | ||
name: test | ||
uid: 039b0d1a-05cb-40b4-b43a-438b0de386af | ||
resourceVersion: "4106772" | ||
uid: 3932ee50-4c2b-4e77-9bfb-45eeb4ec220f | ||
spec: | ||
clusters: | ||
- name: member1 | ||
resource: | ||
apiVersion: v1 | ||
kind: Service | ||
name: service-test | ||
namespace: default | ||
resourceVersion: "3943220" | ||
uid: 9c2b39b9-4607-4795-87db-1a54680939d0 | ||
status: | ||
aggregatedStatus: | ||
- applied: false | ||
clusterName: member1 | ||
health: Unhealthy | ||
conditions: | ||
- lastTransitionTime: "2022-11-03T10:56:30Z" | ||
message: All works have been successfully applied | ||
reason: FullyAppliedSuccess | ||
status: "True" | ||
type: FullyApplied | ||
- lastTransitionTime: "2022-11-03T10:56:30Z" | ||
message: Binding has been scheduled | ||
reason: BindingScheduled | ||
status: "True" | ||
type: Scheduled | ||
schedulerObservedGeneration: 2 |
46 changes: 46 additions & 0 deletions
46
...rce_customizations/work.karmada.io/ClusterResourceBinding/testdata/degraded_unhealth.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,46 @@ | ||
apiVersion: work.karmada.io/v1alpha2 | ||
kind: ClusterResourceBinding | ||
metadata: | ||
finalizers: | ||
- karmada.io/binding-controller | ||
generation: 5 | ||
labels: | ||
clusterpropagationpolicy.karmada.io/name: service-testk4j5t | ||
name: test-service | ||
namespace: default | ||
ownerReferences: | ||
- apiVersion: v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: Service | ||
name: test | ||
uid: 039b0d1a-05cb-40b4-b43a-438b0de386af | ||
resourceVersion: "4106772" | ||
uid: 3932ee50-4c2b-4e77-9bfb-45eeb4ec220f | ||
spec: | ||
clusters: | ||
- name: member1 | ||
resource: | ||
apiVersion: v1 | ||
kind: Service | ||
name: service-test | ||
namespace: default | ||
resourceVersion: "3943220" | ||
uid: 9c2b39b9-4607-4795-87db-1a54680939d0 | ||
status: | ||
aggregatedStatus: | ||
- applied: true | ||
clusterName: member1 | ||
health: Unhealthy | ||
conditions: | ||
- lastTransitionTime: "2022-11-03T10:56:30Z" | ||
message: All works have been successfully applied | ||
reason: FullyAppliedSuccess | ||
status: "True" | ||
type: FullyApplied | ||
- lastTransitionTime: "2022-11-03T10:56:30Z" | ||
message: Binding has been scheduled | ||
reason: BindingScheduled | ||
status: "True" | ||
type: Scheduled | ||
schedulerObservedGeneration: 2 |
46 changes: 46 additions & 0 deletions
46
...urce_customizations/work.karmada.io/ClusterResourceBinding/testdata/degraded_unknown.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,46 @@ | ||
apiVersion: work.karmada.io/v1alpha2 | ||
kind: ClusterResourceBinding | ||
metadata: | ||
finalizers: | ||
- karmada.io/binding-controller | ||
generation: 5 | ||
labels: | ||
clusterpropagationpolicy.karmada.io/name: service-testk4j5t | ||
name: test-service | ||
namespace: default | ||
ownerReferences: | ||
- apiVersion: v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: Service | ||
name: test | ||
uid: 039b0d1a-05cb-40b4-b43a-438b0de386af | ||
resourceVersion: "4106772" | ||
uid: 3932ee50-4c2b-4e77-9bfb-45eeb4ec220f | ||
spec: | ||
clusters: | ||
- name: member1 | ||
resource: | ||
apiVersion: v1 | ||
kind: Service | ||
name: service-test | ||
namespace: default | ||
resourceVersion: "3943220" | ||
uid: 9c2b39b9-4607-4795-87db-1a54680939d0 | ||
status: | ||
aggregatedStatus: | ||
- applied: false | ||
clusterName: member1 | ||
health: Unknown | ||
conditions: | ||
- lastTransitionTime: "2022-11-03T10:56:30Z" | ||
message: All works have been successfully applied | ||
reason: FullyAppliedSuccess | ||
status: "True" | ||
type: FullyApplied | ||
- lastTransitionTime: "2022-11-03T10:56:30Z" | ||
message: Binding has been scheduled | ||
reason: BindingScheduled | ||
status: "True" | ||
type: Scheduled | ||
schedulerObservedGeneration: 2 |
83 changes: 83 additions & 0 deletions
83
resource_customizations/work.karmada.io/ClusterResourceBinding/testdata/health.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,83 @@ | ||
apiVersion: work.karmada.io/v1alpha2 | ||
kind: ClusterResourceBinding | ||
metadata: | ||
finalizers: | ||
- karmada.io/binding-controller | ||
generation: 5 | ||
labels: | ||
clusterpropagationpolicy.karmada.io/name: service-testk4j5t | ||
name: test-service | ||
namespace: default | ||
ownerReferences: | ||
- apiVersion: v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: Service | ||
name: test | ||
uid: 039b0d1a-05cb-40b4-b43a-438b0de386af | ||
resourceVersion: "4106772" | ||
uid: 3932ee50-4c2b-4e77-9bfb-45eeb4ec220f | ||
spec: | ||
clusters: | ||
- name: member1 | ||
- name: member2 | ||
- name: member3 | ||
replicaRequirements: | ||
nodeClaim: | ||
tolerations: | ||
- effect: NoExecute | ||
key: node.kubernetes.io/not-ready | ||
operator: Exists | ||
tolerationSeconds: 300 | ||
- effect: NoExecute | ||
key: node.kubernetes.io/unreachable | ||
operator: Exists | ||
tolerationSeconds: 300 | ||
resourceRequest: | ||
cpu: 250m | ||
memory: 512Mi | ||
replicas: 1 | ||
resource: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: test1 | ||
namespace: default | ||
resourceVersion: "3663243" | ||
uid: 58ccb955-4da6-4167-9b65-dddadcef569e | ||
status: | ||
aggregatedStatus: | ||
- applied: true | ||
clusterName: member1 | ||
health: Healthy | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
updatedReplicas: 1 | ||
- applied: true | ||
clusterName: member2 | ||
health: Healthy | ||
status: | ||
replicas: 1 | ||
unavailableReplicas: 1 | ||
updatedReplicas: 1 | ||
- applied: true | ||
clusterName: member3 | ||
health: Healthy | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
updatedReplicas: 1 | ||
conditions: | ||
- lastTransitionTime: "2022-11-02T02:49:06Z" | ||
message: All works have been successfully applied | ||
reason: FullyAppliedSuccess | ||
status: "True" | ||
type: FullyApplied | ||
- lastTransitionTime: "2022-10-28T09:56:31Z" | ||
message: Binding has been scheduled | ||
reason: BindingScheduled | ||
status: "True" | ||
type: Scheduled | ||
schedulerObservedGeneration: 7 |
46 changes: 46 additions & 0 deletions
46
resource_customizations/work.karmada.io/ClusterResourceBinding/testdata/health_unknown.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,46 @@ | ||
apiVersion: work.karmada.io/v1alpha2 | ||
kind: ClusterResourceBinding | ||
metadata: | ||
finalizers: | ||
- karmada.io/binding-controller | ||
generation: 5 | ||
labels: | ||
clusterpropagationpolicy.karmada.io/name: service-testk4j5t | ||
name: test-service | ||
namespace: default | ||
ownerReferences: | ||
- apiVersion: v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: Service | ||
name: test | ||
uid: 039b0d1a-05cb-40b4-b43a-438b0de386af | ||
resourceVersion: "4106772" | ||
uid: 3932ee50-4c2b-4e77-9bfb-45eeb4ec220f | ||
spec: | ||
clusters: | ||
- name: member1 | ||
resource: | ||
apiVersion: v1 | ||
kind: Service | ||
name: service-test | ||
namespace: default | ||
resourceVersion: "3943220" | ||
uid: 9c2b39b9-4607-4795-87db-1a54680939d0 | ||
status: | ||
aggregatedStatus: | ||
- applied: true | ||
clusterName: member1 | ||
health: Unknown | ||
conditions: | ||
- lastTransitionTime: "2022-11-03T10:56:30Z" | ||
message: All works have been successfully applied | ||
reason: FullyAppliedSuccess | ||
status: "True" | ||
type: FullyApplied | ||
- lastTransitionTime: "2022-11-03T10:56:30Z" | ||
message: Binding has been scheduled | ||
reason: BindingScheduled | ||
status: "True" | ||
type: Scheduled | ||
schedulerObservedGeneration: 2 |
41 changes: 41 additions & 0 deletions
41
resource_customizations/work.karmada.io/ClusterResourceBinding/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,41 @@ | ||
apiVersion: work.karmada.io/v1alpha2 | ||
kind: ClusterResourceBinding | ||
metadata: | ||
finalizers: | ||
- karmada.io/binding-controller | ||
generation: 5 | ||
labels: | ||
clusterpropagationpolicy.karmada.io/name: service-testk4j5t | ||
name: test-service | ||
namespace: default | ||
ownerReferences: | ||
- apiVersion: v1 | ||
blockOwnerDeletion: true | ||
controller: true | ||
kind: Service | ||
name: test | ||
uid: 039b0d1a-05cb-40b4-b43a-438b0de386af | ||
resourceVersion: "4106772" | ||
uid: 3932ee50-4c2b-4e77-9bfb-45eeb4ec220f | ||
spec: | ||
resource: | ||
apiVersion: v1 | ||
kind: Service | ||
name: test | ||
namespace: default | ||
resourceVersion: "2605059" | ||
uid: 039b0d1a-05cb-40b4-b43a-438b0de386af | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2022-10-27T07:19:50Z" | ||
message: '0/3 clusters are available: 3 cluster(s) didn''t match the placement | ||
cluster affinity constraint.' | ||
reason: BindingFailedScheduling | ||
status: "False" | ||
type: Scheduled | ||
- lastTransitionTime: "2022-10-27T07:19:52Z" | ||
message: Failed to apply all works, see status.aggregatedStatus for details | ||
reason: FullyAppliedFailed | ||
status: "False" | ||
type: FullyApplied | ||
schedulerObservedGeneration: 4 |
Oops, something went wrong.