Skip to content

Commit

Permalink
feat: Implement karmada CRD health checks (argoproj#11192)
Browse files Browse the repository at this point in the history
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
  • Loading branch information
chaunceyjiang authored and ashutosh16 committed Nov 23, 2022
1 parent f297763 commit 05f23ad
Show file tree
Hide file tree
Showing 20 changed files with 923 additions and 0 deletions.
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
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
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
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
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
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
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
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
Loading

0 comments on commit 05f23ad

Please sign in to comment.