diff --git a/api/go.mod b/api/go.mod index 418cfbc..6e989a9 100644 --- a/api/go.mod +++ b/api/go.mod @@ -3,7 +3,7 @@ module github.com/openstack-k8s-operators/placement-operator/api go 1.21 require ( - github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333 + github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241113111931-619091d34655 k8s.io/api v0.29.10 k8s.io/apimachinery v0.29.10 sigs.k8s.io/controller-runtime v0.17.6 diff --git a/api/go.sum b/api/go.sum index d772e59..a6ec40e 100644 --- a/api/go.sum +++ b/api/go.sum @@ -72,8 +72,8 @@ github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= -github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333 h1:yejekTWudX5af3mCJQ1MUPLEa0X6sIsklf07o9KilRk= -github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241113111931-619091d34655 h1:LJ41yZsJrGLm/dTtohV9KqI3eHXaNNC6hGKKw+6OHUM= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241113111931-619091d34655/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/controllers/placementapi_controller.go b/controllers/placementapi_controller.go index 82ce21a..310c648 100644 --- a/controllers/placementapi_controller.go +++ b/controllers/placementapi_controller.go @@ -38,6 +38,7 @@ import ( "github.com/go-logr/logr" keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1" + networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" common "github.com/openstack-k8s-operators/lib-common/modules/common" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" deployment "github.com/openstack-k8s-operators/lib-common/modules/common/deployment" @@ -609,8 +610,9 @@ func (r *PlacementAPIReconciler) ensureNetworkAttachments( var err error // networks to attach to + nadList := []networkv1.NetworkAttachmentDefinition{} for _, netAtt := range instance.Spec.NetworkAttachments { - _, err := nad.GetNADWithName(ctx, h, netAtt, instance.Namespace) + nad, err := nad.GetNADWithName(ctx, h, netAtt, instance.Namespace) if err != nil { if k8s_errors.IsNotFound(err) { r.GetLogger(ctx).Info(fmt.Sprintf("network-attachment-definition %s not found", netAtt)) @@ -630,9 +632,13 @@ func (r *PlacementAPIReconciler) ensureNetworkAttachments( err.Error())) return nadAnnotations, ctrl.Result{}, err } + + if nad != nil { + nadList = append(nadList, *nad) + } } - nadAnnotations, err = nad.CreateNetworksAnnotation(instance.Namespace, instance.Spec.NetworkAttachments) + nadAnnotations, err = nad.EnsureNetworksAnnotation(nadList) if err != nil { return nadAnnotations, ctrl.Result{}, fmt.Errorf("failed create network annotation from %s: %w", instance.Spec.NetworkAttachments, err) diff --git a/go.mod b/go.mod index 0bb5f16..07469aa 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/onsi/ginkgo/v2 v2.20.1 github.com/onsi/gomega v1.34.1 github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241030161253-ca1668251700 - github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333 + github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241113111931-619091d34655 github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241029151503-4878b3fa3333 github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241030161252-c847254d0ef7 github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20240216174613-3d349f26e681 diff --git a/go.sum b/go.sum index 8273fea..04d33b5 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,8 @@ github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6 github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4= github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241030161253-ca1668251700 h1:J1wC1E2seCIedpwpnVbfjR70e99V4siHHKgs8SV7qjc= github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241030161253-ca1668251700/go.mod h1:uJ1wM1Y0VlOUAxVoSyvko+tny3enIoTfc7srS8Lrzts= -github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333 h1:yejekTWudX5af3mCJQ1MUPLEa0X6sIsklf07o9KilRk= -github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241113111931-619091d34655 h1:LJ41yZsJrGLm/dTtohV9KqI3eHXaNNC6hGKKw+6OHUM= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241113111931-619091d34655/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.1-0.20241029151503-4878b3fa3333 h1:XWxFOmOYPC6V5KUDkzU20vQOsha1PPNQzzqkNv926mg= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.1-0.20241029151503-4878b3fa3333/go.mod h1:IASoGvp5QM/tBJUd/8i8uIjj4DBnI+64Ydh4r7pmnvA= github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241029151503-4878b3fa3333 h1:zUlxLqucrLMNDp6dc3I7eYWZyGVE7tLrPyWR/n+VD9w=