diff --git a/api/v1/runtime_types.go b/api/v1/runtime_types.go index 13e510fd..c0847732 100644 --- a/api/v1/runtime_types.go +++ b/api/v1/runtime_types.go @@ -241,10 +241,10 @@ func (k *Runtime) UpdateStateDeletion(c RuntimeConditionType, r RuntimeCondition } func (k *Runtime) UpdateStatePending(c RuntimeConditionType, r RuntimeConditionReason, status, msg string) { - if status != "False" { - k.Status.State = RuntimeStatePending - } else { + if status == "False" { k.Status.State = RuntimeStateFailed + } else { + k.Status.State = RuntimeStatePending } condition := metav1.Condition{ diff --git a/internal/controller/runtime/fsm/runtime_fsm_waiting_shoot_creation.go b/internal/controller/runtime/fsm/runtime_fsm_waiting_shoot_creation.go index 7df15da6..0d7564d0 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_waiting_shoot_creation.go +++ b/internal/controller/runtime/fsm/runtime_fsm_waiting_shoot_creation.go @@ -31,6 +31,16 @@ func sFnWaitForShootCreation(_ context.Context, m *fsm, s *systemState) (stateFn switch s.shoot.Status.LastOperation.State { case gardener.LastOperationStateProcessing, gardener.LastOperationStatePending, gardener.LastOperationStateAborted, gardener.LastOperationStateError: + if stateNoMatchingSeeds(s.shoot) { + m.log.Info(fmt.Sprintf("Shoot %s has no matching seeds, setting error state", s.shoot.Name)) + s.instance.UpdateStatePending( + imv1.ConditionTypeRuntimeProvisioned, + imv1.ConditionReasonCreationError, + "False", + "Shoot creation failed, no matching seeds") + return updateStatusAndStop() + } + m.log.Info(fmt.Sprintf("Shoot %s is in %s state, scheduling for retry", s.shoot.Name, s.shoot.Status.LastOperation.State)) s.instance.UpdateStatePending( @@ -81,3 +91,14 @@ func sFnWaitForShootCreation(_ context.Context, m *fsm, s *systemState) (stateFn return stopWithMetrics() } } + +func stateNoMatchingSeeds(shoot *gardener.Shoot) bool { + if shoot == nil { + return false + } + + var seedsCount int + var provider string + _, err := fmt.Sscanf(shoot.Status.LastOperation.Description, "Failed to schedule Shoot: none out of the %d seeds has a matching provider for %q", &seedsCount, &provider) + return err == nil +}