diff --git a/api/go.mod b/api/go.mod index 6cbe718e..bf3731e3 100644 --- a/api/go.mod +++ b/api/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/onsi/ginkgo/v2 v2.20.1 github.com/onsi/gomega v1.34.1 - github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d + github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462 github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b k8s.io/api v0.29.15 k8s.io/apimachinery v0.29.15 diff --git a/api/go.sum b/api/go.sum index f0b0abef..da92077d 100644 --- a/api/go.sum +++ b/api/go.sum @@ -74,8 +74,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E= github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4= -github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d h1:/C+ysubV00VYrqGFhQlDeQ5tUtnhIWPwQUc8MOfCEBA= -github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d/go.mod h1:IY5zp1GRhacGMvjZMUZQ0LlxWDaogIRb/4H3by1Pivk= +github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462 h1:hWdJM9hB/GSFjXc7E7b9L+2H4ZfCOxygceMiYXR4kKc= +github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462/go.mod h1:+l+sclC6YCRcLcvS3UEGKBf8xya8aExMrmHeA9tMg+k= github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b h1:T+N6xOT2NP+hVp2K1xl/NV3uheVHu38CcBuW+8uOBYw= github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b/go.mod h1:A9Ohw5Q90YOGhcDF4ZHkMr5RArz3phoBu9+ibbYDKG4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/controllers/funcs.go b/controllers/funcs.go index 30d54b01..7512f6ef 100644 --- a/controllers/funcs.go +++ b/controllers/funcs.go @@ -88,19 +88,6 @@ type topologyHandler interface { SetLastAppliedTopology(t *topologyv1.TopoRef) } -// GetLastAppliedTopologyRef - Returns a TopoRef object that can be passed to the -// Handle topology logic -func GetLastAppliedTopologyRef(t topologyHandler, ns string) *topologyv1.TopoRef { - lastAppliedTopologyName := "" - if l := t.GetLastAppliedTopology(); l != nil { - lastAppliedTopologyName = l.Name - } - return &topologyv1.TopoRef{ - Name: lastAppliedTopologyName, - Namespace: ns, - } -} - func ensureTopology( ctx context.Context, helper *helper.Helper, @@ -114,7 +101,7 @@ func ensureTopology( ctx, helper, instance.GetSpecTopologyRef(), - GetLastAppliedTopologyRef(instance, helper.GetBefore().GetNamespace()), + instance.GetLastAppliedTopology(), finalizer, defaultLabelSelector, ) diff --git a/go.mod b/go.mod index cb0abeb3..2f122900 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/onsi/ginkgo/v2 v2.20.1 github.com/onsi/gomega v1.34.1 github.com/openshift/api v3.9.0+incompatible - github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d + github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462 github.com/openstack-k8s-operators/ironic-operator/api v0.0.0-00010101000000-000000000000 github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250406092234-10f5f7e5b5a9 github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b diff --git a/go.sum b/go.sum index b6a654b7..3781feb2 100644 --- a/go.sum +++ b/go.sum @@ -78,8 +78,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E= github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4= -github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d h1:/C+ysubV00VYrqGFhQlDeQ5tUtnhIWPwQUc8MOfCEBA= -github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d/go.mod h1:IY5zp1GRhacGMvjZMUZQ0LlxWDaogIRb/4H3by1Pivk= +github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462 h1:hWdJM9hB/GSFjXc7E7b9L+2H4ZfCOxygceMiYXR4kKc= +github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462/go.mod h1:+l+sclC6YCRcLcvS3UEGKBf8xya8aExMrmHeA9tMg+k= github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250406092234-10f5f7e5b5a9 h1:Q1yMkuwIOCtGQJDsKYAbspJU5b6emRvoKw5VyPXfiak= github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250406092234-10f5f7e5b5a9/go.mod h1:klMsoleakNm0dfNR9ePkL5pNZQsIyx4WMLaHDKIkTt4= github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b h1:T+N6xOT2NP+hVp2K1xl/NV3uheVHu38CcBuW+8uOBYw= diff --git a/tests/functional/base_test.go b/tests/functional/base_test.go index 9b479b76..89323a9e 100644 --- a/tests/functional/base_test.go +++ b/tests/functional/base_test.go @@ -22,7 +22,6 @@ import ( . "github.com/onsi/gomega" //revive:disable:dot-imports - topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1" ironicv1 "github.com/openstack-k8s-operators/ironic-operator/api/v1beta1" ironic_pkg "github.com/openstack-k8s-operators/ironic-operator/pkg/ironic" ironic_inspector_pkg "github.com/openstack-k8s-operators/ironic-operator/pkg/ironicinspector" @@ -691,26 +690,3 @@ func GetSampleTopologySpec(label string) (map[string]interface{}, []corev1.Topol } return topologySpec, topologySpecObj } - -// CreateTopology - Creates a Topology CR based on the spec passed as input -func CreateTopology(topology types.NamespacedName, spec map[string]interface{}) client.Object { - raw := map[string]interface{}{ - "apiVersion": "topology.openstack.org/v1beta1", - "kind": "Topology", - "metadata": map[string]interface{}{ - "name": topology.Name, - "namespace": topology.Namespace, - }, - "spec": spec, - } - return th.CreateUnstructured(raw) -} - -// GetTopology - Returns the referenced Topology -func GetTopology(name types.NamespacedName) *topologyv1.Topology { - instance := &topologyv1.Topology{} - Eventually(func(g Gomega) { - g.Expect(k8sClient.Get(ctx, name, instance)).Should(Succeed()) - }, timeout, interval).Should(Succeed()) - return instance -} diff --git a/tests/functional/ironic_controller_test.go b/tests/functional/ironic_controller_test.go index a49e2b3b..96ac7932 100644 --- a/tests/functional/ironic_controller_test.go +++ b/tests/functional/ironic_controller_test.go @@ -702,7 +702,7 @@ var _ = Describe("Ironic controller", func() { for _, t := range ironicNames.IronicTopologies { // Build the topology Spec topologySpec, _ := GetSampleTopologySpec(t.Name) - CreateTopology(t, topologySpec) + infra.CreateTopology(t, topologySpec) } DeferCleanup( k8sClient.Delete, @@ -756,7 +756,7 @@ var _ = Describe("Ironic controller", func() { It("sets topology in CR status", func() { Eventually(func(g Gomega) { - tp := GetTopology(types.NamespacedName{ + tp := infra.GetTopology(types.NamespacedName{ Name: topologyRef.Name, Namespace: topologyRef.Namespace, }) @@ -814,7 +814,7 @@ var _ = Describe("Ironic controller", func() { }, timeout, interval).Should(Succeed()) Eventually(func(g Gomega) { - tp := GetTopology(types.NamespacedName{ + tp := infra.GetTopology(types.NamespacedName{ Name: expectedTopology.Name, Namespace: expectedTopology.Namespace, }) @@ -841,7 +841,7 @@ var _ = Describe("Ironic controller", func() { // Get the previous topology and verify there are no finalizers // anymore - tp = GetTopology(types.NamespacedName{ + tp = infra.GetTopology(types.NamespacedName{ Name: topologyRef.Name, Namespace: topologyRef.Namespace, }) @@ -871,7 +871,7 @@ var _ = Describe("Ironic controller", func() { Name: ironicNames.IronicTopologies[1].Name, Namespace: ironicNames.IronicTopologies[1].Namespace, } - tp := GetTopology(types.NamespacedName{ + tp := infra.GetTopology(types.NamespacedName{ Name: expectedTopology.Name, Namespace: expectedTopology.Namespace, }) @@ -889,7 +889,7 @@ var _ = Describe("Ironic controller", func() { Name: ironicNames.IronicTopologies[2].Name, Namespace: ironicNames.IronicTopologies[2].Namespace, } - tp := GetTopology(types.NamespacedName{ + tp := infra.GetTopology(types.NamespacedName{ Name: expectedTopology.Name, Namespace: expectedTopology.Namespace, }) @@ -907,7 +907,7 @@ var _ = Describe("Ironic controller", func() { Name: ironicNames.IronicTopologies[3].Name, Namespace: ironicNames.IronicTopologies[3].Namespace, } - tp := GetTopology(types.NamespacedName{ + tp := infra.GetTopology(types.NamespacedName{ Name: expectedTopology.Name, Namespace: expectedTopology.Namespace, }) @@ -951,7 +951,7 @@ var _ = Describe("Ironic controller", func() { Eventually(func(g Gomega) { for _, topology := range ironicNames.IronicTopologies { // Get the current topology and verify there are no finalizers - tp := GetTopology(types.NamespacedName{ + tp := infra.GetTopology(types.NamespacedName{ Name: topology.Name, Namespace: topology.Namespace, })