Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch mgmtv3 cluster name to prevent v1 provisioning #676

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/controllers/import_controller_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (r *CAPIImportManagementV3Reconciler) reconcileNormal(ctx context.Context,
newCluster := &managementv3.Cluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: capiCluster.Namespace,
GenerateName: "c-",
GenerateName: capiCluster.Name,
Labels: map[string]string{
capiClusterOwner: capiCluster.Name,
capiClusterOwnerNamespace: capiCluster.Namespace,
Expand Down
22 changes: 11 additions & 11 deletions internal/controllers/import_controller_v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
rancherCluster = &managementv3.Cluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: capiCluster.Namespace,
GenerateName: "c-",
GenerateName: capiCluster.Name,
Labels: map[string]string{
capiClusterOwner: capiCluster.Name,
capiClusterOwnerNamespace: capiCluster.Namespace,
Expand Down Expand Up @@ -196,7 +196,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
Eventually(ctx, func(g Gomega) {
g.Expect(cl.List(ctx, rancherClusters, selectors...)).ToNot(HaveOccurred())
g.Expect(rancherClusters.Items).To(HaveLen(1))
g.Expect(rancherClusters.Items[0].Name).To(ContainSubstring("c-"))
g.Expect(rancherClusters.Items[0].Name).To(ContainSubstring(capiCluster.Name))
g.Expect(rancherClusters.Items[0].Labels).To(HaveKeyWithValue(testLabelName, testLabelVal))
g.Expect(rancherClusters.Items[0].Finalizers).To(ContainElement(managementv3.CapiClusterFinalizer))
}).Should(Succeed())
Expand Down Expand Up @@ -227,7 +227,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
g.Expect(cl.List(ctx, rancherClusters, selectors...)).ToNot(HaveOccurred())
g.Expect(rancherClusters.Items).To(HaveLen(1))
}).Should(Succeed())
Expect(rancherClusters.Items[0].Name).To(ContainSubstring("c-"))
Expect(rancherClusters.Items[0].Name).To(ContainSubstring(capiCluster.Name))
})

It("should reconcile a CAPI cluster when rancher cluster exists, and have finalizers set", func() {
Expand All @@ -254,7 +254,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
g.Expect(rancherClusters.Items[0].Finalizers).ToNot(ContainElement(managementv3.CapiClusterFinalizer))
}).Should(Succeed())
cluster := rancherClusters.Items[0]
Expect(cluster.Name).To(ContainSubstring("c-"))
Expect(cluster.Name).To(ContainSubstring(capiCluster.Name))

clusterRegistrationToken.Name = cluster.Name
clusterRegistrationToken.Namespace = cluster.Name
Expand Down Expand Up @@ -297,7 +297,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {

g.Expect(cl.List(ctx, rancherClusters, selectors...)).ToNot(HaveOccurred())
g.Expect(rancherClusters.Items).To(HaveLen(1))
g.Expect(rancherClusters.Items[0].Name).To(ContainSubstring("c-"))
g.Expect(rancherClusters.Items[0].Name).To(ContainSubstring(capiCluster.Name))
g.Expect(rancherClusters.Items[0].Labels).To(HaveKeyWithValue(testLabelName, testLabelVal))
g.Expect(rancherClusters.Items[0].Finalizers).To(ContainElement(managementv3.CapiClusterFinalizer))
}, 10*time.Second).Should(Succeed())
Expand All @@ -314,7 +314,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
g.Expect(rancherClusters.Items).To(HaveLen(1))
}).Should(Succeed())
cluster := rancherClusters.Items[0]
Expect(cluster.Name).To(ContainSubstring("c-"))
Expect(cluster.Name).To(ContainSubstring(capiCluster.Name))

_, err := testEnv.CreateNamespaceWithName(ctx, cluster.Name)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -343,7 +343,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
g.Expect(rancherClusters.Items).To(HaveLen(1))
}).Should(Succeed())
cluster := rancherClusters.Items[0]
Expect(cluster.Name).To(ContainSubstring("c-"))
Expect(cluster.Name).To(ContainSubstring(capiCluster.Name))

conditions.Set(&cluster, conditions.TrueCondition(managementv3.ClusterConditionReady))
Expect(conditions.IsTrue(&cluster, managementv3.ClusterConditionReady)).To(BeTrue())
Expand Down Expand Up @@ -378,7 +378,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
g.Expect(rancherClusters.Items).To(HaveLen(1))
}).Should(Succeed())
cluster := rancherClusters.Items[0]
Expect(cluster.Name).To(ContainSubstring("c-"))
Expect(cluster.Name).To(ContainSubstring(capiCluster.Name))

clusterRegistrationToken.Name = cluster.Name
clusterRegistrationToken.Namespace = cluster.Name
Expand Down Expand Up @@ -421,7 +421,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
g.Expect(rancherClusters.Items).To(HaveLen(1))
}).Should(Succeed())
cluster := rancherClusters.Items[0]
Expect(cluster.Name).To(ContainSubstring("c-"))
Expect(cluster.Name).To(ContainSubstring(capiCluster.Name))

clusterRegistrationToken.Name = cluster.Name
clusterRegistrationToken.Namespace = cluster.Name
Expand Down Expand Up @@ -455,7 +455,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
g.Expect(rancherClusters.Items).To(HaveLen(1))
}).Should(Succeed())
cluster := rancherClusters.Items[0]
Expect(cluster.Name).To(ContainSubstring("c-"))
Expect(cluster.Name).To(ContainSubstring(capiCluster.Name))

clusterRegistrationToken.Name = cluster.Name
clusterRegistrationToken.Namespace = cluster.Name
Expand Down Expand Up @@ -514,7 +514,7 @@ var _ = Describe("reconcile CAPI Cluster", func() {
g.Expect(cl.List(ctx, rancherClusters, selectors...)).ToNot(HaveOccurred())
g.Expect(rancherClusters.Items).To(HaveLen(1))
}).Should(Succeed())
Expect(rancherClusters.Items[0].Name).To(ContainSubstring("c-"))
Expect(rancherClusters.Items[0].Name).To(ContainSubstring(capiCluster.Name))
Expect(rancherClusters.Items[0].Labels).To(HaveKeyWithValue(testLabelName, testLabelVal))
})

Expand Down
Loading