Skip to content

Commit

Permalink
feat(health): support for distribution aws.crossplane.io resource (#1…
Browse files Browse the repository at this point in the history
…6827)

Signed-off-by: nueavv <[email protected]>
  • Loading branch information
nueavv authored Jan 19, 2024
1 parent 32e3738 commit 21c384f
Show file tree
Hide file tree
Showing 9 changed files with 715 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
local hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
local ready = false
local synced = false
local suspended = false

for i, condition in ipairs(obj.status.conditions) do

if condition.type == "Ready" then
ready = condition.status == "True"
ready_message = condition.reason
elseif condition.type == "Synced" then
synced = condition.status == "True"
if condition.reason == "ReconcileError" then
synced_message = condition.message
elseif condition.reason == "ReconcilePaused" then
suspended = true
suspended_message = condition.reason
end
end
end
if ready and synced then
hs.status = "Healthy"
hs.message = ready_message
elseif synced == false and suspended == true then
hs.status = "Suspended"
hs.message = suspended_message
elseif ready == false and synced == true and suspended == false then
hs.status = "Progressing"
hs.message = "Waiting for distribution to be available"
else
hs.status = "Degraded"
hs.message = synced_message
end
return hs
end
end

hs.status = "Progressing"
hs.message = "Waiting for distribution to be created"
return hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
tests:
- healthStatus:
status: Progressing
message: Waiting for distribution to be available
inputPath: testdata/progressing_creating.yaml
- healthStatus:
status: Progressing
message: Waiting for distribution to be available
inputPath: testdata/progressing_noavailable.yaml
- healthStatus:
status: Progressing
message: Waiting for distribution to be available
inputPath: testdata/progressing.yaml
- healthStatus:
status: Progressing
message: Waiting for distribution to be created
inputPath: testdata/progressing_noStatus.yaml
- healthStatus:
status: Degraded
message: >
update failed: cannot update Distribution in AWS: InvalidParameter: 2
validation error(s) found.
- missing required field,
UpdateDistributionInput.DistributionConfig.Origins.Items[0].DomainName.
- missing required field,
UpdateDistributionInput.DistributionConfig.Origins.Items[0].Id.
inputPath: testdata/degraded_reconcileError.yaml
- healthStatus:
status: Suspended
message: ReconcilePaused
inputPath: testdata/suspended.yaml
- healthStatus:
status: Healthy
message: Available
inputPath: testdata/healthy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
apiVersion: cloudfront.aws.crossplane.io/v1alpha1
kind: Distribution
metadata:
creationTimestamp: '2024-01-17T07:26:02Z'
generation: 2
name: crossplane.io
resourceVersion: '261942288'
uid: 4b50c88b-165c-4176-be8e-aa28fdec0a94
spec:
deletionPolicy: Orphan
forProvider:
distributionConfig:
comment: 'crossplane'
customErrorResponses:
items: []
defaultCacheBehavior:
allowedMethods:
cachedMethods:
items:
- HEAD
- GET
items:
- HEAD
- GET
compress: false
defaultTTL: 600
fieldLevelEncryptionID: ''
forwardedValues:
cookies:
forward: none
headers:
items: []
queryString: false
queryStringCacheKeys: {}
functionAssociations: {}
lambdaFunctionAssociations: {}
maxTTL: 600
minTTL: 0
smoothStreaming: false
targetOriginID: crossplane.io
trustedKeyGroups:
enabled: false
trustedSigners:
enabled: false
viewerProtocolPolicy: allow-all
defaultRootObject: index.html
enabled: true
httpVersion: http2
isIPV6Enabled: true
logging:
bucket: ''
enabled: false
includeCookies: false
prefix: ''
originGroups: {}
origins:
items:
- connectionAttempts: 3
connectionTimeout: 10
customOriginConfig:
httpPort: 8080
httpSPort: 443
originKeepaliveTimeout: 5
originProtocolPolicy: http-only
originReadTimeout: 10
originSSLProtocols:
items:
- TLSv1
- TLSv1.1
- TLSv1.2
priceClass: PriceClass_200
restrictions:
geoRestriction:
restrictionType: none
region: ap-northeast-2
providerConfigRef:
name: crossplane
status:
conditions:
- lastTransitionTime: '2024-01-17T07:26:02Z'
message: >
update failed: cannot update Distribution in AWS: InvalidParameter: 2
validation error(s) found.
- missing required field,
UpdateDistributionInput.DistributionConfig.Origins.Items[0].DomainName.
- missing required field,
UpdateDistributionInput.DistributionConfig.Origins.Items[0].Id.
reason: ReconcileError
status: 'False'
type: Synced
- lastTransitionTime: '2024-01-17T07:26:03Z'
reason: Available
status: 'True'
type: Ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: cloudfront.aws.crossplane.io/v1alpha1
kind: Distribution
metadata:
creationTimestamp: "2023-09-07T01:01:16Z"
generation: 121
name: crossplane.io
resourceVersion: "254225966"
uid: 531d989c-a3d2-4ab4-841d-ab380cce0bdb
spec:
deletionPolicy: Orphan
forProvider:
distributionConfig:
comment: 'crossplane'
customErrorResponses:
items: []
defaultCacheBehavior:
allowedMethods:
cachedMethods:
items:
- HEAD
- GET
items:
- HEAD
- GET
compress: false
defaultTTL: 600
fieldLevelEncryptionID: ''
forwardedValues:
cookies:
forward: none
headers:
items: []
queryString: false
queryStringCacheKeys: {}
functionAssociations: {}
lambdaFunctionAssociations: {}
maxTTL: 600
minTTL: 0
smoothStreaming: false
targetOriginID: crossplane.io
trustedKeyGroups:
enabled: false
trustedSigners:
enabled: false
viewerProtocolPolicy: allow-all
defaultRootObject: index.html
enabled: true
httpVersion: http2
isIPV6Enabled: true
logging:
bucket: ''
enabled: false
includeCookies: false
prefix: ''
originGroups: {}
origins:
items:
- connectionAttempts: 3
connectionTimeout: 10
customHeaders: {}
customOriginConfig:
httpPort: 8080
httpSPort: 443
originKeepaliveTimeout: 5
originProtocolPolicy: http-only
originReadTimeout: 10
originSSLProtocols:
items:
- TLSv1
- TLSv1.1
- TLSv1.2
domainName: crossplane.io
id: crossplane.io
originShield:
enabled: false
priceClass: PriceClass_200
restrictions:
geoRestriction:
restrictionType: none
region: ap-northeast-2
providerConfigRef:
name: crossplane
status:
conditions:
- lastTransitionTime: "2024-01-11T06:23:18Z"
reason: ReconcileSuccess
status: "True"
type: Synced
- lastTransitionTime: "2024-01-10T03:23:02Z"
reason: Available
status: "True"
type: Ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: cloudfront.aws.crossplane.io/v1alpha1
kind: Distribution
metadata:
creationTimestamp: '2023-06-16T04:42:04Z'
generation: 37
name: crossplane.io
resourceVersion: '254326453'
uid: fd357670-b762-4285-ae83-00859c40dd6b
spec:
deletionPolicy: Orphan
forProvider:
distributionConfig:
comment: 'crossplane'
customErrorResponses:
items: []
defaultCacheBehavior:
allowedMethods:
cachedMethods:
items:
- HEAD
- GET
items:
- GET
- HEAD
compress: false
defaultTTL: 600
fieldLevelEncryptionID: ""
forwardedValues:
cookies:
forward: none
headers:
items: []
queryString: false
queryStringCacheKeys: {}
functionAssociations: {}
lambdaFunctionAssociations: {}
maxTTL: 600
minTTL: 0
smoothStreaming: false
targetOriginID: crossplane.io
trustedKeyGroups:
enabled: false
trustedSigners:
enabled: false
viewerProtocolPolicy: allow-all
defaultRootObject: index.html
enabled: true
httpVersion: http2
isIPV6Enabled: true
logging:
bucket: ""
enabled: false
includeCookies: false
prefix: ""
originGroups: {}
origins:
items:
- connectionAttempts: 3
connectionTimeout: 10
customHeaders: {}
customOriginConfig:
httpPort: 8080
httpSPort: 443
originKeepaliveTimeout: 5
originProtocolPolicy: http-only
originReadTimeout: 10
originSSLProtocols:
items:
- TLSv1
- TLSv1.1
- TLSv1.2
domainName: crossplane.io
id: crossplane.io
originShield:
enabled: false
priceClass: PriceClass_200
restrictions:
geoRestriction:
restrictionType: none
region: ap-northeast-2
providerConfigRef:
name: crossplane
status:
conditions:
- lastTransitionTime: '2024-01-11T08:11:27Z'
reason: Unavailable
status: 'False'
type: Ready
- lastTransitionTime: '2024-01-11T08:11:02Z'
reason: ReconcileSuccess
status: 'True'
type: Synced
Loading

0 comments on commit 21c384f

Please sign in to comment.