@@ -13,6 +13,7 @@ import (
13
13
ctrlutils "github.com/openmcp-project/controller-utils/pkg/controller"
14
14
errutils "github.com/openmcp-project/controller-utils/pkg/errors"
15
15
"github.com/openmcp-project/controller-utils/pkg/logging"
16
+ "github.com/openmcp-project/controller-utils/pkg/retry"
16
17
17
18
clustersv1alpha1 "github.com/openmcp-project/openmcp-operator/api/clusters/v1alpha1"
18
19
cconst "github.com/openmcp-project/openmcp-operator/api/clusters/v1alpha1/constants"
@@ -47,12 +48,13 @@ type SchedulingResult struct {
47
48
func (sr * SchedulingResult ) Apply (ctx context.Context , platformClient client.Client ) ([]* clustersv1alpha1.Cluster , errutils.ReasonableError ) {
48
49
errs := errutils .NewReasonableErrorList ()
49
50
res := make ([]* clustersv1alpha1.Cluster , 0 , len (sr .Backup )- len (sr .Delete )+ len (sr .Create ))
51
+ rc := retry .NewRetryingClient (platformClient ).WithMaxAttempts (3 )
50
52
51
53
// patch clusters
52
54
for k , cOld := range sr .Backup {
53
55
updated := cOld
54
56
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 {
56
58
errs .Append (errutils .WithReason (fmt .Errorf ("error patching cluster '%s': %w" , k , err ), cconst .ReasonPlatformClusterInteractionProblem ))
57
59
}
58
60
updated = c
@@ -62,22 +64,22 @@ func (sr *SchedulingResult) Apply(ctx context.Context, platformClient client.Cli
62
64
63
65
// create new clusters
64
66
for _ , c := range sr .Create {
65
- if err := platformClient .Create (ctx , c ); err != nil {
67
+ if err := rc .Create (ctx , c ); err != nil {
66
68
errs .Append (errutils .WithReason (fmt .Errorf ("error creating cluster: %w" , err ), cconst .ReasonPlatformClusterInteractionProblem ))
67
69
}
68
70
res = append (res , c )
69
71
}
70
72
71
73
// delete clusters
72
74
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 {
74
76
errs .Append (errutils .WithReason (fmt .Errorf ("error deleting cluster '%s': %w" , k , err ), cconst .ReasonPlatformClusterInteractionProblem ))
75
77
}
76
78
}
77
79
78
80
// patch reconcile annotation on preemptive requests that need to be rescheduled
79
81
for uid := range sr .Reschedule {
80
- errs .Append (ReschedulePreemptiveRequest (ctx , platformClient , uid ))
82
+ errs .Append (ReschedulePreemptiveRequest (ctx , rc , uid ))
81
83
}
82
84
83
85
return res , errs .Aggregate ()
0 commit comments