Skip to content

Commit 57e61b2

Browse files
gcp-cherry-pick-bot[bot]itaiatudependabot[bot]
authoredAug 2, 2024
feat: Add custom health check for cluster-api AWSManagedControlPlane (#19304) (#19360)
* add custom health check for awsmanagedcontrolplane * chore(deps): bump github.com/aws/aws-sdk-go from 1.55.3 to 1.55.4 (#19295) Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.55.3 to 1.55.4. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](aws/aws-sdk-go@v1.55.3...v1.55.4) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... * add new line at the end of health_test.yaml file --------- Signed-off-by: Iulian Taiatu <itaiatu@adobe.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: itaiatu <140485521+itaiatu@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 6f2ae0d commit 57e61b2

File tree

6 files changed

+252
-0
lines changed

6 files changed

+252
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
local health_status = {
2+
status = "Progressing",
3+
message = "Provisioning..."
4+
}
5+
6+
-- If .status is nil or doesn't have conditions, then the control plane is not ready
7+
if obj.status == nil or obj.status.conditions == nil then
8+
return health_status
9+
end
10+
11+
-- Accumulator for the error messages (could be multiple conditions in error state)
12+
err_msg = ""
13+
14+
-- Iterate over the conditions to determine the health status
15+
for i, condition in ipairs(obj.status.conditions) do
16+
-- Check if the Ready condition is True, then the control plane is ready
17+
if condition.type == "Ready" and condition.status == "True" then
18+
health_status.status = "Healthy"
19+
health_status.message = "Control plane is ready"
20+
return health_status
21+
end
22+
23+
-- If we have a condition that is False and has an Error severity, then the control plane is in a degraded state
24+
if condition.status == "False" and condition.severity == "Error" then
25+
health_status.status = "Degraded"
26+
err_msg = err_msg .. condition.message .. " "
27+
end
28+
end
29+
30+
-- If we have any error conditions, then the control plane is in a degraded state
31+
if health_status.status == "Degraded" then
32+
health_status.message = err_msg
33+
return health_status
34+
end
35+
36+
-- If .status.ready is False, then the control plane is not ready
37+
if obj.status.ready == false then
38+
health_status.status = "Progressing"
39+
health_status.message = "Control plane is not ready (.status.ready is false)"
40+
return health_status
41+
end
42+
43+
-- If we reach this point, then the control plane is not ready and we don't have any error conditions
44+
health_status.status = "Progressing"
45+
health_status.message = "Control plane is not ready"
46+
47+
return health_status
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tests:
2+
- healthStatus:
3+
status: Healthy
4+
message: 'Control plane is ready'
5+
inputPath: testdata/healthy.yaml
6+
- healthStatus:
7+
status: Progressing
8+
message: 'Control plane is not ready (.status.ready is false)'
9+
inputPath: testdata/progressing_ready_false.yaml
10+
- healthStatus:
11+
status: Progressing
12+
message: 'Control plane is not ready'
13+
inputPath: testdata/progressing_ready_true.yaml
14+
- healthStatus:
15+
status: Degraded
16+
message: '7 of 10 completed failed reconciling OIDC provider for cluster: failed to create OIDC provider: error creating provider: LimitExceeded: Cannot exceed quota for OpenIdConnectProvidersPerAccount: 100 '
17+
inputPath: testdata/degraded.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
2+
kind: AWSManagedControlPlane
3+
metadata:
4+
name: test
5+
namespace: ns-test
6+
ownerReferences:
7+
- apiVersion: cluster.x-k8s.io/v1beta1
8+
blockOwnerDeletion: true
9+
controller: true
10+
kind: Cluster
11+
name: test
12+
status:
13+
conditions:
14+
- lastTransitionTime: "2024-07-30T11:10:03Z"
15+
status: "False"
16+
severity: Error
17+
message: "7 of 10 completed"
18+
type: Ready
19+
- lastTransitionTime: "2024-07-26T14:35:48Z"
20+
status: "True"
21+
type: ClusterSecurityGroupsReady
22+
- lastTransitionTime: "2024-07-30T02:20:06Z"
23+
status: "True"
24+
type: EKSAddonsConfigured
25+
- lastTransitionTime: "2024-07-26T14:43:57Z"
26+
reason: created
27+
severity: Info
28+
status: "False"
29+
type: EKSControlPlaneCreating
30+
- lastTransitionTime: "2024-07-25T09:22:46Z"
31+
message: "failed reconciling OIDC provider for cluster: failed to create OIDC provider: error creating provider: LimitExceeded: Cannot exceed quota for OpenIdConnectProvidersPerAccount: 100"
32+
reason: EKSControlPlaneReconciliationFailed
33+
severity: Error
34+
status: "False"
35+
- lastTransitionTime: "2024-07-30T11:10:03Z"
36+
status: "True"
37+
type: EKSControlPlaneReady
38+
- lastTransitionTime: "2024-07-26T15:28:01Z"
39+
status: "True"
40+
type: IAMAuthenticatorConfigured
41+
- lastTransitionTime: "2024-07-26T15:27:58Z"
42+
status: "True"
43+
type: IAMControlPlaneRolesReady
44+
- lastTransitionTime: "2024-07-26T14:35:48Z"
45+
status: "True"
46+
type: SubnetsReady
47+
- lastTransitionTime: "2024-07-26T14:35:46Z"
48+
status: "True"
49+
type: VpcReady
50+
ready: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
2+
kind: AWSManagedControlPlane
3+
metadata:
4+
name: test
5+
namespace: ns-test
6+
ownerReferences:
7+
- apiVersion: cluster.x-k8s.io/v1beta1
8+
blockOwnerDeletion: true
9+
controller: true
10+
kind: Cluster
11+
name: test
12+
status:
13+
conditions:
14+
- lastTransitionTime: "2024-07-30T11:10:03Z"
15+
status: "True"
16+
type: Ready
17+
- lastTransitionTime: "2024-07-26T14:35:48Z"
18+
status: "True"
19+
type: ClusterSecurityGroupsReady
20+
- lastTransitionTime: "2024-07-30T02:20:06Z"
21+
status: "True"
22+
type: EKSAddonsConfigured
23+
- lastTransitionTime: "2024-07-26T14:43:57Z"
24+
reason: created
25+
severity: Info
26+
status: "False"
27+
type: EKSControlPlaneCreating
28+
- lastTransitionTime: "2024-07-30T11:10:03Z"
29+
status: "True"
30+
type: EKSControlPlaneReady
31+
- lastTransitionTime: "2024-07-30T13:05:45Z"
32+
status: "True"
33+
type: EKSIdentityProviderConfigured
34+
- lastTransitionTime: "2024-07-26T15:28:01Z"
35+
status: "True"
36+
type: IAMAuthenticatorConfigured
37+
- lastTransitionTime: "2024-07-26T15:27:58Z"
38+
status: "True"
39+
type: IAMControlPlaneRolesReady
40+
- lastTransitionTime: "2024-07-26T14:35:48Z"
41+
status: "True"
42+
type: SubnetsReady
43+
- lastTransitionTime: "2024-07-26T14:35:46Z"
44+
status: "True"
45+
type: VpcReady
46+
ready: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
2+
kind: AWSManagedControlPlane
3+
metadata:
4+
name: test
5+
namespace: ns-test
6+
ownerReferences:
7+
- apiVersion: cluster.x-k8s.io/v1beta1
8+
blockOwnerDeletion: true
9+
controller: true
10+
kind: Cluster
11+
name: test
12+
status:
13+
conditions:
14+
- lastTransitionTime: "2024-07-30T11:10:03Z"
15+
status: "False"
16+
type: Ready
17+
- lastTransitionTime: "2024-07-26T14:35:48Z"
18+
status: "True"
19+
type: ClusterSecurityGroupsReady
20+
- lastTransitionTime: "2024-07-30T02:20:06Z"
21+
status: "True"
22+
type: EKSAddonsConfigured
23+
- lastTransitionTime: "2024-07-26T14:43:57Z"
24+
reason: created
25+
severity: Info
26+
status: "False"
27+
type: EKSControlPlaneCreating
28+
- lastTransitionTime: "2024-07-30T11:10:03Z"
29+
status: "True"
30+
type: EKSControlPlaneReady
31+
- lastTransitionTime: "2024-07-30T13:05:45Z"
32+
status: "True"
33+
type: EKSIdentityProviderConfigured
34+
- lastTransitionTime: "2024-07-26T15:28:01Z"
35+
status: "True"
36+
type: IAMAuthenticatorConfigured
37+
- lastTransitionTime: "2024-07-26T15:27:58Z"
38+
status: "True"
39+
type: IAMControlPlaneRolesReady
40+
- lastTransitionTime: "2024-07-26T14:35:48Z"
41+
status: "True"
42+
type: SubnetsReady
43+
- lastTransitionTime: "2024-07-26T14:35:46Z"
44+
status: "True"
45+
type: VpcReady
46+
ready: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
2+
kind: AWSManagedControlPlane
3+
metadata:
4+
name: test
5+
namespace: ns-test
6+
ownerReferences:
7+
- apiVersion: cluster.x-k8s.io/v1beta1
8+
blockOwnerDeletion: true
9+
controller: true
10+
kind: Cluster
11+
name: test
12+
status:
13+
conditions:
14+
- lastTransitionTime: "2024-07-30T11:10:03Z"
15+
status: "False"
16+
type: Ready
17+
- lastTransitionTime: "2024-07-26T14:35:48Z"
18+
status: "True"
19+
type: ClusterSecurityGroupsReady
20+
- lastTransitionTime: "2024-07-30T02:20:06Z"
21+
status: "True"
22+
type: EKSAddonsConfigured
23+
- lastTransitionTime: "2024-07-26T14:43:57Z"
24+
reason: created
25+
severity: Info
26+
status: "False"
27+
type: EKSControlPlaneCreating
28+
- lastTransitionTime: "2024-07-30T11:10:03Z"
29+
status: "True"
30+
type: EKSControlPlaneReady
31+
- lastTransitionTime: "2024-07-30T13:05:45Z"
32+
status: "True"
33+
type: EKSIdentityProviderConfigured
34+
- lastTransitionTime: "2024-07-26T15:28:01Z"
35+
status: "True"
36+
type: IAMAuthenticatorConfigured
37+
- lastTransitionTime: "2024-07-26T15:27:58Z"
38+
status: "True"
39+
type: IAMControlPlaneRolesReady
40+
- lastTransitionTime: "2024-07-26T14:35:48Z"
41+
status: "True"
42+
type: SubnetsReady
43+
- lastTransitionTime: "2024-07-26T14:35:46Z"
44+
status: "True"
45+
type: VpcReady
46+
ready: true

0 commit comments

Comments
 (0)