forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,242 additions
and
40 deletions.
There are no files selected for viewing
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
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
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
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
36 changes: 36 additions & 0 deletions
36
resource_customizations/apps.kruise.io/AdvancedCronJob/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,36 @@ | ||
hs = { status = "Progressing", message = "AdvancedCronJobs has active jobs" } | ||
-- Extract lastScheduleTime and convert to time objects | ||
lastScheduleTime = nil | ||
|
||
if obj.status.lastScheduleTime ~= nil then | ||
local year, month, day, hour, min, sec = string.match(obj.status.lastScheduleTime, "(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)Z") | ||
lastScheduleTime = os.time({year=year, month=month, day=day, hour=hour, min=min, sec=sec}) | ||
end | ||
|
||
|
||
if lastScheduleTime == nil and obj.spec.paused == true then | ||
hs.status = "Suspended" | ||
hs.message = "AdvancedCronJob is Paused" | ||
return hs | ||
end | ||
|
||
-- AdvancedCronJobs are progressing if they have any object in the "active" state | ||
if obj.status.active ~= nil and #obj.status.active > 0 then | ||
hs.status = "Progressing" | ||
hs.message = "AdvancedCronJobs has active jobs" | ||
return hs | ||
end | ||
-- AdvancedCronJobs are Degraded if they don't have lastScheduleTime | ||
if lastScheduleTime == nil then | ||
hs.status = "Degraded" | ||
hs.message = "AdvancedCronJobs has not run successfully" | ||
return hs | ||
end | ||
-- AdvancedCronJobs are healthy if they have lastScheduleTime | ||
if lastScheduleTime ~= nil then | ||
hs.status = "Healthy" | ||
hs.message = "AdvancedCronJobs has run successfully" | ||
return hs | ||
end | ||
|
||
return hs |
17 changes: 17 additions & 0 deletions
17
resource_customizations/apps.kruise.io/AdvancedCronJob/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,17 @@ | ||
tests: | ||
- healthStatus: | ||
status: Healthy | ||
message: AdvancedCronJobs has run successfully | ||
inputPath: testdata/lastScheduleTime.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: AdvancedCronJobs has not run successfully | ||
inputPath: testdata/notScheduled.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: AdvancedCronJobs has active jobs | ||
inputPath: testdata/activeJobs.yaml | ||
- healthStatus: | ||
status: Suspended | ||
message: AdvancedCronJob is Paused | ||
inputPath: testdata/suspended.yaml |
30 changes: 30 additions & 0 deletions
30
resource_customizations/apps.kruise.io/AdvancedCronJob/testdata/activeJobs.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,30 @@ | ||
apiVersion: apps.kruise.io/v1alpha1 | ||
kind: AdvancedCronJob | ||
metadata: | ||
name: acj-test | ||
spec: | ||
schedule: "*/1 * * * *" | ||
template: | ||
broadcastJobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: pi | ||
image: perl | ||
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] | ||
restartPolicy: Never | ||
completionPolicy: | ||
type: Always | ||
ttlSecondsAfterFinished: 30 | ||
|
||
status: | ||
active: | ||
- apiVersion: apps.kruise.io/v1alpha1 | ||
kind: BroadcastJob | ||
name: acj-test-1694882400 | ||
namespace: default | ||
resourceVersion: '4012' | ||
uid: 2b08a429-a43b-4382-8e5d-3db0c72b5b13 | ||
lastScheduleTime: '2023-09-16T16:40:00Z' | ||
type: BroadcastJob |
23 changes: 23 additions & 0 deletions
23
resource_customizations/apps.kruise.io/AdvancedCronJob/testdata/lastScheduleTime.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,23 @@ | ||
apiVersion: apps.kruise.io/v1alpha1 | ||
kind: AdvancedCronJob | ||
metadata: | ||
name: acj-test | ||
spec: | ||
schedule: "*/1 * * * *" | ||
template: | ||
broadcastJobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: pi | ||
image: perl | ||
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] | ||
restartPolicy: Never | ||
completionPolicy: | ||
type: Always | ||
ttlSecondsAfterFinished: 30 | ||
|
||
status: | ||
lastScheduleTime: "2023-09-16T16:29:00Z" | ||
type: BroadcastJob |
22 changes: 22 additions & 0 deletions
22
resource_customizations/apps.kruise.io/AdvancedCronJob/testdata/notScheduled.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,22 @@ | ||
apiVersion: apps.kruise.io/v1alpha1 | ||
kind: AdvancedCronJob | ||
metadata: | ||
name: acj-test | ||
spec: | ||
schedule: "*/1 * * * *" | ||
template: | ||
broadcastJobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: pi | ||
image: perl | ||
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] | ||
restartPolicy: Never | ||
completionPolicy: | ||
type: Always | ||
ttlSecondsAfterFinished: 30 | ||
|
||
status: | ||
lastScheduleTime: null |
23 changes: 23 additions & 0 deletions
23
resource_customizations/apps.kruise.io/AdvancedCronJob/testdata/suspended.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,23 @@ | ||
apiVersion: apps.kruise.io/v1alpha1 | ||
kind: AdvancedCronJob | ||
metadata: | ||
name: acj-test | ||
spec: | ||
schedule: "*/1 * * * *" | ||
template: | ||
broadcastJobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: pi | ||
image: perl | ||
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] | ||
restartPolicy: Never | ||
completionPolicy: | ||
type: Always | ||
ttlSecondsAfterFinished: 30 | ||
paused: true | ||
|
||
status: | ||
type: BroadcastJob |
Oops, something went wrong.