From bdb91faaace140a367769360561d7e74decfccb3 Mon Sep 17 00:00:00 2001 From: zhengyansheng Date: Fri, 16 Feb 2024 13:44:46 +0800 Subject: [PATCH 1/2] delete unused variable --- pkg/controller/cronmanager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/cronmanager.go b/pkg/controller/cronmanager.go index e6c46346..264e0d82 100644 --- a/pkg/controller/cronmanager.go +++ b/pkg/controller/cronmanager.go @@ -35,7 +35,7 @@ func (n NoNeedUpdate) Error() string { } type CronManager struct { - sync.Mutex + //sync.Mutex cfg *rest.Config client client.Client jobQueue *sync.Map From 4f936567710ba85b5d944dbba691c498da855bad Mon Sep 17 00:00:00 2001 From: zhengyansheng Date: Fri, 16 Feb 2024 16:53:21 +0800 Subject: [PATCH 2/2] remove unnecessary assignments to make the code more concise --- pkg/controller/cronmanager.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/controller/cronmanager.go b/pkg/controller/cronmanager.go index 264e0d82..b7a45116 100644 --- a/pkg/controller/cronmanager.go +++ b/pkg/controller/cronmanager.go @@ -47,7 +47,7 @@ type CronManager struct { } func (cm *CronManager) createOrUpdate(j CronJob) error { - if _, ok := cm.jobQueue.Load(j.ID()); !ok { + if loadJob, ok := cm.jobQueue.Load(j.ID()); !ok { err := cm.cronExecutor.AddJob(j) if err != nil { return fmt.Errorf("Failed to add job to cronExecutor,because of %v", err) @@ -56,7 +56,6 @@ func (cm *CronManager) createOrUpdate(j CronJob) error { log.Infof("cronHPA job %s of cronHPA %s in %s created, %d active jobs exist", j.Name(), j.CronHPAMeta().Name, j.CronHPAMeta().Namespace, queueLength(cm.jobQueue)) } else { - loadJob, _ := cm.jobQueue.Load(j.ID()) job, convert := loadJob.(*CronJobHPA) if !convert { return fmt.Errorf("failed to convert job %v to CronJobHPA", loadJob)