@@ -107,7 +107,7 @@ var _ = Describe("MetalStackCluster Controller", func() {
107107 resource .Spec = v1alpha1.MetalStackClusterSpec {
108108 ControlPlaneEndpoint : v1alpha1.APIEndpoint {},
109109 ProjectID : "test-project" ,
110- NodeNetworkID : "node-network-id" ,
110+ NodeNetworkID : nil ,
111111 ControlPlaneIP : nil ,
112112 Partition : "test-partition" ,
113113 }
@@ -229,7 +229,7 @@ var _ = Describe("MetalStackCluster Controller", func() {
229229 resource .Spec = v1alpha1.MetalStackClusterSpec {
230230 ControlPlaneEndpoint : v1alpha1.APIEndpoint {},
231231 ProjectID : "test-project" ,
232- NodeNetworkID : "node-network-id" ,
232+ NodeNetworkID : nil ,
233233 ControlPlaneIP : nil ,
234234 Partition : "test-partition" ,
235235 }
@@ -271,11 +271,11 @@ var _ = Describe("MetalStackCluster Controller", func() {
271271 IP : func (m * mock.Mock ) {
272272 m .On ("AllocateIP" , testcommon .MatchIgnoreContext (testingT , metalip .NewAllocateIPParams ().WithBody (& models.V1IPAllocateRequest {
273273 Tags : []string {
274- "cluster.metal-stack.io/id=" + resource .GetClusterID (),
274+ "cluster.metal-stack.io/id=" + resource .GetClusterName (),
275275 "metal-stack.infrastructure.cluster.x-k8s.io/purpose=control-plane" ,
276276 },
277277 Name : resource .Name + "-control-plane" ,
278- Description : resource .GetClusterID () + " control plane ip" ,
278+ Description : resource .GetClusterName () + " control plane ip" ,
279279 Networkid : ptr .To ("internet" ),
280280 Projectid : ptr .To ("test-project" ),
281281 Type : ptr .To ("ephemeral" ),
@@ -286,6 +286,26 @@ var _ = Describe("MetalStackCluster Controller", func() {
286286 }, nil )
287287 },
288288 Network : func (m * mock.Mock ) {
289+ m .On ("AllocateNetwork" , testcommon .MatchIgnoreContext (testingT , metalnetwork .NewAllocateNetworkParams ().WithBody (& models.V1NetworkAllocateRequest {
290+ Name : resource .Name ,
291+ Description : resource .Namespace + "/" + resource .Name ,
292+ Labels : map [string ]string {
293+ "cluster.metal-stack.io/id" : string (resource .UID ),
294+ },
295+ Partitionid : "test-partition" ,
296+ Projectid : "test-project" ,
297+ })), nil ).Return (& metalnetwork.AllocateNetworkCreated {
298+ Payload : & models.V1NetworkResponse {
299+ Labels : map [string ]string {
300+ "cluster.metal-stack.io/id" : string (resource .UID ),
301+ },
302+ Partitionid : "test-partition" ,
303+ Projectid : "test-project" ,
304+ ID : ptr .To ("test-network" ),
305+ Prefixes : []string {"192.168.42.0/24" },
306+ },
307+ }, nil )
308+
289309 m .On ("FindNetworks" , testcommon .MatchIgnoreContext (testingT , metalnetwork .NewFindNetworksParams ().WithBody (& models.V1NetworkFindRequest {
290310 Labels : map [string ]string {
291311 "network.metal-stack.io/default" : "" ,
@@ -325,6 +345,10 @@ var _ = Describe("MetalStackCluster Controller", func() {
325345
326346 Expect (k8sClient .Get (ctx , typeNamespacedName , resource )).To (Succeed ())
327347
348+ Expect (resource .Status .Conditions ).To (ContainElement (MatchFields (IgnoreExtras , Fields {
349+ "Type" : Equal (v1alpha1 .ClusterNodeNetworkEnsured ),
350+ "Status" : Equal (corev1 .ConditionTrue ),
351+ })))
328352 Expect (resource .Status .Conditions ).To (ContainElement (MatchFields (IgnoreExtras , Fields {
329353 "Type" : Equal (v1alpha1 .ClusterControlPlaneIPEnsured ),
330354 "Status" : Equal (corev1 .ConditionTrue ),
@@ -351,7 +375,7 @@ var _ = Describe("MetalStackCluster Controller", func() {
351375 resource .Spec = v1alpha1.MetalStackClusterSpec {
352376 ControlPlaneEndpoint : v1alpha1.APIEndpoint {},
353377 ProjectID : "test-project" ,
354- NodeNetworkID : nodeNetworkID ,
378+ NodeNetworkID : & nodeNetworkID ,
355379 ControlPlaneIP : & controlPlaneIP ,
356380 Partition : "test-partition" ,
357381 }
@@ -402,6 +426,10 @@ var _ = Describe("MetalStackCluster Controller", func() {
402426
403427 return resource .Status .Conditions
404428 }, "20s" ).Should (ContainElements (
429+ MatchFields (IgnoreExtras , Fields {
430+ "Type" : Equal (v1alpha1 .ClusterNodeNetworkEnsured ),
431+ "Status" : Equal (corev1 .ConditionTrue ),
432+ }),
405433 MatchFields (IgnoreExtras , Fields {
406434 "Type" : Equal (v1alpha1 .ClusterControlPlaneIPEnsured ),
407435 "Status" : Equal (corev1 .ConditionTrue ),
@@ -447,6 +475,10 @@ var _ = Describe("MetalStackCluster Controller", func() {
447475
448476 return resource .Status .Conditions
449477 }, "20s" ).Should (ContainElements (
478+ MatchFields (IgnoreExtras , Fields {
479+ "Type" : Equal (v1alpha1 .ClusterNodeNetworkEnsured ),
480+ "Status" : Equal (corev1 .ConditionTrue ),
481+ }),
450482 MatchFields (IgnoreExtras , Fields {
451483 "Type" : Equal (v1alpha1 .ClusterControlPlaneIPEnsured ),
452484 "Status" : Equal (corev1 .ConditionTrue ),
0 commit comments