Skip to content

Commit 12ef821

Browse files
committed
MGMT-18437: Add consumer label when creating ACI
To identify this cluster is being used by the CAPI Openshift Assisted controllers, we'll add the consumer label on the AgentClusterInstall with the value set to this controller's name.
1 parent c1efe86 commit 12ef821

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

controlplane/internal/controller/clusterdeployment_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ func (r *ClusterDeploymentReconciler) computeAgentClusterInstall(
247247
ManifestsConfigMapRefs: additionalManifests,
248248
},
249249
}
250+
aci.Labels[hiveext.ClusterConsumerLabel] = openshiftAssistedControlPlaneKind
250251

251252
if len(acp.Spec.Config.APIVIPs) > 0 && len(acp.Spec.Config.IngressVIPs) > 0 {
252253
aci.Spec.APIVIPs = acp.Spec.Config.APIVIPs

controlplane/internal/controller/clusterdeployment_controller_test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var _ = Describe("ClusterDeployment Controller", func() {
104104
cluster := utils.NewCluster(clusterName, namespace)
105105
Expect(k8sClient.Create(ctx, cluster)).To(Succeed())
106106

107-
cd := utils.NewClusterDeployment(namespace, clusterDeploymentName)
107+
cd := utils.NewClusterDeploymentWithOwnerCluster(namespace, clusterDeploymentName, clusterName)
108108
Expect(k8sClient.Create(ctx, cd)).To(Succeed())
109109

110110
enableOn := models.DiskEncryptionEnableOnAll
@@ -156,6 +156,16 @@ var _ = Describe("ClusterDeployment Controller", func() {
156156
Expect(aci.Spec.MastersSchedulable).To(Equal(oacp.Spec.Config.MastersSchedulable))
157157
Expect(aci.Spec.SSHPublicKey).To(Equal(oacp.Spec.Config.SSHAuthorizedKey))
158158

159+
// Assert ACI has correct labels
160+
Expect(aci.Labels).NotTo(BeEmpty())
161+
Expect(aci.Labels).To(HaveKey(clusterv1.ClusterNameLabel))
162+
Expect(aci.Labels[clusterv1.ClusterNameLabel]).To(Equal(clusterName))
163+
Expect(aci.Labels).To(HaveKey(clusterv1.MachineControlPlaneLabel))
164+
Expect(aci.Labels).To(HaveKey(clusterv1.MachineControlPlaneNameLabel))
165+
Expect(aci.Labels[clusterv1.MachineControlPlaneNameLabel]).To(Equal(oacp.Name))
166+
Expect(aci.Labels).To(HaveKey(hiveext.ClusterConsumerLabel))
167+
Expect(aci.Labels[hiveext.ClusterConsumerLabel]).To(Equal(openshiftAssistedControlPlaneKind))
168+
159169
clusterImageSet := &hivev1.ClusterImageSet{}
160170
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: cd.Name}, clusterImageSet)).To(Succeed())
161171
Expect(clusterImageSet.Spec.ReleaseImage).To(Equal("quay.io/openshift-release-dev/ocp-release:4.16.0-multi"))

0 commit comments

Comments
 (0)