From 74bf83dec4d42f1a38f85fe0ad29515228072e66 Mon Sep 17 00:00:00 2001 From: Rafael Franzke Date: Wed, 14 Sep 2022 13:20:31 +0200 Subject: [PATCH] Drop `botanist.InitializeSeedClient` method The gardenlet will have the seed client always available, no need to initialize it anymore. --- .../controller/shoot/shoot_care_control.go | 10 +--------- pkg/operation/botanist/botanist.go | 4 ---- pkg/operation/operation.go | 20 ------------------- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/pkg/gardenlet/controller/shoot/shoot_care_control.go b/pkg/gardenlet/controller/shoot/shoot_care_control.go index 64369b27e215..71e452ee230a 100644 --- a/pkg/gardenlet/controller/shoot/shoot_care_control.go +++ b/pkg/gardenlet/controller/shoot/shoot_care_control.go @@ -280,15 +280,7 @@ func (r *careReconciler) care(ctx context.Context, log logr.Logger, shoot *garde ) if err != nil { log.Error(err, "Could not initialize a new operation") - if err := patchStatusToUnknown(ctx, gardenClient, shoot, "Precondition failed: operation could not be initialized", conditions, constraints); err != nil { - log.Error(err, "Error when trying to update the shoot status") - } - return nil // We do not want to run in the exponential backoff for the condition checks. - } - - if err := o.InitializeSeedClients(careCtx); err != nil { - log.Error(err, "Could not initialize seed clients") - if err := patchStatusToUnknown(ctx, gardenClient, shoot, "Precondition failed: seed client cannot be constructed", conditions, constraints); err != nil { + if err := patchStatusToUnknown(ctx, r.gardenClient, shoot, "Precondition failed: operation could not be initialized", conditions, constraints); err != nil { log.Error(err, "Error when trying to update the shoot status") } return nil // We do not want to run in the exponential backoff for the condition checks. diff --git a/pkg/operation/botanist/botanist.go b/pkg/operation/botanist/botanist.go index 4d3da741cba4..2faf0c1a1a85 100644 --- a/pkg/operation/botanist/botanist.go +++ b/pkg/operation/botanist/botanist.go @@ -74,10 +74,6 @@ func New(ctx context.Context, o *operation.Operation) (*Botanist, error) { } } - if err = b.InitializeSeedClients(ctx); err != nil { - return nil, err - } - o.SecretsManager, err = secretsmanager.New( ctx, b.Logger.WithName("secretsmanager"), diff --git a/pkg/operation/operation.go b/pkg/operation/operation.go index 336075fe659a..6fb41922c6f6 100644 --- a/pkg/operation/operation.go +++ b/pkg/operation/operation.go @@ -304,23 +304,6 @@ func (b *Builder) Build( return operation, nil } -// InitializeSeedClients will use the Garden Kubernetes client to read the Seed Secret in the Garden -// cluster which contains a Kubeconfig that can be used to authenticate against the Seed cluster. With it, -// a Kubernetes client as well as a Chart renderer for the Seed cluster will be initialized and attached to -// the already existing Operation object. -func (o *Operation) InitializeSeedClients(ctx context.Context) error { - if o.K8sSeedClient != nil { - return nil - } - - seedClient, err := o.ClientMap.GetClient(ctx, keys.ForSeed(o.Seed.GetInfo())) - if err != nil { - return fmt.Errorf("failed to get seed client: %w", err) - } - o.K8sSeedClient = seedClient - return nil -} - // InitializeShootClients will use the Seed Kubernetes client to read the gardener Secret in the Seed // cluster which contains a Kubeconfig that can be used to authenticate against the Shoot cluster. With it, // a Kubernetes client as well as a Chart renderer for the Shoot cluster will be initialized and attached to @@ -574,9 +557,6 @@ func (o *Operation) SaveGardenerResourceDataInShootState(ctx context.Context, f // DeleteClusterResourceFromSeed deletes the `Cluster` extension resource for the shoot in the seed cluster. func (o *Operation) DeleteClusterResourceFromSeed(ctx context.Context) error { - if err := o.InitializeSeedClients(ctx); err != nil { - return fmt.Errorf("could not initialize a new Kubernetes client for the seed cluster: %w", err) - } return client.IgnoreNotFound(o.SeedClientSet.Client().Delete(ctx, &extensionsv1alpha1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: o.Shoot.SeedNamespace}})) }