Skip to content

Commit

Permalink
Set SeedSystemComponentsHealthy and Bootstrapped seed conditions …
Browse files Browse the repository at this point in the history
…to `Progressing` on seed reconciliations. (gardener#5995)

* Remove unsued variables

* Make SeedSystemComponentsHealthy Failed or Progressing if a resource cannot be found

* Add seed health check unit test

* Set SeedSystemComponentsHealthy and Bootstrap conditions to progressing on seed reconciliation

* Increase seed controller syncPeriod to 15m

* Apply review comments

* Apply review comments

* Revert seed controller syncPeriod to 1m
  • Loading branch information
plkokanov authored and Kristiyan Gostev committed Jul 5, 2022
1 parent 1df4eb2 commit bb66879
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 19 deletions.
2 changes: 2 additions & 0 deletions charts/gardener/gardenlet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ global:
# - production
seed:
concurrentSyncs: 5
# TODO (plkokanov): the sync period is currently set to 1m because of the way that SNI detection is done during seed reconciliations.
# ref: https://github.com/gardener/gardener/issues/6036
syncPeriod: 1m
# leaseResyncSeconds: 2
# leaseResyncMissThreshold: 10
Expand Down
2 changes: 2 additions & 0 deletions example/20-componentconfig-gardenlet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ controllers:
syncPeriod: 30s
seed:
concurrentSyncs: 5
# TODO (plkokanov): the sync period is currently set to 1m because of the way that SNI detection is done during seed reconciliations.
# ref: https://github.com/gardener/gardener/issues/6036
syncPeriod: 1m
# leaseResyncSeconds: 2
# leaseResyncMissThreshold: 10
Expand Down
10 changes: 0 additions & 10 deletions pkg/gardenlet/controller/seed/seed_care_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,10 @@ func (r *careReconciler) care(ctx context.Context, gardenClientSet client.Client
return nil // We do not want to run in the exponential backoff for the condition checks.
}

seedObj, err := NewSeed(careCtx, seed)
if err != nil {
log.Error(err, "SeedObj cannot be constructed")
if err := careSetupFailure(ctx, gardenClientSet, seed, "seedObj cannot be constructed", conditions); err != nil {
log.Error(err, "Unable to create error condition")
}
return nil
}

// Trigger health check
seedHealth := NewHealthCheck(seed, seedClient.Client())
updatedConditions := seedHealth.CheckSeed(
careCtx,
seedObj,
conditions,
r.conditionThresholdsToProgressingMapping(),
)
Expand Down
2 changes: 0 additions & 2 deletions pkg/gardenlet/controller/seed/seed_care_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
fakeclientset "github.com/gardener/gardener/pkg/client/kubernetes/fake"
"github.com/gardener/gardener/pkg/gardenlet/apis/config"
. "github.com/gardener/gardener/pkg/gardenlet/controller/seed"
seedpkg "github.com/gardener/gardener/pkg/operation/seed"
kutil "github.com/gardener/gardener/pkg/utils/kubernetes"
"github.com/gardener/gardener/pkg/utils/test"

Expand Down Expand Up @@ -249,7 +248,6 @@ func healthCheckFunc(fn resultingConditionFunc) NewHealthCheckFunc {
}

func (c resultingConditionFunc) CheckSeed(_ context.Context,
seed *seedpkg.Seed,
conditions []gardencorev1beta1.Condition,
thresholdMappings map[gardencorev1beta1.ConditionType]time.Duration) []gardencorev1beta1.Condition {
return c(conditions)
Expand Down
2 changes: 1 addition & 1 deletion pkg/gardenlet/controller/seed/seed_care_control_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ var defaultNewHealthCheck NewHealthCheckFunc = func(seed *gardencorev1beta1.Seed

// HealthCheck is an interface used to perform health checks.
type HealthCheck interface {
CheckSeed(ctx context.Context, seed *seedpkg.Seed, condition []gardencorev1beta1.Condition, thresholdMappings map[gardencorev1beta1.ConditionType]time.Duration) []gardencorev1beta1.Condition
CheckSeed(ctx context.Context, condition []gardencorev1beta1.Condition, thresholdMappings map[gardencorev1beta1.ConditionType]time.Duration) []gardencorev1beta1.Condition
}
15 changes: 14 additions & 1 deletion pkg/gardenlet/controller/seed/seed_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ func (r *reconciler) reconcile(ctx context.Context, gardenClient client.Client,
return err
}

conditionSeedBootstrapped = gardencorev1beta1helper.UpdatedCondition(conditionSeedBootstrapped, gardencorev1beta1.ConditionProgressing, "BootstrapProgressing", "Seed cluster is currently being bootstrapped.")
if err = r.patchSeedStatus(ctx, gardenClient, log, seed, seedKubernetesVersion, capacity, allocatable, conditionSeedBootstrapped); err != nil {
return fmt.Errorf("could not update status of %s condition to %s: %w", conditionSeedBootstrapped.Type, gardencorev1beta1.ConditionProgressing, err)
}

// Bootstrap the Seed cluster.
if err := seedpkg.RunReconcileSeedFlow(ctx, gardenClient, seedClientSet, seedObj, gardenSecrets, r.imageVector, r.componentImageVectors, r.config.DeepCopy(), log); err != nil {
conditionSeedBootstrapped = gardencorev1beta1helper.UpdatedCondition(conditionSeedBootstrapped, gardencorev1beta1.ConditionFalse, "BootstrappingFailed", err.Error())
Expand All @@ -327,8 +332,16 @@ func (r *reconciler) reconcile(ctx context.Context, gardenClient client.Client,
return err
}

// Set the status of SeedSystemComponentsHealthy condition to Progressing so that the Seed does not immediately become ready
// after being successfully bootstrapped in case the system components got updated. The SeedSystemComponentsHealthy condition
// will be set to either True, False or Progressing by the seed care reconciler depending on the health of the system components
// after the necessary checks are completed.
conditionSeedSystemComponentsHealthy := gardencorev1beta1helper.GetOrInitCondition(seed.Status.Conditions, gardencorev1beta1.SeedSystemComponentsHealthy)
conditionSeedSystemComponentsHealthy = gardencorev1beta1helper.UpdatedCondition(conditionSeedSystemComponentsHealthy, gardencorev1beta1.ConditionProgressing, "SystemComponentsCheckProgressing", "Pending health check of system components after successful bootstrap of seed cluster.")
conditionSeedBootstrapped = gardencorev1beta1helper.UpdatedCondition(conditionSeedBootstrapped, gardencorev1beta1.ConditionTrue, "BootstrappingSucceeded", "Seed cluster has been bootstrapped successfully.")
_ = r.patchSeedStatus(ctx, gardenClient, log, seed, seedKubernetesVersion, capacity, allocatable, conditionSeedBootstrapped)
if err = r.patchSeedStatus(ctx, gardenClient, log, seed, seedKubernetesVersion, capacity, allocatable, conditionSeedBootstrapped, conditionSeedSystemComponentsHealthy); err != nil {
return fmt.Errorf("could not update status of %s condition to %s and %s conditions to %s: %w", conditionSeedBootstrapped.Type, gardencorev1beta1.ConditionTrue, conditionSeedSystemComponentsHealthy.Type, gardencorev1beta1.ConditionProgressing, err)
}

if seed.Spec.Backup != nil {
// This should be post updating the seed is available. Since, scheduler will then mostly use
Expand Down
7 changes: 5 additions & 2 deletions pkg/operation/care/seed_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
"github.com/gardener/gardener/pkg/operation/botanist/component/nginxingress"
"github.com/gardener/gardener/pkg/operation/botanist/component/seedadmissioncontroller"
"github.com/gardener/gardener/pkg/operation/botanist/component/vpa"
seedpkg "github.com/gardener/gardener/pkg/operation/seed"
kutil "github.com/gardener/gardener/pkg/utils/kubernetes"

apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -62,7 +62,6 @@ func NewHealthForSeed(seed *gardencorev1beta1.Seed, seedClient client.Client) *S

// CheckSeed conducts the health checks on all the given conditions.
func (h *SeedHealth) CheckSeed(ctx context.Context,
seed *seedpkg.Seed,
conditions []gardencorev1beta1.Condition,
thresholdMappings map[gardencorev1beta1.ConditionType]time.Duration) []gardencorev1beta1.Condition {

Expand Down Expand Up @@ -101,6 +100,10 @@ func (h *SeedHealth) checkSeedSystemComponents(
for _, name := range managedResources {
mr := &resourcesv1alpha1.ManagedResource{}
if err := h.seedClient.Get(ctx, kutil.Key(v1beta1constants.GardenNamespace, name), mr); err != nil {
if apierrors.IsNotFound(err) {
exitCondition := checker.FailedCondition(condition, "ResourceNotFound", err.Error())
return &exitCondition, nil
}
return nil, err
}

Expand Down
Loading

0 comments on commit bb66879

Please sign in to comment.