diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 5346d21..41a6354 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -130,14 +130,6 @@ rules: - patch - update - watch -- apiGroups: - - dataplane.openstack.org - resources: - - openstackdataplanenodesets - verbs: - - get - - list - - watch - apiGroups: - k8s.cni.cncf.io resources: diff --git a/controllers/swiftring_controller.go b/controllers/swiftring_controller.go index 9868f0c..6efce67 100644 --- a/controllers/swiftring_controller.go +++ b/controllers/swiftring_controller.go @@ -22,11 +22,14 @@ import ( "time" "github.com/go-logr/logr" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" "github.com/openstack-k8s-operators/lib-common/modules/common/condition" @@ -35,7 +38,6 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/common/helper" "github.com/openstack-k8s-operators/lib-common/modules/common/job" - dataplanev1 "github.com/openstack-k8s-operators/dataplane-operator/api/v1beta1" swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" "github.com/openstack-k8s-operators/swift-operator/pkg/swift" "github.com/openstack-k8s-operators/swift-operator/pkg/swiftring" @@ -289,11 +291,25 @@ func (r *SwiftRingReconciler) SetupWithManager(mgr ctrl.Manager) error { return result } + inventoryPredicator, err := predicate.LabelSelectorPredicate( + metav1.LabelSelector{ + MatchLabels: map[string]string{ + "openstack.org/operator-name": "dataplane", + "inventory": "true", + }, + }, + ) + if err != nil { + return err + } + return ctrl.NewControllerManagedBy(mgr). For(&swiftv1beta1.SwiftRing{}). Owns(&batchv1.Job{}). Owns(&corev1.ConfigMap{}). Watches(&swiftv1beta1.SwiftStorage{}, handler.EnqueueRequestsFromMapFunc(swiftRingFilter)). - Watches(&dataplanev1.OpenStackDataPlaneNodeSet{}, handler.EnqueueRequestsFromMapFunc(swiftRingFilter)). + Watches(&corev1.Secret{}, + handler.EnqueueRequestsFromMapFunc(swiftRingFilter), + builder.WithPredicates(inventoryPredicator)). Complete(r) } diff --git a/go.mod b/go.mod index bc7fefd..5e4089f 100644 --- a/go.mod +++ b/go.mod @@ -9,12 +9,13 @@ require ( github.com/onsi/ginkgo/v2 v2.19.0 github.com/onsi/gomega v1.33.1 github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240523081006-98dc23995369 - github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240601165131-290ef03229dc github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240525122647-715f01bb2987 github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240525111221-1e3ee314289c + github.com/openstack-k8s-operators/lib-common/modules/ansible v0.3.1-0.20240603143707-f5c5fe030fdd github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240531085522-94fdcd5ff4fd github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240531085522-94fdcd5ff4fd github.com/openstack-k8s-operators/swift-operator/api v0.3.1-0.20240523121736-379011b2cfac + golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 k8s.io/api v0.28.10 k8s.io/apimachinery v0.28.10 k8s.io/client-go v0.28.10 @@ -24,20 +25,15 @@ require ( require ( github.com/beorn7/perks v1.0.1 // indirect - github.com/cert-manager/cert-manager v1.13.6 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/go-restful/v3 v3.11.2 // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/go-logr/zapr v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.20.2 // indirect github.com/go-openapi/jsonreference v0.20.4 // indirect github.com/go-openapi/swag v0.22.9 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -50,45 +46,19 @@ require ( github.com/imdario/mergo v0.3.16 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/leodido/go-urn v1.4.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/metal3-io/baremetal-operator/apis v0.5.1 // indirect - github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.4.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/openshift/api v3.9.0+incompatible // indirect - github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240529155246-4afc791bbb82 // indirect - github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20240528100324-b8f58a72095b // indirect - github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240602191531-ee2f5310fb97 // indirect - github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240602060615-cab225f2aa04 // indirect - github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20240515093015-9d2609bb0015 // indirect - github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20240523093522-7a25580a799d // indirect - github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240531085522-94fdcd5ff4fd // indirect - github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240602180119-bb1bd220b0ff // indirect - github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240514152407-b2bea62f05db // indirect - github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240531054845-7fa2b6b39520 // indirect - github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20240530073125-ab95f150cbec // indirect - github.com/openstack-k8s-operators/octavia-operator/api v0.3.1-0.20240530121452-c1107b888dd4 // indirect - github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.3.1-0.20240523005930-c332745390c8 // indirect - github.com/openstack-k8s-operators/openstack-operator/apis v0.0.0-20240531084739-3b4c0451297c // indirect - github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20240531062432-734161acf81e // indirect - github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20240529171513-a5b0bf43b21f // indirect - github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240529090522-c780bd90b147 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/common v0.46.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect - github.com/rabbitmq/cluster-operator/v2 v2.6.0 // indirect - github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.69.0-rhobs1 // indirect - github.com/rhobs/observability-operator v0.0.28 // indirect - github.com/robfig/cron/v3 v3.0.1 // indirect github.com/spf13/pflag v1.0.5 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.23.0 // indirect - golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sys v0.20.0 // indirect @@ -106,7 +76,6 @@ require ( k8s.io/component-base v0.28.10 // indirect k8s.io/klog/v2 v2.120.1 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect - sigs.k8s.io/gateway-api v0.8.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect diff --git a/go.sum b/go.sum index 29a64d4..4edbd5e 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cert-manager/cert-manager v1.13.6 h1:yngKM4ZQoyFQ3LGHTx95fWqyiNJP11UM5PWq7pAr3T0= -github.com/cert-manager/cert-manager v1.13.6/go.mod h1:iWFePja8XKEl+Dv1kZtwPshT8D0SmC4Hyu5Qc5KS0tM= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -15,8 +13,6 @@ github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0 github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= -github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= @@ -27,13 +23,6 @@ github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdX github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4= github.com/go-openapi/swag v0.22.9 h1:XX2DssF+mQKM2DHsbgZK74y/zj4mo9I99+89xUmuZCE= github.com/go-openapi/swag v0.22.9/go.mod h1:3/OXnFfnMAwBD099SwYRk7GD3xOrr1iL7d/XNLXVVwE= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= -github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -71,14 +60,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= -github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/metal3-io/baremetal-operator/apis v0.5.1 h1:l6VCuM2nSYMsdir3mocXvF80F7HnTXVZ7NNIoMEYbio= -github.com/metal3-io/baremetal-operator/apis v0.5.1/go.mod h1:Q3MHes59mRabjHM6ARoHfgd2uXUjJIytl3/uflzhyew= -github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.4.0 h1:AnA8XLLp3RKYjjlB4KI0fyPSDN/d5gb3ZtM2cVyxwOc= -github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.4.0/go.mod h1:399nvdaqoU9rTI25UdFw2EWcVjmJPpeZPIhfDAIx/XU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -94,52 +77,16 @@ github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxC github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4= github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240523081006-98dc23995369 h1:gUZVKIEC/awfN+BkMDpBlcY8exT90DAXM0SSh/zGwH8= github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240523081006-98dc23995369/go.mod h1:GkisiXRP0lvef7h19rR9WRMCLN0+X+gdTt5Zs5ZyzBo= -github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240529155246-4afc791bbb82 h1:Q+U8JpT+grvSaDD9wqpdF6OyrJc1v+qDDkcg60xmDMg= -github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20240529155246-4afc791bbb82/go.mod h1:8Wn6ZAPaJshxozJVPI7uq4qrcUXZmECGAPJK7Ed+uGQ= -github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240601165131-290ef03229dc h1:Za/q+TP4FnZISIPuohSEOBmO1GbRW0lSNILow1QZI9I= -github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240601165131-290ef03229dc/go.mod h1:UbGgM9EsXXoY748EyNB7tovr+WwgR8w2fjl1tDZaALM= -github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20240528100324-b8f58a72095b h1:Lc6e6OzE7e0TlnDGfRcUB1b060QTKyK+GSB53BxQtM4= -github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20240528100324-b8f58a72095b/go.mod h1:grWcSpsvvrTUARs8XGFcobA5y51RtSU+FuKWGOutwAQ= -github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240602191531-ee2f5310fb97 h1:jCMsHVGpVT+dIdljdXw+dlz7pnFvx4K8eM4RMyaFPAs= -github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20240602191531-ee2f5310fb97/go.mod h1:f0L4NpxrXd+yPoBmizGYLEn9ffU8VMMheYilRV/hNWc= -github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240602060615-cab225f2aa04 h1:SfeOwOmWDnxZ1t1udGyQwv8HBNbdHl5ZO5gAIj2k8OY= -github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20240602060615-cab225f2aa04/go.mod h1:uIOH4pC2ka8229p40Wz0AWBCev0LGQxZfOcrDUTahqs= -github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20240515093015-9d2609bb0015 h1:eWXh/0ECebuM+R42T+C+RWFQIkn+zOiOhHLbOVPm6D4= -github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20240515093015-9d2609bb0015/go.mod h1:1ddkgh0JPbFIc8TuV0o7fR29WcDV0aH3uuovpCGfTlg= github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240525122647-715f01bb2987 h1:QKCvlSmU3toGuGmLIIazSnfAGtPc9WYWJHUh6qTyH+s= github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240525122647-715f01bb2987/go.mod h1:TnXnCaOQjjbAsj7v1F4Aynrb1abBvTTUdqxSx4HXUw0= -github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20240523093522-7a25580a799d h1:tgT+mww9s0srwvWG5KZraTxR+y4g4fG5zhi/50fh0lY= -github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20240523093522-7a25580a799d/go.mod h1:rltaem4x0R2LE4fTdUOVNAp7nBwzTSpKBdhfrQxZIX8= github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240525111221-1e3ee314289c h1:DLvy+ngJJiXjh4KEnCR15EieFkiCM4Wkp43Col5HnGc= github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240525111221-1e3ee314289c/go.mod h1:TnNxraQbQGIoP1pLlhTsBPJ5sWbpAS4amCaQ0XNnEAs= +github.com/openstack-k8s-operators/lib-common/modules/ansible v0.3.1-0.20240603143707-f5c5fe030fdd h1:CYMh2hpwNurFlptL5VkmaVDaT6PtvBBuAUfxrxKLybs= +github.com/openstack-k8s-operators/lib-common/modules/ansible v0.3.1-0.20240603143707-f5c5fe030fdd/go.mod h1:tP+nxk95PisCKJaXE/an2igG9lluxuOVhdmV9WtkR2s= github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240531085522-94fdcd5ff4fd h1:KdpVRQv1b5y7zIGWpXGmO5K4ErnPJrSsqwmNfGAgD2s= github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240531085522-94fdcd5ff4fd/go.mod h1:4Fe07vWr4OYg2qoFwoOM8rHEukdD3/r3FBqkYKE5//E= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240531085522-94fdcd5ff4fd h1:53cIwpNnml1s7e9RQ+XsbanZe7SmgPg5e/dZzseCtFQ= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240531085522-94fdcd5ff4fd/go.mod h1:OC9eAX0l35U8DD+ANolrVExTxeZbxKbrMVyiA3Dywow= -github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240531085522-94fdcd5ff4fd h1:tR0cs3CB7FtlwiAk/bMRl5sEXFs4ut5WNW7utBO5QAQ= -github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240531085522-94fdcd5ff4fd/go.mod h1:HnATO+h6spGXATZ8fdOc+CJ47BiTV3ML1ZtGZa6yj3I= -github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240602180119-bb1bd220b0ff h1:tRMcOm8K2tG7EY5UECwzwbIKSyo/jC4jrC44amBte1U= -github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240602180119-bb1bd220b0ff/go.mod h1:47/hHuGGXHZx7eWJpsPzwW9tem0Ghod85PSnlBasT0Y= -github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240514152407-b2bea62f05db h1:9Egd/Hs/ZKyWl4vXkbivu/MG52Ww/kDrzE9KNYKuj7M= -github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240514152407-b2bea62f05db/go.mod h1:tJbu9FBKNOpgN7T8SHhFGFnmKOg2EQsBWRKqE8+CPPA= -github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240531054845-7fa2b6b39520 h1:Ai1IgbtqeCyTWE2t41OBV2qTJ8GqYVmo5Ses3FqI2G4= -github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240531054845-7fa2b6b39520/go.mod h1:dHpsaGk+Lku6XFxp+oHqhGxTjvYiuStiCe/1GUFijI4= -github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20240530073125-ab95f150cbec h1:yKSiIqM+/9O7R3cAKD0uWJ89Ojfix1YcsijmwTMYbTY= -github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20240530073125-ab95f150cbec/go.mod h1:c9gu8Yp0RJqX8BEuVSytmmomf5WoDt5ukY0qbwT+DC4= -github.com/openstack-k8s-operators/octavia-operator/api v0.3.1-0.20240530121452-c1107b888dd4 h1:s/lqFXWVIGI6rktCmg70Uw2shPfnwaIIbkkNMcj8I9g= -github.com/openstack-k8s-operators/octavia-operator/api v0.3.1-0.20240530121452-c1107b888dd4/go.mod h1:AWiNsUW/IQARQfEt0RDknT879JszjK4AOVHkjhs/Svk= -github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.3.1-0.20240523005930-c332745390c8 h1:R1MeuR4dPhMop5i9Q4s0PKwqII/uzB6+sVhF9DeWk78= -github.com/openstack-k8s-operators/openstack-baremetal-operator/api v0.3.1-0.20240523005930-c332745390c8/go.mod h1:z+mHw+0/ehsh5bPzeuurxY5uahRNtH1KcOkYg8Bl678= -github.com/openstack-k8s-operators/openstack-operator/apis v0.0.0-20240531084739-3b4c0451297c h1:jgPabkWJ/V4DAjinP0GNAENghihZLlg5/hkmooFi9pM= -github.com/openstack-k8s-operators/openstack-operator/apis v0.0.0-20240531084739-3b4c0451297c/go.mod h1:tIIY+EHcOI8e6sB8mbMKsS0H5Y+vKGvKw9zwDcNnohg= -github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20240531062432-734161acf81e h1:07ZnKM7Xr86ghG8tZw2P71j1pNME4ADO0hPW/42H83Q= -github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20240531062432-734161acf81e/go.mod h1:8IGlVTQjOGjlfhA268wcZXvDn0RKy6I+I5JjlN+Ffds= -github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20240529171513-a5b0bf43b21f h1:tddtlKWrSr2seok3wHQvC6ZECHmSFyUfFAwdyizOkdA= -github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20240529171513-a5b0bf43b21f/go.mod h1:C9aUa9an/pgQmbMg79sqdQDI7UT7GjoiHttYbfB0h14= -github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20240313124519-961a0ee8bf7f h1:wWaOCAkCym4t+NZWXYT/LErGhKujDdKgc7Qy/3vX4uU= -github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20240313124519-961a0ee8bf7f/go.mod h1:Zryxg5YgbPUFcLSCcKpf10il8kIRAK5HloNo6khhdis= -github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240529090522-c780bd90b147 h1:+X4c8beJnrdFwLX67Y7vK+7hWp1svRp4hT2hTdNP/b8= -github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240529090522-c780bd90b147/go.mod h1:ADN4s09xZpxhnmjD5s0gcRIOm73IUwA6kpimioiGIAI= 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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -152,12 +99,6 @@ github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqSc github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.69.0-rhobs1 h1:d6UamuHl8GaEXcQqM7VO8jMnnhzHmTA0f6h4dQTQsGk= -github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.69.0-rhobs1/go.mod h1:SDL0R6499oleOOVL5ovIxHpyLOh2sR2g0rvBuuqHyQM= -github.com/rhobs/observability-operator v0.0.28 h1:FFMBkmI1LWJVWyJKJqelYbV5iUc4u/wJClqowRJZRoU= -github.com/rhobs/observability-operator v0.0.28/go.mod h1:LbxNGGlKlcD7NBt0axiTeRRjnE0m///DoyeVKeaStg4= -github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= -github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -177,8 +118,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 h1:ESSUROHIBHg7USnszlcdmjBEwdMj9VUvU+OPk4yl2mc= golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -268,8 +207,6 @@ k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCI k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/controller-runtime v0.16.6 h1:FiXwTuFF5ZJKmozfP2Z0j7dh6kmxP4Ou1KLfxgKKC3I= sigs.k8s.io/controller-runtime v0.16.6/go.mod h1:+dQzkZxnylD0u49e0a+7AR+vlibEBaThmPca7lTyUsI= -sigs.k8s.io/gateway-api v0.8.0 h1:isQQ3Jx2qFP7vaA3ls0846F0Amp9Eq14P08xbSwVbQg= -sigs.k8s.io/gateway-api v0.8.0/go.mod h1:okOnjPNBFbIS/Rw9kAhuIUaIkLhTKEu+ARIuXk2dgaM= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/main.go b/main.go index 2cea77c..5e8cefb 100644 --- a/main.go +++ b/main.go @@ -44,7 +44,6 @@ import ( networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" barbicanv1 "github.com/openstack-k8s-operators/barbican-operator/api/v1beta1" - dataplanev1 "github.com/openstack-k8s-operators/dataplane-operator/api/v1beta1" memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1" infranetworkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" @@ -65,7 +64,6 @@ func init() { utilruntime.Must(memcachedv1.AddToScheme(scheme)) utilruntime.Must(networkv1.AddToScheme(scheme)) utilruntime.Must(infranetworkv1.AddToScheme(scheme)) - utilruntime.Must(dataplanev1.AddToScheme(scheme)) utilruntime.Must(barbicanv1.AddToScheme(scheme)) utilruntime.Must(rabbitmqv1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme diff --git a/pkg/swiftring/funcs.go b/pkg/swiftring/funcs.go index 319b3f8..f018927 100644 --- a/pkg/swiftring/funcs.go +++ b/pkg/swiftring/funcs.go @@ -23,21 +23,22 @@ import ( "sort" "strings" + "golang.org/x/exp/slices" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/openstack-k8s-operators/lib-common/modules/ansible" "github.com/openstack-k8s-operators/lib-common/modules/common/helper" "github.com/openstack-k8s-operators/lib-common/modules/common/util" - dataplanev1 "github.com/openstack-k8s-operators/dataplane-operator/api/v1beta1" swiftv1beta1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" "github.com/openstack-k8s-operators/swift-operator/pkg/swift" ) //+kubebuilder:rbac:groups=core,resources=persistentvolumeclaims,verbs=get;list;watch -//+kubebuilder:rbac:groups=dataplane.openstack.org,resources=openstackdataplanenodesets,verbs=get;list;watch func DeviceList(ctx context.Context, h *helper.Helper, instance *swiftv1beta1.SwiftRing) (string, string, error) { // Returns a list of devices as CSV @@ -85,46 +86,66 @@ func DeviceList(ctx context.Context, h *helper.Helper, instance *swiftv1beta1.Sw } } - // Get all OpenStackDataPlaneNodeSets that deploy the Swift service and + // Get all DataPlaneNodeSet inventories that deploy the Swift service and // their used Swift disks - nodeSets := &dataplanev1.OpenStackDataPlaneNodeSetList{} - err = h.GetClient().List(context.Background(), nodeSets, listOpts...) + secrets := &corev1.SecretList{} + labelSelector := map[string]string{ + "openstack.org/operator-name": "dataplane", + "inventory": "true", + } + labels := client.MatchingLabels(labelSelector) + listOpts = append(listOpts, labels) + + err = h.GetClient().List(context.Background(), secrets, listOpts...) if err != nil && !errors.IsNotFound(err) { return "", "", err } - for _, nodeSet := range nodeSets.Items { - for _, service := range nodeSet.Spec.Services { - if service == "swift" { - // Get the global disk vars first that are used for all - // nodes if not set otherwise per-node - var globalDisks []swiftv1beta1.SwiftDisk - if edpmSwiftDisks, found := nodeSet.Spec.NodeTemplate.Ansible.AnsibleVars[DataplaneDisks]; found { - err = json.Unmarshal(edpmSwiftDisks, &globalDisks) - if err != nil { - return "", "", err - } + for _, secret := range secrets.Items { + inventory, err := ansible.UnmarshalYAML(secret.Data["inventory"]) + if err != nil { + return "", "", err + } + nodeSetGroup := inventory.Groups[secret.Labels["openstackdataplanenodeset"]] + + if slices.Contains(nodeSetGroup.Vars["edpm_services"].([]interface{}), "swift") { + // Get the global disk vars first that are used for all + // nodes if not set otherwise per-node + var globalDisks []swiftv1beta1.SwiftDisk + if _, found := nodeSetGroup.Vars[DataplaneDisks]; found { + edpmSwiftDisks, err := json.Marshal(nodeSetGroup.Vars[DataplaneDisks]) + if err != nil { + return "", "", err } + err = json.Unmarshal(edpmSwiftDisks, &globalDisks) + if err != nil { + return "", "", err + } + } - for _, node := range nodeSet.Spec.Nodes { - hostName := fmt.Sprintf("%s.%s", node.HostName, DataplaneDomain) - hostDisks := make([]swiftv1beta1.SwiftDisk, len(globalDisks)) - copy(hostDisks, globalDisks) - - // These overwrite the global vars if set - if edpmSwiftDisks, found := node.Ansible.AnsibleVars[DataplaneDisks]; found { - hostDisks = nil // clear global disks, per-node settings prevail - err = json.Unmarshal(edpmSwiftDisks, &hostDisks) - if err != nil { - return "", "", err - } + for nodeName, host := range nodeSetGroup.Hosts { + hostName := fmt.Sprintf("%s.%s", nodeName, DataplaneDomain) + hostDisks := make([]swiftv1beta1.SwiftDisk, len(globalDisks)) + copy(hostDisks, globalDisks) + // These overwrite the global vars if set + if _, found := host.Vars[DataplaneDisks]; found { + edpmSwiftDisks, err := json.Marshal(host.Vars[DataplaneDisks]) + if err != nil { + return "", "", err } - for _, disk := range hostDisks { - devices = append(devices, fmt.Sprintf("%d %d %s %s %d\n", disk.Region, disk.Zone, hostName, filepath.Base(disk.Path), disk.Weight)) + hostDisks = nil // clear global disks, per-node settings prevail + err = json.Unmarshal(edpmSwiftDisks, &hostDisks) + if err != nil { + return "", "", err } + + } + for _, disk := range hostDisks { + devices = append(devices, fmt.Sprintf("%d %d %s %s %d\n", disk.Region, disk.Zone, hostName, filepath.Base(disk.Path), disk.Weight)) } } } + } // Device list must be sorted to ensure hash does not change