github.com/argoproj/argo-cd/v3@v3.2.1/resource_customizations/batch/CronJob/health.lua (about) 1 hs = {} 2 3 if obj.spec.suspend == true then 4 -- Set to Healthy insted of Suspended until bug is resolved 5 -- See https://github.com/argoproj/argo-cd/issues/24428 6 hs.status = "Healthy" 7 hs.message = "CronJob is Suspended" 8 return hs 9 end 10 11 if obj.status ~= nil then 12 if obj.status.lastScheduleTime ~= nil then 13 14 -- Job is running its first execution and has not yet reported any success 15 if obj.status.lastSuccessfulTime == nil then 16 -- Set to healthy even if it may be degraded, because we dont know 17 -- if it was not yet executed or if it never succeeded 18 hs.status = "Healthy" 19 hs.message = "The Cronjob never completed succesfully. It may not be healthy" 20 return hs 21 end 22 23 24 -- Job is progressing, so lastScheduleTime will always be grater than lastSuccessfulTime 25 -- Set to healthy since we do not know if it is Degraded 26 -- See https://github.com/argoproj/argo-cd/issues/24429 27 if obj.status.active ~= nil and table.getn(obj.status.active) > 0 then 28 hs.status = "Healthy" 29 hs.message = "The job is running. Its last execution may not have been successful" 30 return hs 31 end 32 33 -- If the CronJob has no active jobs and the lastSuccessfulTime < lastScheduleTime 34 -- then we know it failed the last execution 35 if obj.status.lastSuccessfulTime ~= nil and obj.status.lastSuccessfulTime < obj.status.lastScheduleTime then 36 hs.status = "Degraded" 37 hs.message = "CronJob has not completed its last execution successfully" 38 return hs 39 end 40 41 hs.message = "CronJob has completed its last execution successfully" 42 hs.status = "Healthy" 43 return hs 44 end 45 46 -- There is no way to know if as CronJob missed its execution based on status 47 -- so we assume Healthy even if a cronJob is not getting scheduled. 48 -- https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#job-creation 49 hs.message = "CronJob has not been scheduled yet" 50 hs.status = "Healthy" 51 return hs 52 end 53 54 hs.status = "Progressing" 55 hs.message = "Waiting for CronJob" 56 return hs