Skip to content

Commit

Permalink
Merge pull request #8610 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…8604-to-release-1.3

[release-1.3] 🐛 Return error on infra cluster and control plane discovery
  • Loading branch information
k8s-ci-robot authored May 4, 2023
2 parents 89923bf + 63fcab2 commit 6a8ee61
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cmd/clusterctl/client/tree/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package tree
import (
"context"

"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down Expand Up @@ -83,9 +84,11 @@ func Discovery(ctx context.Context, c client.Client, namespace, name string, opt
tree := NewObjectTree(cluster, options.toObjectTreeOptions())

// Adds cluster infra
if clusterInfra, err := external.Get(ctx, c, cluster.Spec.InfrastructureRef, cluster.Namespace); err == nil {
tree.Add(cluster, clusterInfra, ObjectMetaName("ClusterInfrastructure"))
clusterInfra, err := external.Get(ctx, c, cluster.Spec.InfrastructureRef, cluster.Namespace)
if err != nil {
return nil, errors.Wrap(err, "get InfraCluster reference from Cluster")
}
tree.Add(cluster, clusterInfra, ObjectMetaName("ClusterInfrastructure"))

if options.ShowClusterResourceSets {
addClusterResourceSetsToObjectTree(ctx, c, cluster, tree)
Expand Down Expand Up @@ -119,9 +122,11 @@ func Discovery(ctx context.Context, c client.Client, namespace, name string, opt
}

controlPlaneMachines := selectControlPlaneMachines(machinesList)
for i := range controlPlaneMachines {
cp := controlPlaneMachines[i]
addMachineFunc(controlPlane, cp)
if controlPlane != nil {
for i := range controlPlaneMachines {
cp := controlPlaneMachines[i]
addMachineFunc(controlPlane, cp)
}
}

machinePoolList, err := getMachinePoolsInCluster(ctx, c, cluster.Namespace, cluster.Name)
Expand Down

0 comments on commit 6a8ee61

Please sign in to comment.