diff --git a/apinetlet/controllers/network_controller_test.go b/apinetlet/controllers/network_controller_test.go index 6fc8d99..90743b8 100644 --- a/apinetlet/controllers/network_controller_test.go +++ b/apinetlet/controllers/network_controller_test.go @@ -201,6 +201,7 @@ var _ = Describe("NetworkController", func() { By("patching apinet network peering status") apiNetNetwork2ID, _ := strconv.Atoi(apiNetNetwork2.Spec.ID) Eventually(UpdateStatus(apiNetNetwork1, func() { + apiNetNetwork1.Status.Peerings = make(map[string][]apinetv1alpha1.NetworkPeeringStatus) apiNetNetwork1.Status.Peerings["partition1"] = []apinetv1alpha1.NetworkPeeringStatus{{ ID: int32(apiNetNetwork2ID), State: apinetv1alpha1.NetworkPeeringStateReady, @@ -209,6 +210,7 @@ var _ = Describe("NetworkController", func() { apiNetNetwork1ID, _ := strconv.Atoi(apiNetNetwork1.Spec.ID) Eventually(UpdateStatus(apiNetNetwork2, func() { + apiNetNetwork2.Status.Peerings = make(map[string][]apinetv1alpha1.NetworkPeeringStatus) apiNetNetwork2.Status.Peerings["partition1"] = []apinetv1alpha1.NetworkPeeringStatus{{ ID: int32(apiNetNetwork1ID), State: apinetv1alpha1.NetworkPeeringStateReady, @@ -377,6 +379,7 @@ var _ = Describe("NetworkController", func() { By("patching apinet network peering status") apiNetNetwork2ID, _ := strconv.Atoi(apiNetNetwork2.Spec.ID) Eventually(UpdateStatus(apiNetNetwork1, func() { + apiNetNetwork1.Status.Peerings = make(map[string][]apinetv1alpha1.NetworkPeeringStatus) apiNetNetwork1.Status.Peerings["partition1"] = []apinetv1alpha1.NetworkPeeringStatus{{ ID: int32(apiNetNetwork2ID), State: apinetv1alpha1.NetworkPeeringStateReady, @@ -385,6 +388,7 @@ var _ = Describe("NetworkController", func() { apiNetNetwork1ID, _ := strconv.Atoi(apiNetNetwork1.Spec.ID) Eventually(UpdateStatus(apiNetNetwork2, func() { + apiNetNetwork2.Status.Peerings = make(map[string][]apinetv1alpha1.NetworkPeeringStatus) apiNetNetwork2.Status.Peerings["partition1"] = []apinetv1alpha1.NetworkPeeringStatus{{ ID: int32(apiNetNetwork1ID), State: apinetv1alpha1.NetworkPeeringStateReady, diff --git a/metalnetlet/controllers/network_controller.go b/metalnetlet/controllers/network_controller.go index 42dc78c..afe2865 100644 --- a/metalnetlet/controllers/network_controller.go +++ b/metalnetlet/controllers/network_controller.go @@ -119,7 +119,7 @@ func (r *NetworkReconciler) updateApinetNetworkStatus(ctx context.Context, log l log.V(1).Info("Patching apinet network status", "status", apinetStatusPeerings) networkBase := network.DeepCopy() if network.Status.Peerings == nil { - network.Status.Peerings = make(map[string][]apinetv1alpha1.NetworkPeeringStatus, 0) + network.Status.Peerings = make(map[string][]apinetv1alpha1.NetworkPeeringStatus) } network.Status.Peerings[r.PartitionName] = apinetStatusPeerings if err := r.Status().Patch(ctx, network, client.MergeFrom(networkBase)); err != nil {