mirror of https://github.com/k3s-io/k3s
Fix lint warnings in pkg/controller/cronjob.
parent
6518c0b696
commit
ac88e13821
|
@ -46,7 +46,7 @@ func startCronJobController(ctx ControllerContext) (http.Handler, bool, error) {
|
|||
if !ctx.AvailableResources[schema.GroupVersionResource{Group: "batch", Version: "v1beta1", Resource: "cronjobs"}] {
|
||||
return nil, false, nil
|
||||
}
|
||||
cjc, err := cronjob.NewCronJobController(
|
||||
cjc, err := cronjob.NewController(
|
||||
ctx.ClientBuilder.ClientOrDie("cronjob-controller"),
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
@ -79,7 +79,6 @@ pkg/controller/certificates/approver
|
|||
pkg/controller/certificates/signer
|
||||
pkg/controller/cloud
|
||||
pkg/controller/clusterroleaggregation
|
||||
pkg/controller/cronjob
|
||||
pkg/controller/daemon
|
||||
pkg/controller/deployment
|
||||
pkg/controller/disruption
|
||||
|
|
|
@ -58,7 +58,8 @@ import (
|
|||
// controllerKind contains the schema.GroupVersionKind for this controller type.
|
||||
var controllerKind = batchv1beta1.SchemeGroupVersion.WithKind("CronJob")
|
||||
|
||||
type CronJobController struct {
|
||||
// Controller is a controller for CronJobs.
|
||||
type Controller struct {
|
||||
kubeClient clientset.Interface
|
||||
jobControl jobControlInterface
|
||||
sjControl sjControlInterface
|
||||
|
@ -66,7 +67,8 @@ type CronJobController struct {
|
|||
recorder record.EventRecorder
|
||||
}
|
||||
|
||||
func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, error) {
|
||||
// NewController creates and initializes a new Controller.
|
||||
func NewController(kubeClient clientset.Interface) (*Controller, error) {
|
||||
eventBroadcaster := record.NewBroadcaster()
|
||||
eventBroadcaster.StartLogging(klog.Infof)
|
||||
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
|
||||
|
@ -77,7 +79,7 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
|
|||
}
|
||||
}
|
||||
|
||||
jm := &CronJobController{
|
||||
jm := &Controller{
|
||||
kubeClient: kubeClient,
|
||||
jobControl: realJobControl{KubeClient: kubeClient},
|
||||
sjControl: &realSJControl{KubeClient: kubeClient},
|
||||
|
@ -88,8 +90,8 @@ func NewCronJobController(kubeClient clientset.Interface) (*CronJobController, e
|
|||
return jm, nil
|
||||
}
|
||||
|
||||
// Run the main goroutine responsible for watching and syncing jobs.
|
||||
func (jm *CronJobController) Run(stopCh <-chan struct{}) {
|
||||
// Run starts the main goroutine responsible for watching and syncing jobs.
|
||||
func (jm *Controller) Run(stopCh <-chan struct{}) {
|
||||
defer utilruntime.HandleCrash()
|
||||
klog.Infof("Starting CronJob Manager")
|
||||
// Check things every 10 second.
|
||||
|
@ -99,7 +101,7 @@ func (jm *CronJobController) Run(stopCh <-chan struct{}) {
|
|||
}
|
||||
|
||||
// syncAll lists all the CronJobs and Jobs and reconciles them.
|
||||
func (jm *CronJobController) syncAll() {
|
||||
func (jm *Controller) syncAll() {
|
||||
// List children (Jobs) before parents (CronJob).
|
||||
// This guarantees that if we see any Job that got orphaned by the GC orphan finalizer,
|
||||
// we must also see that the parent CronJob has non-nil DeletionTimestamp (see #42639).
|
||||
|
|
|
@ -142,7 +142,7 @@ func getRecentUnmetScheduleTimes(sj batchv1beta1.CronJob, now time.Time) ([]time
|
|||
// but less than "lots".
|
||||
if len(starts) > 100 {
|
||||
// We can't get the most recent times so just return an empty slice
|
||||
return []time.Time{}, fmt.Errorf("Too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew.")
|
||||
return []time.Time{}, fmt.Errorf("too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew")
|
||||
}
|
||||
}
|
||||
return starts, nil
|
||||
|
@ -183,6 +183,7 @@ func getFinishedStatus(j *batchv1.Job) (bool, batchv1.JobConditionType) {
|
|||
return false, ""
|
||||
}
|
||||
|
||||
// IsJobFinished returns whether or not a job has completed successfully or failed.
|
||||
func IsJobFinished(j *batchv1.Job) bool {
|
||||
isFinished, _ := getFinishedStatus(j)
|
||||
return isFinished
|
||||
|
|
|
@ -35,7 +35,7 @@ func TestGetJobFromTemplate(t *testing.T) {
|
|||
// and other fields, and add a created-by reference.
|
||||
|
||||
var one int64 = 1
|
||||
var no bool = false
|
||||
var no bool
|
||||
|
||||
sj := batchv1beta1.CronJob{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
|
|
@ -38,7 +38,7 @@ import (
|
|||
"k8s.io/kubernetes/test/integration/framework"
|
||||
)
|
||||
|
||||
func setup(t *testing.T) (*httptest.Server, framework.CloseFunc, *cronjob.CronJobController, *job.JobController, informers.SharedInformerFactory, clientset.Interface, rest.Config) {
|
||||
func setup(t *testing.T) (*httptest.Server, framework.CloseFunc, *cronjob.Controller, *job.JobController, informers.SharedInformerFactory, clientset.Interface, rest.Config) {
|
||||
masterConfig := framework.NewIntegrationTestMasterConfig()
|
||||
_, server, closeFn := framework.RunAMaster(masterConfig)
|
||||
|
||||
|
@ -49,7 +49,7 @@ func setup(t *testing.T) (*httptest.Server, framework.CloseFunc, *cronjob.CronJo
|
|||
}
|
||||
resyncPeriod := 12 * time.Hour
|
||||
informerSet := informers.NewSharedInformerFactory(clientset.NewForConfigOrDie(restclient.AddUserAgent(&config, "cronjob-informers")), resyncPeriod)
|
||||
cjc, err := cronjob.NewCronJobController(clientSet)
|
||||
cjc, err := cronjob.NewController(clientSet)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating CronJob controller: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue