CronJob: Apply missing ControllerRefs to Jobs created by a CronJob.

This should only happen if the Jobs were created by an older version
of the CronJob controller, since from now on we add ControllerRef upon
creation.

CronJob doesn't do actual adoption because it doesn't use label
selectors to find its Jobs. However, we should apply ControllerRef
for potential server-side cascading deletion, and to advise other
controllers we own these objects.
This commit is contained in:
Anthony Yeh
2017-02-26 20:14:36 -08:00
parent 631d8bcdbb
commit e085f1f83c
5 changed files with 70 additions and 1 deletions

View File

@@ -120,6 +120,7 @@ type fakeJobControl struct {
Jobs []batchv1.Job
DeleteJobName []string
Err error
UpdateJobName []string
}
var _ jobControlInterface = &fakeJobControl{}
@@ -151,6 +152,7 @@ func (f *fakeJobControl) UpdateJob(namespace string, job *batchv1.Job) (*batchv1
if f.Err != nil {
return nil, f.Err
}
f.UpdateJobName = append(f.UpdateJobName, job.Name)
return job, nil
}