Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use patch instead of update on jobframework multikueue adapters. #2590

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pkg/controller/jobs/job/job_multikueue_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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 {
Expand All @@ -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
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/jobs/jobset/jobset_multikueue_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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{
Expand Down