From 43fa1902ce29e313fb9a91cc060a0f49ff60253c Mon Sep 17 00:00:00 2001 From: Mykhailo Bobrovskyi Date: Thu, 11 Jul 2024 23:50:54 +0300 Subject: [PATCH] Use patch instead of update on jobframework multikueue adapters. --- pkg/controller/jobs/job/job_multikueue_adapter.go | 14 +++++++++----- .../jobs/jobset/jobset_multikueue_adapter.go | 7 +++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/controller/jobs/job/job_multikueue_adapter.go b/pkg/controller/jobs/job/job_multikueue_adapter.go index 136cb93eaa..3d00b5a380 100644 --- a/pkg/controller/jobs/job/job_multikueue_adapter.go +++ b/pkg/controller/jobs/job/job_multikueue_adapter.go @@ -35,6 +35,7 @@ import ( "sigs.k8s.io/kueue/pkg/controller/jobframework" "sigs.k8s.io/kueue/pkg/features" "sigs.k8s.io/kueue/pkg/util/api" + clientutil "sigs.k8s.io/kueue/pkg/util/client" ) type multikueueAdapter struct{} @@ -57,8 +58,10 @@ func (b *multikueueAdapter) SyncJob(ctx context.Context, localClient client.Clie // the remote job exists if err == nil { if features.Enabled(features.MultiKueueBatchJobWithManagedBy) { - localJob.Status = remoteJob.Status - return localClient.Status().Update(ctx, &localJob) + return clientutil.PatchStatus(ctx, localClient, &localJob, func() (bool, error) { + localJob.Status = remoteJob.Status + return true, nil + }) } remoteFinished := false for _, c := range remoteJob.Status.Conditions { @@ -67,10 +70,11 @@ func (b *multikueueAdapter) SyncJob(ctx context.Context, localClient client.Clie break } } - if remoteFinished { - localJob.Status = remoteJob.Status - return localClient.Status().Update(ctx, &localJob) + return clientutil.PatchStatus(ctx, localClient, &localJob, func() (bool, error) { + localJob.Status = remoteJob.Status + return true, nil + }) } return nil } diff --git a/pkg/controller/jobs/jobset/jobset_multikueue_adapter.go b/pkg/controller/jobs/jobset/jobset_multikueue_adapter.go index 59a71698e5..895b6ca039 100644 --- a/pkg/controller/jobs/jobset/jobset_multikueue_adapter.go +++ b/pkg/controller/jobs/jobset/jobset_multikueue_adapter.go @@ -33,6 +33,7 @@ import ( "sigs.k8s.io/kueue/pkg/controller/constants" "sigs.k8s.io/kueue/pkg/controller/jobframework" "sigs.k8s.io/kueue/pkg/util/api" + clientutil "sigs.k8s.io/kueue/pkg/util/client" ) type multikueueAdapter struct{} @@ -54,8 +55,10 @@ func (b *multikueueAdapter) SyncJob(ctx context.Context, localClient client.Clie // if the remote exists, just copy the status if err == nil { - localJob.Status = remoteJob.Status - return localClient.Status().Update(ctx, &localJob) + return clientutil.PatchStatus(ctx, localClient, &localJob, func() (bool, error) { + localJob.Status = remoteJob.Status + return true, nil + }) } remoteJob = jobset.JobSet{