Skip to content

Commit

Permalink
Update CLI logging output to be cluster type aware:
Browse files Browse the repository at this point in the history
We have been leaking implementation details around
how we create clusters. While CAPI calls the initial
cluster a workload cluster and then pivots its control plane
objects to make it a management cluster this is an
implementation detail that we shouldn't be exposing to
users.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
  • Loading branch information
jacobweinstock committed May 30, 2024
1 parent dc21cf6 commit acba587
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/eksctl-anywhere/cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er
err = createWorkloadCluster.Run(ctx, clusterSpec, createValidations)

} else if clusterSpec.Cluster.IsSelfManaged() {
logger.Info("Using the new workflow using the controller for management cluster create")
logger.V(1).Info("Using the eksa controller to create the management cluster")

createMgmtCluster := management.NewCreate(
deps.Bootstrapper,
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflows/management/create_install_eksa.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *installEksaComponentsOnWorkloadTask) Run(ctx context.Context, commandCo
commandContext.ClusterSpec.Cluster.ClearTinkerbellIPAnnotation()
}

logger.Info("Installing EKS-A custom components on workload cluster")
logger.Info("Installing EKS-A custom components on the management cluster")

err := installEKSAComponents(ctx, commandContext, commandContext.WorkloadCluster)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflows/management/create_move_capi.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (s *moveClusterManagementTask) Run(ctx context.Context, commandContext *tas
return &workflows.CollectDiagnosticsTask{}
}

logger.Info("Moving cluster management from bootstrap to workload cluster")
logger.Info("Moving the cluster management components from the bootstrap cluster to the management cluster")
err = commandContext.ClusterManager.MoveCAPI(ctx, commandContext.BootstrapCluster, commandContext.WorkloadCluster, commandContext.WorkloadCluster.Name, commandContext.ClusterSpec, types.WithNodeRef())
if err != nil {
commandContext.SetError(err)
Expand Down
11 changes: 8 additions & 3 deletions pkg/workflows/management/create_workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package management

import (
"context"
"fmt"

"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/logger"
Expand All @@ -13,7 +14,11 @@ import (
type createWorkloadClusterTask struct{}

func (s *createWorkloadClusterTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task {
logger.Info("Creating new workload cluster")
clusterType := "workload"
if commandContext.ClusterSpec.Cluster.Name == commandContext.ClusterSpec.ManagementCluster.Name {
clusterType = "management"
}
logger.Info(fmt.Sprintf("Creating new %s cluster", clusterType))

commandContext.ClusterSpec.Cluster.AddManagedByCLIAnnotation()
commandContext.ClusterSpec.Cluster.SetManagementComponentsVersion(commandContext.ClusterSpec.EKSARelease.Spec.Version)
Expand Down Expand Up @@ -45,15 +50,15 @@ func (s *createWorkloadClusterTask) Run(ctx context.Context, commandContext *tas
return &workflows.CollectDiagnosticsTask{}
}

logger.Info("Installing cluster-api providers on workload cluster")
logger.Info(fmt.Sprintf("Installing cluster-api providers on %s cluster", clusterType))
managementComponents := cluster.ManagementComponentsFromBundles(commandContext.ClusterSpec.Bundles)
err = commandContext.ClusterManager.InstallCAPI(ctx, managementComponents, commandContext.ClusterSpec, commandContext.WorkloadCluster, commandContext.Provider)
if err != nil {
commandContext.SetError(err)
return &workflows.CollectDiagnosticsTask{}
}

logger.Info("Installing EKS-A secrets on workload cluster")
logger.Info(fmt.Sprintf("Installing EKS-A secrets on %s cluster", clusterType))
err = commandContext.Provider.UpdateSecrets(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec)
if err != nil {
commandContext.SetError(err)
Expand Down

0 comments on commit acba587

Please sign in to comment.