@@ -25,11 +25,13 @@ package reconcile
25
25
import (
26
26
"context"
27
27
"fmt"
28
+ "time"
28
29
30
+ "github.com/rs/zerolog"
29
31
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30
32
31
33
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
32
- "github.com/rs/zerolog "
34
+ "github.com/arangodb/kube-arangodb/pkg/util/k8sutil "
33
35
)
34
36
35
37
// ExecutePlan tries to execute the plan as far as possible.
@@ -106,7 +108,21 @@ func (d *Reconciler) ExecutePlan(ctx context.Context) (bool, error) {
106
108
}
107
109
log .Debug ().Bool ("ready" , ready ).Msg ("Action CheckProgress completed" )
108
110
if ! ready {
109
- // Not ready check, come back soon
111
+ // Not ready yet, check timeout
112
+ deadline := planAction .CreationTime .Add (action .Timeout ())
113
+ if time .Now ().After (deadline ) {
114
+ // Timeout has expired
115
+ log .Warn ().Msg ("Action not finished in time. Removing the entire plan" )
116
+ d .context .CreateEvent (k8sutil .NewPlanTimeoutEvent (d .context .GetAPIObject (), string (planAction .Type ), planAction .MemberID , planAction .Group .AsRole ()))
117
+ // Replace plan with empty one and save it.
118
+ status .Plan = api.Plan {}
119
+ if err := d .context .UpdateStatus (status ); err != nil {
120
+ log .Debug ().Err (err ).Msg ("Failed to update CR status" )
121
+ return false , maskAny (err )
122
+ }
123
+ return true , nil
124
+ }
125
+ // Timeout not yet expired, come back soon
110
126
return true , nil
111
127
}
112
128
// Continue with next action
0 commit comments