Skip to content

Commit ac88e13

Browse files
committed
Fix lint warnings in pkg/controller/cronjob.
1 parent 6518c0b commit ac88e13

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

cmd/kube-controller-manager/app/batch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func startCronJobController(ctx ControllerContext) (http.Handler, bool, error) {
4646
if !ctx.AvailableResources[schema.GroupVersionResource{Group: "batch", Version: "v1beta1", Resource: "cronjobs"}] {
4747
return nil, false, nil
4848
}
49-
cjc, err := cronjob.NewCronJobController(
49+
cjc, err := cronjob.NewController(
5050
ctx.ClientBuilder.ClientOrDie("cronjob-controller"),
5151
)
5252
if err != nil {

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ pkg/controller/certificates/approver
7979
pkg/controller/certificates/signer
8080
pkg/controller/cloud
8181
pkg/controller/clusterroleaggregation
82-
pkg/controller/cronjob
8382
pkg/controller/daemon
8483
pkg/controller/deployment
8584
pkg/controller/disruption

pkg/controller/cronjob/controller.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,17 @@ import (
5858
// controllerKind contains the schema.GroupVersionKind for this controller type.
5959
var controllerKind = batchv1beta1.SchemeGroupVersion.WithKind("CronJob")
6060

61-
type CronJobController struct {
61+
// Controller is a controller for CronJobs.
62+
type Controller struct {
6263
kubeClient clientset.Interface
6364
jobControl jobControlInterface
6465
sjControl sjControlInterface
6566
podControl podControlInterface
6667
recorder record.EventRecorder
6768
}
6869

69-
func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, error) {
70+
// NewController creates and initializes a new Controller.
71+
func NewController(kubeClient clientset.Interface) (*Controller, error) {
7072
eventBroadcaster := record.NewBroadcaster()
7173
eventBroadcaster.StartLogging(klog.Infof)
7274
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
@@ -77,7 +79,7 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
7779
}
7880
}
7981

80-
jm := &CronJobController{
82+
jm := &Controller{
8183
kubeClient: kubeClient,
8284
jobControl: realJobControl{KubeClient: kubeClient},
8385
sjControl: &realSJControl{KubeClient: kubeClient},
@@ -88,8 +90,8 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
8890
return jm, nil
8991
}
9092

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{}) {
9395
defer utilruntime.HandleCrash()
9496
klog.Infof("Starting CronJob Manager")
9597
// Check things every 10 second.
@@ -99,7 +101,7 @@ func (jm *CronJobController) Run(stopCh <-chan struct{}) {
99101
}
100102

101103
// syncAll lists all the CronJobs and Jobs and reconciles them.
102-
func (jm *CronJobController) syncAll() {
104+
func (jm *Controller) syncAll() {
103105
// List children (Jobs) before parents (CronJob).
104106
// This guarantees that if we see any Job that got orphaned by the GC orphan finalizer,
105107
// we must also see that the parent CronJob has non-nil DeletionTimestamp (see #42639).

pkg/controller/cronjob/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func getRecentUnmetScheduleTimes(sj batchv1beta1.CronJob, now time.Time) ([]time
142142
// but less than "lots".
143143
if len(starts) > 100 {
144144
// We can't get the most recent times so just return an empty slice
145-
return []time.Time{}, fmt.Errorf("Too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew.")
145+
return []time.Time{}, fmt.Errorf("too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew")
146146
}
147147
}
148148
return starts, nil
@@ -183,6 +183,7 @@ func getFinishedStatus(j *batchv1.Job) (bool, batchv1.JobConditionType) {
183183
return false, ""
184184
}
185185

186+
// IsJobFinished returns whether or not a job has completed successfully or failed.
186187
func IsJobFinished(j *batchv1.Job) bool {
187188
isFinished, _ := getFinishedStatus(j)
188189
return isFinished

pkg/controller/cronjob/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestGetJobFromTemplate(t *testing.T) {
3535
// and other fields, and add a created-by reference.
3636

3737
var one int64 = 1
38-
var no bool = false
38+
var no bool
3939

4040
sj := batchv1beta1.CronJob{
4141
ObjectMeta: metav1.ObjectMeta{

test/integration/cronjob/cronjob_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
"k8s.io/kubernetes/test/integration/framework"
3939
)
4040

41-
func setup(t *testing.T) (*httptest.Server, framework.CloseFunc, *cronjob.CronJobController, *job.JobController, informers.SharedInformerFactory, clientset.Interface, rest.Config) {
41+
func setup(t *testing.T) (*httptest.Server, framework.CloseFunc, *cronjob.Controller, *job.JobController, informers.SharedInformerFactory, clientset.Interface, rest.Config) {
4242
masterConfig := framework.NewIntegrationTestMasterConfig()
4343
_, server, closeFn := framework.RunAMaster(masterConfig)
4444

@@ -49,7 +49,7 @@ func setup(t *testing.T) (*httptest.Server, framework.CloseFunc, *cronjob.CronJo
4949
}
5050
resyncPeriod := 12 * time.Hour
5151
informerSet := informers.NewSharedInformerFactory(clientset.NewForConfigOrDie(restclient.AddUserAgent(&config, "cronjob-informers")), resyncPeriod)
52-
cjc, err := cronjob.NewCronJobController(clientSet)
52+
cjc, err := cronjob.NewController(clientSet)
5353
if err != nil {
5454
t.Fatalf("Error creating CronJob controller: %v", err)
5555
}

0 commit comments

Comments
 (0)