@@ -58,15 +58,17 @@ import (
58
58
// controllerKind contains the schema.GroupVersionKind for this controller type.
59
59
var controllerKind = batchv1beta1 .SchemeGroupVersion .WithKind ("CronJob" )
60
60
61
- type CronJobController struct {
61
+ // Controller is a controller for CronJobs.
62
+ type Controller struct {
62
63
kubeClient clientset.Interface
63
64
jobControl jobControlInterface
64
65
sjControl sjControlInterface
65
66
podControl podControlInterface
66
67
recorder record.EventRecorder
67
68
}
68
69
69
- func NewCronJobController (kubeClient clientset.Interface ) (* CronJobController , error ) {
70
+ // NewController creates and initializes a new Controller.
71
+ func NewController (kubeClient clientset.Interface ) (* Controller , error ) {
70
72
eventBroadcaster := record .NewBroadcaster ()
71
73
eventBroadcaster .StartLogging (klog .Infof )
72
74
eventBroadcaster .StartRecordingToSink (& v1core.EventSinkImpl {Interface : kubeClient .CoreV1 ().Events ("" )})
@@ -77,7 +79,7 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
77
79
}
78
80
}
79
81
80
- jm := & CronJobController {
82
+ jm := & Controller {
81
83
kubeClient : kubeClient ,
82
84
jobControl : realJobControl {KubeClient : kubeClient },
83
85
sjControl : & realSJControl {KubeClient : kubeClient },
@@ -88,8 +90,8 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
88
90
return jm , nil
89
91
}
90
92
91
- // Run the main goroutine responsible for watching and syncing jobs.
92
- func (jm * CronJobController ) Run (stopCh <- chan struct {}) {
93
+ // Run starts the main goroutine responsible for watching and syncing jobs.
94
+ func (jm * Controller ) Run (stopCh <- chan struct {}) {
93
95
defer utilruntime .HandleCrash ()
94
96
klog .Infof ("Starting CronJob Manager" )
95
97
// Check things every 10 second.
@@ -99,7 +101,7 @@ func (jm *CronJobController) Run(stopCh <-chan struct{}) {
99
101
}
100
102
101
103
// syncAll lists all the CronJobs and Jobs and reconciles them.
102
- func (jm * CronJobController ) syncAll () {
104
+ func (jm * Controller ) syncAll () {
103
105
// List children (Jobs) before parents (CronJob).
104
106
// This guarantees that if we see any Job that got orphaned by the GC orphan finalizer,
105
107
// we must also see that the parent CronJob has non-nil DeletionTimestamp (see #42639).
0 commit comments