Skip to content

Instantly share code, notes, and snippets.

@d-kuro
Created March 7, 2019 19:48
Show Gist options
  • Save d-kuro/b1666f96a2502c17d90e53b944b4f63a to your computer and use it in GitHub Desktop.
Save d-kuro/b1666f96a2502c17d90e53b944b4f63a to your computer and use it in GitHub Desktop.
// from: https://github.com/kubernetes/kubernetes/blob/87f9429087d4e31201412548517d36e83abebc8d/pkg/controller/cronjob/utils.go#L58-L72
// getParentUIDFromJob extracts UID of job's parent and whether it was found
func getParentUIDFromJob(j batchv1.Job) (types.UID, bool) {
controllerRef := metav1.GetControllerOf(&j)
if controllerRef == nil {
return types.UID(""), false
}
if controllerRef.Kind != "CronJob" {
klog.V(4).Infof("Job with non-CronJob parent, name %s namespace %s", j.Name, j.Namespace)
return types.UID(""), false
}
return controllerRef.UID, true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment