Skip to content

Commit 691569c

Browse files
committed
use retrying client for applying the schedule result
1 parent c2a14dd commit 691569c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

internal/controllers/scheduler/schedule.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
ctrlutils "github.com/openmcp-project/controller-utils/pkg/controller"
1414
errutils "github.com/openmcp-project/controller-utils/pkg/errors"
1515
"github.com/openmcp-project/controller-utils/pkg/logging"
16+
"github.com/openmcp-project/controller-utils/pkg/retry"
1617

1718
clustersv1alpha1 "github.com/openmcp-project/openmcp-operator/api/clusters/v1alpha1"
1819
cconst "github.com/openmcp-project/openmcp-operator/api/clusters/v1alpha1/constants"
@@ -47,12 +48,13 @@ type SchedulingResult struct {
4748
func (sr *SchedulingResult) Apply(ctx context.Context, platformClient client.Client) ([]*clustersv1alpha1.Cluster, errutils.ReasonableError) {
4849
errs := errutils.NewReasonableErrorList()
4950
res := make([]*clustersv1alpha1.Cluster, 0, len(sr.Backup)-len(sr.Delete)+len(sr.Create))
51+
rc := retry.NewRetryingClient(platformClient).WithMaxAttempts(3)
5052

5153
// patch clusters
5254
for k, cOld := range sr.Backup {
5355
updated := cOld
5456
if c, ok := sr.Patch[k]; ok {
55-
if err := platformClient.Patch(ctx, c, client.MergeFrom(cOld)); err != nil {
57+
if err := rc.Patch(ctx, c, client.MergeFrom(cOld)); err != nil {
5658
errs.Append(errutils.WithReason(fmt.Errorf("error patching cluster '%s': %w", k, err), cconst.ReasonPlatformClusterInteractionProblem))
5759
}
5860
updated = c
@@ -62,22 +64,22 @@ func (sr *SchedulingResult) Apply(ctx context.Context, platformClient client.Cli
6264

6365
// create new clusters
6466
for _, c := range sr.Create {
65-
if err := platformClient.Create(ctx, c); err != nil {
67+
if err := rc.Create(ctx, c); err != nil {
6668
errs.Append(errutils.WithReason(fmt.Errorf("error creating cluster: %w", err), cconst.ReasonPlatformClusterInteractionProblem))
6769
}
6870
res = append(res, c)
6971
}
7072

7173
// delete clusters
7274
for k, c := range sr.Delete {
73-
if err := platformClient.Delete(ctx, c); client.IgnoreNotFound(err) != nil {
75+
if err := rc.Delete(ctx, c); client.IgnoreNotFound(err) != nil {
7476
errs.Append(errutils.WithReason(fmt.Errorf("error deleting cluster '%s': %w", k, err), cconst.ReasonPlatformClusterInteractionProblem))
7577
}
7678
}
7779

7880
// patch reconcile annotation on preemptive requests that need to be rescheduled
7981
for uid := range sr.Reschedule {
80-
errs.Append(ReschedulePreemptiveRequest(ctx, platformClient, uid))
82+
errs.Append(ReschedulePreemptiveRequest(ctx, rc, uid))
8183
}
8284

8385
return res, errs.Aggregate()

0 commit comments

Comments
 (0)