Skip to content

Commit

Permalink
Merge pull request #532 from VOID404/error-on-bad-seed
Browse files Browse the repository at this point in the history
Set error state, if seed doesn't exist in required region
  • Loading branch information
kyma-bot authored Nov 29, 2024
2 parents ef44cc6 + 3117d60 commit 53b3536
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/v1/runtime_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
}

0 comments on commit 53b3536

Please sign in to comment.