Skip to content

Commit

Permalink
fix staticcheck warnings on pkg/controllers
Browse files Browse the repository at this point in the history
Signed-off-by: xovoxy <xilovele@gmail.com>
  • Loading branch information
xovoxy committed Oct 16, 2024
1 parent 320698e commit ddaa721
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
5 changes: 2 additions & 3 deletions pkg/controllers/garbagecollector/garbagecollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"time"

"k8s.io/apimachinery/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -196,7 +195,7 @@ func (gc *gccontroller) processJob(key string) error {
klog.V(4).Infof("Checking if Job %s/%s is ready for cleanup", namespace, name)
// Ignore the Jobs that are already deleted or being deleted, or the ones that don't need clean up.
job, err := gc.jobLister.Jobs(namespace).Get(name)
if errors.IsNotFound(err) {
if apierrors.IsNotFound(err) {
return nil
}
if err != nil {
Expand All @@ -214,7 +213,7 @@ func (gc *gccontroller) processJob(key string) error {
// If TTL is modified before we do this check, we cannot be sure if the TTL truly expires.
// The latest Job may have a different UID, but it's fine because the checks will be run again.
fresh, err := gc.vcClient.BatchV1alpha1().Jobs(namespace).Get(context.TODO(), name, metav1.GetOptions{})
if errors.IsNotFound(err) {
if apierrors.IsNotFound(err) {
return nil
}
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/controllers/job/job_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -137,7 +136,7 @@ func (cc *jobcontroller) killJob(jobInfo *apis.JobInfo, podRetainPhase state.Pha

// Update Job status
newJob, err := cc.vcClient.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(context.TODO(), job, metav1.UpdateOptions{})
if errors.IsNotFound(err) {
if apierrors.IsNotFound(err) {
klog.Errorf("Job %v/%v was not found", job.Namespace, job.Name)
return nil
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/controllers/job/job_controller_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"volcano.sh/apis/pkg/apis/batch/v1alpha1"
batch "volcano.sh/apis/pkg/apis/batch/v1alpha1"
busv1alpha1 "volcano.sh/apis/pkg/apis/bus/v1alpha1"
"volcano.sh/volcano/pkg/controllers/apis"
)
Expand Down Expand Up @@ -1027,10 +1026,10 @@ func TestTaskPriority_CalcPGMin(t *testing.T) {

func TestCalcPGMinResources(t *testing.T) {
jc := newFakeController()
job := &batch.Job{
job := &v1alpha1.Job{
TypeMeta: metav1.TypeMeta{},
Spec: batch.JobSpec{
Tasks: []batch.TaskSpec{
Spec: v1alpha1.JobSpec{
Tasks: []v1alpha1.TaskSpec{
master, worker,
},
},
Expand Down
3 changes: 1 addition & 2 deletions pkg/controllers/jobflow/jobflow_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
flowlister "volcano.sh/apis/pkg/client/listers/flow/v1alpha1"
"volcano.sh/volcano/pkg/controllers/apis"
"volcano.sh/volcano/pkg/controllers/framework"
"volcano.sh/volcano/pkg/controllers/jobflow/state"
jobflowstate "volcano.sh/volcano/pkg/controllers/jobflow/state"
)

Expand Down Expand Up @@ -129,7 +128,7 @@ func (jf *jobflowcontroller) Initialize(opt *framework.ControllerOption) error {

jf.syncHandler = jf.handleJobFlow

state.SyncJobFlow = jf.syncJobFlow
jobflowstate.SyncJobFlow = jf.syncJobFlow
return nil
}

Expand Down

0 comments on commit ddaa721

Please sign in to comment.