Skip to content

Commit

Permalink
Giving up on the idea of automatically cleanup of the annotation with…
Browse files Browse the repository at this point in the history
… operation start time
  • Loading branch information
koala7659 committed Aug 7, 2024
1 parent 446637d commit 07fcd90
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
10 changes: 10 additions & 0 deletions api/v1/runtime_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,13 @@ func (k *Runtime) HasTimeoutElapsed(timeLimit time.Duration) bool {

return false
}

func (k *Runtime) HasRuntimeOperationTimedOut() bool {
if k.Status.State != RuntimeStateFailed {
return false
}

return k.IsConditionSet(ConditionTypeRuntimeProvisioned, ConditionReasonShootCreationTimeout) ||
k.IsConditionSet(ConditionTypeRuntimeDeprovisioned, ConditionReasonShootDeletionTimeout) ||
k.IsConditionSet(ConditionTypeRuntimeProvisioned, ConditionReasonShootProcessingTimeout)
}
4 changes: 2 additions & 2 deletions internal/controller/runtime/fsm/runtime_fsm_delete_shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func sFnDeleteShoot(ctx context.Context, m *fsm, s *systemState) (stateFn, *ctrl
if !s.shoot.GetDeletionTimestamp().IsZero() {
if s.instance.HasTimeoutElapsed(m.DeprovisionTimeout) {
m.log.Info(fmt.Sprintf("Runtime deprovision timeout for %s", s.shoot.Name))
s.instance.UpdateStateDeletion(imv1.ConditionTypeRuntimeProvisioned, imv1.ConditionReasonShootDeletionTimeout, "False", "Runtime deprovisioning timeout")
return updateStatusAndRequeue() // Requeue to clear annotation
s.instance.UpdateStateDeletion(imv1.ConditionTypeRuntimeDeprovisioned, imv1.ConditionReasonShootDeletionTimeout, "False", "Runtime deprovisioning timeout")
return updateStatusAndStop()
}

m.log.Info("Waiting for shoot to be deleted", "Name", s.shoot.Name, "Namespace", s.shoot.Namespace)
Expand Down
12 changes: 0 additions & 12 deletions internal/controller/runtime/fsm/runtime_fsm_initialise.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ func sFnInitialize(ctx context.Context, m *fsm, s *systemState) (stateFn, *ctrl.
return updateStatusAndRequeue()
}

if s.instance.Status.State == imv1.RuntimeStateFailed || s.instance.Status.State == imv1.RuntimeStateReady {
if s.instance.Annotations != nil {
if val, found := s.instance.Annotations[imv1.AnnotationRuntimeOperationStarted]; found {
if val != "" {
s.instance.Annotations[imv1.AnnotationRuntimeOperationStarted] = ""
m.Update(ctx, &s.instance)
return stop()
}
}
}
}

if instanceIsNotBeingDeleted && s.shoot == nil {
m.log.Info("Gardener shoot does not exist, creating new one")
if !dryRunMode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ func sFnSelectShootProcessing(_ context.Context, m *fsm, s *systemState) (stateF
return updateStatusAndRequeueAfter(gardenerRequeueDuration)
}

if s.instance.Status.State == imv1.RuntimeStateReady && lastOperation.State == gardener.LastOperationStateSucceeded ||
s.instance.Status.State == imv1.RuntimeStateFailed { // to make possible to recover from timeout during previous operation
if s.instance.HasRuntimeOperationTimedOut() {
// recovering from previous operation timeout after manual intervention
m.log.Info("Patching Gardener shoot after previously operation timeout")
return switchState(sFnPatchExistingShoot)
}

if s.instance.Status.State == imv1.RuntimeStateReady && lastOperation.State == gardener.LastOperationStateSucceeded {
// only allow to patch if full previous cycle was completed
m.log.Info("Gardener shoot already exists, updating")
return switchState(sFnPatchExistingShoot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func sFnWaitForShootReconcile(ctx context.Context, m *fsm, s *systemState) (stat
if s.instance.HasTimeoutElapsed(m.UpdateTimeout) {
m.log.Info(fmt.Sprintf("Shoot creation timeout for %s", s.shoot.Name))
s.instance.UpdateStatePending(imv1.ConditionTypeRuntimeProvisioned, imv1.ConditionReasonShootProcessingTimeout, "False", "Shoot reconcile timeout")
return updateStatusAndRequeue() // Requeue to clear annotation
return updateStatusAndStop()
}

switch s.shoot.Status.LastOperation.State {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func sFnWaitForShootCreation(_ context.Context, m *fsm, s *systemState) (stateFn
if s.instance.HasTimeoutElapsed(m.ProvisionTimeout) {
m.log.Info(fmt.Sprintf("Shoot creation timeout for %s", s.shoot.Name))
s.instance.UpdateStatePending(imv1.ConditionTypeRuntimeProvisioned, imv1.ConditionReasonShootCreationTimeout, "False", "Shoot creation timeout")
return updateStatusAndRequeue() // Requeue to clear annotation
return updateStatusAndStop()
}

switch s.shoot.Status.LastOperation.State {
Expand Down

0 comments on commit 07fcd90

Please sign in to comment.