Last active
March 8, 2019 03:57
-
-
Save d-kuro/62b76683cc1c9f760ac9604629036d08 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// from: https://github.com/kubernetes/kubernetes/blob/87f9429087d4e31201412548517d36e83abebc8d/pkg/controller/cronjob/cronjob_controller.go#L190-L344 | |
childrenJobs := make(map[types.UID]bool) | |
for _, j := range js { | |
childrenJobs[j.ObjectMeta.UID] = true | |
found := inActiveList(*sj, j.ObjectMeta.UID) | |
if !found && !IsJobFinished(&j) { | |
recorder.Eventf(sj, v1.EventTypeWarning, "UnexpectedJob", "Saw a job that the controller did not create or forgot: %v", j.Name) | |
// We found an unfinished job that has us as the parent, but it is not in our Active list. | |
// This could happen if we crashed right after creating the Job and before updating the status, | |
// or if our jobs list is newer than our sj status after a relist, or if someone intentionally created | |
// a job that they wanted us to adopt. | |
// TODO: maybe handle the adoption case? Concurrency/suspend rules will not apply in that case, obviously, since we can't | |
// stop users from creating jobs if they have permission. It is assumed that if a | |
// user has permission to create a job within a namespace, then they have permission to make any scheduledJob | |
// in the same namespace "adopt" that job. ReplicaSets and their Pods work the same way. | |
// TBS: how to update sj.Status.LastScheduleTime if the adopted job is newer than any we knew about? | |
} else if found && IsJobFinished(&j) { | |
deleteFromActiveList(sj, j.ObjectMeta.UID) | |
// TODO: event to call out failure vs success. | |
recorder.Eventf(sj, v1.EventTypeNormal, "SawCompletedJob", "Saw completed job: %v", j.Name) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment