Skip to content

Commit

Permalink
Drop botanist.InitializeSeedClient method
Browse files Browse the repository at this point in the history
The gardenlet will have the seed client always available, no need to initialize it anymore.
  • Loading branch information
rfranzke committed Sep 19, 2022
1 parent 246541e commit 74bf83d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
10 changes: 1 addition & 9 deletions pkg/gardenlet/controller/shoot/shoot_care_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions pkg/operation/botanist/botanist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
20 changes: 0 additions & 20 deletions pkg/operation/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}}))
}

Expand Down

0 comments on commit 74bf83d

Please sign in to comment.