66 source : " event.id"
77 type : " string"
88 required : true
9- - name : " jobSleepDuration"
10- source : " env.JOB_SLEEP_DURATION"
11- type : " string"
12- default : " 1"
139
1410# Preconditions with valid operators and CEL expressions
1511preconditions :
@@ -25,8 +21,6 @@ preconditions:
2521 field : " name"
2622 - name : " generationSpec"
2723 field : " generation"
28- - name : " simulateResult" # possible values: success (default), failure, hang, crash, invalid-json, missing-status
29- field : " simulateResult"
3024 - name : " is_deleting"
3125 expression : " has(clusterStatus.deleted_time)"
3226 - name : " clusterNotReconciled"
@@ -59,60 +53,7 @@ preconditions:
5953
6054# Resources with valid K8s manifests
6155resources :
62- # the following configuration is for a job that will be created in the cluster
63- # in the namespace created above
64- # it will require a service account to be created in that namespace as well as a role and rolebinding
65- - name : " jobServiceAccount"
66- transport :
67- client : " kubernetes"
68- manifest :
69- ref : " /etc/adapter/job-serviceaccount.yaml"
70- discovery :
71- namespace : " {{ .clusterId }}"
72- by_selectors :
73- label_selector :
74- hyperfleet.io/resource-type : " service-account"
75- hyperfleet.io/cluster-id : " {{ .clusterId }}"
76- lifecycle :
77- delete :
78- propagationPolicy : Background
79- when :
80- expression : " is_deleting"
81-
82- - name : " jobRole"
83- transport :
84- client : " kubernetes"
85- manifest :
86- ref : " /etc/adapter/job-role.yaml"
87- discovery :
88- namespace : " {{ .clusterId }}"
89- by_selectors :
90- label_selector :
91- hyperfleet.io/cluster-id : " {{ .clusterId }}"
92- hyperfleet.io/resource-type : " role"
93- lifecycle :
94- delete :
95- propagationPolicy : Background
96- when :
97- expression : " is_deleting"
98-
99- - name : " jobRolebinding"
100- transport :
101- client : " kubernetes"
102- manifest :
103- ref : " /etc/adapter/job-rolebinding.yaml"
104- discovery :
105- namespace : " {{ .clusterId }}"
106- by_selectors :
107- label_selector :
108- hyperfleet.io/cluster-id : " {{ .clusterId }}"
109- hyperfleet.io/resource-type : " role-binding"
110- lifecycle :
111- delete :
112- propagationPolicy : Background
113- when :
114- expression : " is_deleting"
115-
56+ # Hello-world job created in the cluster namespace
11657 - name : " testJob"
11758 transport :
11859 client : " kubernetes"
@@ -131,7 +72,7 @@ resources:
13172 expression : " is_deleting"
13273
13374# Post-processing with valid CEL expressions
134- # This example contains multiple resources, we will only report on the conditions of the jobNamespace not to overcomplicate the example
75+ # Reports Applied, Available, and Health conditions for the hello-world job
13576post :
13677 payloads :
13778 - name : " clusterStatusPayload"
@@ -153,26 +94,33 @@ post:
15394 has(resources.testJob)
15495 ? "testJob manifest applied successfully"
15596 : "testJob is pending to be applied"
156- # Available: Check job status conditions
97+ # Available: True when the job has completed successfully
15798 - type : " Available"
15899 status :
159100 expression : |
160101 has(resources.testJob) ?
161- ( resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Available")
162- ? resources.testJob.status.conditions.filter(c, c.type == "Available")[0].status : "False")
163- : "False"
102+ ( resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Complete")
103+ ? resources.testJob.status.conditions.filter(c, c.type == "Complete")[0].status
104+ : "False")
105+ : "False"
164106 reason :
165107 expression : |
166- resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Available")
167- ? resources.testJob.status.conditions.filter(c, c.type == "Available")[0].reason
168- : resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Failed") ? "testJobFailed"
169- : resources.?testJob.?status.hasValue() ? "testJobInProgress" : "testJobPending"
108+ resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Complete")
109+ ? "JobComplete"
110+ : resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Failed")
111+ ? "JobFailed"
112+ : resources.?testJob.?status.hasValue()
113+ ? "JobRunning"
114+ : "JobPending"
170115 message :
171116 expression : |
172- resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Available")
173- ? resources.testJob.status.conditions.filter(c, c.type == "Available")[0].message
174- : resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Failed") ? "testJob failed"
175- : resources.?testJob.?status.hasValue() ? "testJob in progress" : "testJob is pending"
117+ resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Complete")
118+ ? "Hello-world job completed successfully"
119+ : resources.?testJob.?status.?conditions.orValue([]).exists(c, c.type == "Failed")
120+ ? "Hello-world job failed"
121+ : resources.?testJob.?status.hasValue()
122+ ? "Hello-world job is running"
123+ : "Hello-world job is pending"
176124 # Health: Adapter execution status (runtime)
177125 - type : " Health"
178126 status :
@@ -208,21 +156,18 @@ post:
208156 && adapter.?executionStatus.orValue("") == "success"
209157 && !adapter.?resourcesSkipped.orValue(false)
210158 && !resources.?testJob.hasValue()
211- && !resources.?jobServiceAccount.hasValue()
212- && !resources.?jobRole.hasValue()
213- && !resources.?jobRolebinding.hasValue()
214159 ? "True"
215160 : "False"
216161 reason :
217162 expression : |
218163 !is_deleting ? "NotDeleting"
219- : !resources.?testJob.hasValue() && !resources.?jobServiceAccount.hasValue() && !resources.?jobRole.hasValue() && !resources.?jobRolebinding.hasValue()
164+ : !resources.?testJob.hasValue()
220165 ? "CleanupConfirmed"
221166 : "CleanupInProgress"
222167 message :
223168 expression : |
224169 !is_deleting ? "Resource not marked for deletion"
225- : !resources.?testJob.hasValue() && !resources.?jobServiceAccount.hasValue() && !resources.?jobRole.hasValue() && !resources.?jobRolebinding.hasValue()
170+ : !resources.?testJob.hasValue()
226171 ? "All resources deleted; cleanup confirmed"
227172 : "Deletion in progress; waiting for resources to be removed"
228173 # Event generation ID metadata field needs to use expression to avoid interpolation issues
0 commit comments