diff --git a/hack/verify-golangci-lint.sh b/hack/verify-golangci-lint.sh index f8f91c3a56..c55fc4919d 100755 --- a/hack/verify-golangci-lint.sh +++ b/hack/verify-golangci-lint.sh @@ -27,7 +27,7 @@ function check_golangci-lint() { command -v golangci-lint >/dev/null 2>&1 if [[ $? -ne 0 ]]; then echo "installing golangci-lint ." - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.40.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0 if [[ $? -ne 0 ]]; then echo "golangci-lint installed failed, exiting." exit 1 diff --git a/pkg/controllers/job/job_controller_actions.go b/pkg/controllers/job/job_controller_actions.go index a77cb043c6..97521ba4f1 100644 --- a/pkg/controllers/job/job_controller_actions.go +++ b/pkg/controllers/job/job_controller_actions.go @@ -649,54 +649,53 @@ func (cc *jobcontroller) createOrUpdatePodGroup(job *batch.Job) error { klog.Errorf("Failed to get PodGroup for Job <%s/%s>: %v", job.Namespace, job.Name, err) return err - } else { - // try to get old pg if new pg not exist - pg, err = cc.pgLister.PodGroups(job.Namespace).Get(job.Name) - if err != nil { - if !apierrors.IsNotFound(err) { - klog.Errorf("Failed to get PodGroup for Job <%s/%s>: %v", - job.Namespace, job.Name, err) - return err - } + } + // try to get old pg if new pg not exist + pg, err = cc.pgLister.PodGroups(job.Namespace).Get(job.Name) + if err != nil { + if !apierrors.IsNotFound(err) { + klog.Errorf("Failed to get PodGroup for Job <%s/%s>: %v", + job.Namespace, job.Name, err) + return err + } - minTaskMember := map[string]int32{} - for _, task := range job.Spec.Tasks { - if task.MinAvailable != nil { - minTaskMember[task.Name] = *task.MinAvailable - } else { - minTaskMember[task.Name] = task.Replicas - } + minTaskMember := map[string]int32{} + for _, task := range job.Spec.Tasks { + if task.MinAvailable != nil { + minTaskMember[task.Name] = *task.MinAvailable + } else { + minTaskMember[task.Name] = task.Replicas } + } - pg := &scheduling.PodGroup{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: job.Namespace, - //add job.UID into its name when create new PodGroup - Name: pgName, - Annotations: job.Annotations, - Labels: job.Labels, - OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(job, helpers.JobKind), - }, + pg := &scheduling.PodGroup{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: job.Namespace, + //add job.UID into its name when create new PodGroup + Name: pgName, + Annotations: job.Annotations, + Labels: job.Labels, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(job, helpers.JobKind), }, - Spec: scheduling.PodGroupSpec{ - MinMember: job.Spec.MinAvailable, - MinTaskMember: minTaskMember, - Queue: job.Spec.Queue, - MinResources: cc.calcPGMinResources(job), - PriorityClassName: job.Spec.PriorityClassName, - }, - } + }, + Spec: scheduling.PodGroupSpec{ + MinMember: job.Spec.MinAvailable, + MinTaskMember: minTaskMember, + Queue: job.Spec.Queue, + MinResources: cc.calcPGMinResources(job), + PriorityClassName: job.Spec.PriorityClassName, + }, + } - if _, err = cc.vcClient.SchedulingV1beta1().PodGroups(job.Namespace).Create(context.TODO(), pg, metav1.CreateOptions{}); err != nil { - if !apierrors.IsAlreadyExists(err) { - klog.Errorf("Failed to create PodGroup for Job <%s/%s>: %v", - job.Namespace, job.Name, err) - return err - } + if _, err = cc.vcClient.SchedulingV1beta1().PodGroups(job.Namespace).Create(context.TODO(), pg, metav1.CreateOptions{}); err != nil { + if !apierrors.IsAlreadyExists(err) { + klog.Errorf("Failed to create PodGroup for Job <%s/%s>: %v", + job.Namespace, job.Name, err) + return err } - return nil } + return nil } }