-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added health checks for Config Connector resources. (#9878)
Signed-off-by: Patrick Kerwood <patrick@kerwood.dk>
- Loading branch information
Showing
53 changed files
with
688 additions
and
432 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
resource_customizations/iam.cnrm.cloud.google.com/IAMPartialPolicy/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,39 @@ | ||
hs = { | ||
status = "Progressing", | ||
message = "Update in progress" | ||
} | ||
if obj.status ~= nil then | ||
if obj.status.conditions ~= nil then | ||
for i, condition in ipairs(obj.status.conditions) do | ||
|
||
-- Up To Date | ||
if condition.reason == "UpToDate" and condition.status == "True" then | ||
hs.status = "Healthy" | ||
hs.message = condition.message | ||
return hs | ||
end | ||
|
||
-- Update Failed | ||
if condition.reason == "UpdateFailed" then | ||
hs.status = "Degraded" | ||
hs.message = condition.message | ||
return hs | ||
end | ||
|
||
-- Dependency Not Found | ||
if condition.reason == "DependencyNotFound" then | ||
hs.status = "Degraded" | ||
hs.message = condition.message | ||
return hs | ||
end | ||
|
||
-- Dependency Not Ready | ||
if condition.reason == "DependencyNotReady" then | ||
hs.status = "Suspended" | ||
hs.message = condition.message | ||
return hs | ||
end | ||
end | ||
end | ||
end | ||
return hs |
21 changes: 21 additions & 0 deletions
21
resource_customizations/iam.cnrm.cloud.google.com/IAMPartialPolicy/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,21 @@ | ||
tests: | ||
- healthStatus: | ||
status: Degraded | ||
message: "Dependency not found" | ||
inputPath: testdata/dependency_not_found.yaml | ||
- healthStatus: | ||
status: Suspended | ||
message: "Dependency not ready" | ||
inputPath: testdata/dependency_not_ready.yaml | ||
- healthStatus: | ||
status: Healthy | ||
message: "The resource is up to date" | ||
inputPath: testdata/up_to_date.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "Update failed" | ||
inputPath: testdata/update_failed.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Update in progress" | ||
inputPath: testdata/update_in_progress.yaml |
9 changes: 9 additions & 0 deletions
9
...tomizations/iam.cnrm.cloud.google.com/IAMPartialPolicy/testdata/dependency_not_found.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,9 @@ | ||
apiVersion: iam.cnrm.cloud.google.com/v1beta1 | ||
kind: IAMPartialPolicy | ||
status: | ||
conditions: | ||
- lastTransitionTime: '2022-07-01T12:56:21Z' | ||
message: Dependency not found | ||
reason: DependencyNotFound | ||
status: 'False' | ||
type: Ready |
9 changes: 9 additions & 0 deletions
9
...tomizations/iam.cnrm.cloud.google.com/IAMPartialPolicy/testdata/dependency_not_ready.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,9 @@ | ||
apiVersion: iam.cnrm.cloud.google.com/v1beta1 | ||
kind: IAMPartialPolicy | ||
status: | ||
conditions: | ||
- lastTransitionTime: '2022-07-01T12:56:21Z' | ||
message: Dependency not ready | ||
reason: DependencyNotReady | ||
status: 'False' | ||
type: Ready |
9 changes: 9 additions & 0 deletions
9
resource_customizations/iam.cnrm.cloud.google.com/IAMPartialPolicy/testdata/up_to_date.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,9 @@ | ||
apiVersion: iam.cnrm.cloud.google.com/v1beta1 | ||
kind: IAMPartialPolicy | ||
status: | ||
conditions: | ||
- lastTransitionTime: '2022-05-09T08:49:18Z' | ||
message: The resource is up to date | ||
reason: UpToDate | ||
status: 'True' | ||
type: Ready |
9 changes: 9 additions & 0 deletions
9
...rce_customizations/iam.cnrm.cloud.google.com/IAMPartialPolicy/testdata/update_failed.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,9 @@ | ||
apiVersion: iam.cnrm.cloud.google.com/v1beta1 | ||
kind: IAMPartialPolicy | ||
status: | ||
conditions: | ||
- lastTransitionTime: '2022-07-01T12:56:21Z' | ||
message: Update failed | ||
reason: UpdateFailed | ||
status: 'False' | ||
type: Ready |
9 changes: 9 additions & 0 deletions
9
...ustomizations/iam.cnrm.cloud.google.com/IAMPartialPolicy/testdata/update_in_progress.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,9 @@ | ||
apiVersion: iam.cnrm.cloud.google.com/v1beta1 | ||
kind: IAMPartialPolicy | ||
status: | ||
conditions: | ||
- lastTransitionTime: '2022-07-01T12:56:21Z' | ||
message: Update in progress | ||
reason: Updating | ||
status: 'False' | ||
type: Ready |
53 changes: 32 additions & 21 deletions
53
resource_customizations/iam.cnrm.cloud.google.com/IAMPolicyMember/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 |
---|---|---|
@@ -1,28 +1,39 @@ | ||
hs = {} | ||
hs.status = "Progressing" | ||
hs.message = "Provisioning IAMPolicyMember..." | ||
hs = { | ||
status = "Progressing", | ||
message = "Update in progress" | ||
} | ||
if obj.status ~= nil then | ||
if obj.status.conditions ~= nil then | ||
for i, condition in ipairs(obj.status.conditions) do | ||
|
||
if obj.status == nil or obj.status.conditions == nil then | ||
return hs | ||
end | ||
|
||
for i, condition in ipairs(obj.status.conditions) do | ||
-- There should be only Ready status | ||
if condition.type == "Ready" then | ||
-- Up To Date | ||
if condition.reason == "UpToDate" and condition.status == "True" then | ||
hs.status = "Healthy" | ||
hs.message = condition.message | ||
return hs | ||
end | ||
|
||
hs.message = condition.message | ||
-- Update Failed | ||
if condition.reason == "UpdateFailed" then | ||
hs.status = "Degraded" | ||
hs.message = condition.message | ||
return hs | ||
end | ||
|
||
if condition.status == "True" then | ||
hs.status = "Healthy" | ||
return hs | ||
end | ||
-- Dependency Not Found | ||
if condition.reason == "DependencyNotFound" then | ||
hs.status = "Degraded" | ||
hs.message = condition.message | ||
return hs | ||
end | ||
|
||
if condition.reason == "UpdateFailed" then | ||
hs.status = "Degraded" | ||
return hs | ||
-- Dependency Not Ready | ||
if condition.reason == "DependencyNotReady" then | ||
hs.status = "Suspended" | ||
hs.message = condition.message | ||
return hs | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
return hs | ||
return hs |
50 changes: 20 additions & 30 deletions
50
resource_customizations/iam.cnrm.cloud.google.com/IAMPolicyMember/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 |
---|---|---|
@@ -1,31 +1,21 @@ | ||
tests: | ||
- healthStatus: | ||
status: Degraded | ||
message: | ||
'Update call failed: error setting policy member: error applying changes: | ||
summary: Request "Create IAM Members roles/storage.objects.create serviceAccount:test-sa@test-project.iam.gserviceaccount.com | ||
for \"project \\\"projects/test-project\\\"\"" returned error: Batch request | ||
and retried single request "Create IAM Members roles/storage.objects.create | ||
serviceAccount:test-sa@test-project.iam.gserviceaccount.com | ||
for \"project \\\"projects/test-project\\\"\"" both failed. Final error: | ||
Error applying IAM policy for project "projects/test-project": Error setting | ||
IAM policy for project "projects/test-project": googleapi: Error 400: Role | ||
roles/storage.objects.create is not supported for this resource., badRequest, | ||
detail: ' | ||
inputPath: testdata/degraded_updateFailed.yaml | ||
- healthStatus: | ||
status: Healthy | ||
message: "The resource is up to date" | ||
inputPath: testdata/healthy_upToDate.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Successfully deleted" | ||
inputPath: testdata/progressing_deleted.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Provisioning IAMPolicyMember..." | ||
inputPath: testdata/progressing_noStatus.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Provisioning IAMPolicyMember..." | ||
inputPath: testdata/progressing_statusGeneration.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "Dependency not found" | ||
inputPath: testdata/dependency_not_found.yaml | ||
- healthStatus: | ||
status: Suspended | ||
message: "Dependency not ready" | ||
inputPath: testdata/dependency_not_ready.yaml | ||
- healthStatus: | ||
status: Healthy | ||
message: "The resource is up to date" | ||
inputPath: testdata/up_to_date.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "Update failed" | ||
inputPath: testdata/update_failed.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Update in progress" | ||
inputPath: testdata/update_in_progress.yaml |
87 changes: 0 additions & 87 deletions
87
...tomizations/iam.cnrm.cloud.google.com/IAMPolicyMember/testdata/degraded_updateFailed.yaml
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...stomizations/iam.cnrm.cloud.google.com/IAMPolicyMember/testdata/dependency_not_found.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,9 @@ | ||
apiVersion: iam.cnrm.cloud.google.com/v1beta1 | ||
kind: IAMPolicyMember | ||
status: | ||
conditions: | ||
- lastTransitionTime: '2022-07-01T12:56:21Z' | ||
message: Dependency not found | ||
reason: DependencyNotFound | ||
status: 'False' | ||
type: Ready |
9 changes: 9 additions & 0 deletions
9
...stomizations/iam.cnrm.cloud.google.com/IAMPolicyMember/testdata/dependency_not_ready.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,9 @@ | ||
apiVersion: iam.cnrm.cloud.google.com/v1beta1 | ||
kind: IAMPolicyMember | ||
status: | ||
conditions: | ||
- lastTransitionTime: '2022-07-01T12:56:21Z' | ||
message: Dependency not ready | ||
reason: DependencyNotReady | ||
status: 'False' | ||
type: Ready |
Oops, something went wrong.