diff --git a/controllers/nova_controller.go b/controllers/nova_controller.go index a37375b42..609619151 100644 --- a/controllers/nova_controller.go +++ b/controllers/nova_controller.go @@ -1649,10 +1649,7 @@ func (r *NovaReconciler) getKeystoneAuthURL( h *helper.Helper, instance *novav1.Nova, ) (string, string, error) { - // TODO(gibi): change lib-common to take the name of the KeystoneAPI as - // parameter instead of labels. Then use instance.Spec.KeystoneInstance as - // the name. - keystoneAPI, err := keystonev1.GetKeystoneAPI(ctx, h, instance.Namespace, map[string]string{}) + keystoneAPI, err := keystonev1.GetKeystoneAPIByName(ctx, h, instance.Spec.KeystoneInstance, instance.Namespace) if err != nil { return "", "", err } diff --git a/go.mod b/go.mod index 01f144c56..f0e13deaf 100644 --- a/go.mod +++ b/go.mod @@ -87,6 +87,8 @@ require ( replace github.com/openstack-k8s-operators/nova-operator/api => ./api +replace github.com/openstack-k8s-operators/keystone-operator/api => github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250818061624-cbdfd1f68df8 //allow-merging + // mschuppert: map to latest commit from release-4.16 tag // must consistent within modules and service operators replace github.com/openshift/api => github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 //allow-merging diff --git a/go.sum b/go.sum index d524a7c86..29675c3fb 100644 --- a/go.sum +++ b/go.sum @@ -80,8 +80,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/infra-operator/apis v0.6.1-0.20250813063935-fdc20530dcf1 h1:77TRnwfSxNI5cn/RxMS9I+kqefMm7XRQsNknIhEE4tg= github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250813063935-fdc20530dcf1/go.mod h1:Dv8qpmBIQy3Jv/EyQnOyc0w61X8vyfxpjcIQONP5CwY= -github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250811083324-e790d63f389f h1:Ivo4YKaH26B1lQlwKcolELCRGtEbmvbfJShBTVrCdQI= -github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250811083324-e790d63f389f/go.mod h1:H5iZOohoVOmZvIZPR5ep6z+jmfrpz25axOM6IXlXzNU= +github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250818061624-cbdfd1f68df8 h1:1r3wSalcW2TY8K3X6j5cL0M9MgJDCI1nZ7tHne/Izlg= +github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250818061624-cbdfd1f68df8/go.mod h1:H5iZOohoVOmZvIZPR5ep6z+jmfrpz25axOM6IXlXzNU= github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250730071847-837b07f8d72f h1:DW8aNjEtDFrWiZ6vWuOXwdRB4eBD0n+bA9foQkOEx6U= github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250730071847-837b07f8d72f/go.mod h1:P+7F1wiwZUxOy4myYXFyc/uBtGATDFpk3yAllXe1Vzk= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250730071847-837b07f8d72f h1:nGYLHcpM7EjiSzN4bmiLZbxty9u0k0Qzvkqn+1s1TF0= diff --git a/test/functional/base_test.go b/test/functional/base_test.go index f64e37b44..ff752065a 100644 --- a/test/functional/base_test.go +++ b/test/functional/base_test.go @@ -1042,17 +1042,20 @@ func CreateNovaWithNCellsAndEnsureReady(cellNumber int, novaNames *NovaNames) { cellTemplates[cellName] = template } + // Create KeystoneAPI first to get the correct name + // DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) + // Create Nova spec spec := GetDefaultNovaSpec() spec["cellTemplates"] = cellTemplates spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name spec["apiMessageBusInstance"] = novaNames.Cells["cell0"].TransportURLName.Name + spec["keystoneInstance"] = keystoneAPIName.Name // Deploy Nova and simulate its dependencies DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) - // DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) - novaNames.KeystoneAPIName = keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) - DeferCleanup(keystone.DeleteKeystoneAPI, novaNames.KeystoneAPIName) memcachedSpec := infra.GetDefaultMemcachedSpec() DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) diff --git a/test/functional/nova_controller_test.go b/test/functional/nova_controller_test.go index 0885d82d1..7282d3632 100644 --- a/test/functional/nova_controller_test.go +++ b/test/functional/nova_controller_test.go @@ -759,13 +759,17 @@ var _ = Describe("Nova controller", func() { DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(novaNames.MemcachedNamespace) - DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) + + // Create KeystoneAPI first to get correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) spec := GetDefaultNovaSpec() cell0template := GetDefaultNovaCellTemplate() cell0template["cellDatabaseInstance"] = cell0.MariaDBDatabaseName.Name spec["cellTemplates"] = map[string]interface{}{"cell0": cell0template} spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name + spec["keystoneInstance"] = keystoneAPIName.Name DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) }) @@ -1100,7 +1104,9 @@ var _ = Describe("Nova controller", func() { DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(novaNames.MemcachedNamespace) - DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) + // Create KeystoneAPI first to get the correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) spec := GetDefaultNovaSpec() cell0template := GetDefaultNovaCellTemplate() @@ -1109,6 +1115,7 @@ var _ = Describe("Nova controller", func() { spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name spec["apiDatabaseAccount"] = novaNames.APIMariaDBDatabaseAccount.Name spec["topologyRef"] = map[string]interface{}{"name": "foo"} + spec["keystoneInstance"] = keystoneAPIName.Name DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) @@ -1176,7 +1183,9 @@ var _ = Describe("Nova controller", func() { // Create a global Test Topology _, topologyRef = infra.CreateTopology(novaNames.NovaTopologies[0], topologySpec) - DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) + // Create keystoneAPI first to get correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) spec := GetDefaultNovaSpec() cell0template := GetDefaultNovaCellTemplate() @@ -1184,6 +1193,7 @@ var _ = Describe("Nova controller", func() { spec["cellTemplates"] = map[string]interface{}{"cell0": cell0template} spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name spec["apiDatabaseAccount"] = novaNames.APIMariaDBDatabaseAccount.Name + spec["keystoneInstance"] = keystoneAPIName.Name // We reference the global topology and is inherited by the sub components spec["topologyRef"] = map[string]interface{}{"name": topologyRef.Name} @@ -1284,6 +1294,9 @@ var _ = Describe("Nova controller", func() { DeferCleanup(mariadb.DeleteDBService, mariadb.CreateDBService(novaNames.APIMariaDBDatabaseName.Namespace, novaNames.APIMariaDBDatabaseName.Name, serviceSpec)) DeferCleanup(mariadb.DeleteDBService, mariadb.CreateDBService(cell0.MariaDBDatabaseName.Namespace, cell0.MariaDBDatabaseName.Name, serviceSpec)) DeferCleanup(mariadb.DeleteDBService, mariadb.CreateDBService(cell1.MariaDBDatabaseName.Namespace, cell1.MariaDBDatabaseName.Name, serviceSpec)) + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + keystoneAPI := keystone.GetKeystoneAPI(keystoneAPIName) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) // cell0 spec := GetDefaultNovaSpec() cell0Template := GetDefaultNovaCellTemplate() @@ -1313,13 +1326,11 @@ var _ = Describe("Nova controller", func() { // We reference the global topology and is inherited by the sub components // except cell1 that has an override spec["topologyRef"] = map[string]interface{}{"name": topologyRefTopLevel.Name} + spec["keystoneInstance"] = keystoneAPIName.Name DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) memcachedSpec := infra.GetDefaultMemcachedSpec() DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(novaNames.MemcachedNamespace) - keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) - DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) - keystoneAPI := keystone.GetKeystoneAPI(keystoneAPIName) Eventually(func(g Gomega) { g.Expect(k8sClient.Status().Update(ctx, keystoneAPI.DeepCopy())).Should(Succeed()) }, timeout, interval).Should(Succeed()) @@ -1449,11 +1460,16 @@ var _ = Describe("Nova controller", func() { DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(novaNames.MemcachedNamespace) + // Create keystoneAPI first to get the correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) + DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) spec := GetDefaultNovaSpec() cell0 := GetDefaultNovaCellTemplate() spec["cellTemplates"] = map[string]interface{}{"cell0": cell0} + spec["keystoneInstance"] = keystoneAPIName.Name // This nova is created without any container image is specified in // the request DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) @@ -1533,7 +1549,9 @@ var _ = Describe("Nova controller", func() { DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(novaNames.MemcachedNamespace) - DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) + // Create keystoneAPI first to get the correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) spec := GetDefaultNovaSpec() cell0template := GetDefaultNovaCellTemplate() @@ -1541,6 +1559,7 @@ var _ = Describe("Nova controller", func() { spec["cellTemplates"] = map[string]interface{}{"cell0": cell0template} spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name spec["apiDatabaseAccount"] = accountName.Name + spec["keystoneInstance"] = keystoneAPIName.Name DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) @@ -1637,7 +1656,9 @@ var _ = Describe("Nova controller", func() { DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(novaNames.MemcachedNamespace) - DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) + // Create keystoneAPI first to get the correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) spec := GetDefaultNovaSpec() cell0template := GetDefaultNovaCellTemplate() @@ -1645,6 +1666,7 @@ var _ = Describe("Nova controller", func() { cell0template["cellDatabaseAccount"] = accountName.Name spec["cellTemplates"] = map[string]interface{}{"cell0": cell0template} spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name + spec["keystoneInstance"] = keystoneAPIName.Name DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) diff --git a/test/functional/nova_multicell_test.go b/test/functional/nova_multicell_test.go index 589d08cdd..cc17c0195 100644 --- a/test/functional/nova_multicell_test.go +++ b/test/functional/nova_multicell_test.go @@ -98,6 +98,10 @@ var _ = Describe("Nova multi cell", func() { "database": "NovaCell2DatabasePassword", } + // Create KeystoneAPI first to get the correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) + spec["cellTemplates"] = map[string]interface{}{ "cell0": cell0Template, "cell1": cell1Template, @@ -105,9 +109,9 @@ var _ = Describe("Nova multi cell", func() { } spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name spec["apiMessageBusInstance"] = cell0.TransportURLName.Name + spec["keystoneInstance"] = keystoneAPIName.Name DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) - DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) memcachedSpecCell1 := infra.GetDefaultMemcachedSpec() memcachedNamespace := types.NamespacedName{ Name: cell1Memcached, @@ -678,19 +682,23 @@ var _ = Describe("Nova multi cell", func() { cell1Template["cellMessageBusInstance"] = cell0.TransportURLName.Name cell1Template["hasAPIAccess"] = true + // Create KeystoneAPI first to get the correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) + spec["cellTemplates"] = map[string]interface{}{ "cell0": cell0Template, "cell1": cell1Template, } spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name spec["apiMessageBusInstance"] = cell0.TransportURLName.Name + spec["keystoneInstance"] = keystoneAPIName.Name DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) memcachedSpec := infra.GetDefaultMemcachedSpec() DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(novaNames.MemcachedNamespace) - DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace)) keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName) }) @@ -792,19 +800,23 @@ var _ = Describe("Nova multi cell", func() { cell1Template["cellDatabaseAccount"] = cell1.MariaDBAccountName.Name cell1Template["cellMessageBusInstance"] = cell1.TransportURLName.Name + // Create KeystoneAPI first to get the correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) + spec["cellTemplates"] = map[string]interface{}{ "cell0": cell0Template, "cell1": cell1Template, } spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name spec["apiMessageBusInstance"] = cell0.TransportURLName.Name + spec["keystoneInstance"] = keystoneAPIName.Name DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) memcachedSpec := infra.GetDefaultMemcachedSpec() DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(novaNames.MemcachedNamespace) - DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.Namespace)) keystone.SimulateKeystoneServiceReady(novaNames.KeystoneServiceName) }) @@ -858,19 +870,22 @@ var _ = Describe("Nova multi cell", func() { "cell0": cell0Template, "cell1": cell1Template, } + // Create KeystoneAPI first to get the correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) + spec["metadataServiceTemplate"] = map[string]interface{}{ "enabled": false, } spec["apiDatabaseInstance"] = novaNames.APIMariaDBDatabaseName.Name spec["apiMessageBusInstance"] = cell0.TransportURLName.Name + spec["keystoneInstance"] = keystoneAPIName.Name DeferCleanup(th.DeleteInstance, CreateNova(novaNames.NovaName, spec)) memcachedSpec := infra.GetDefaultMemcachedSpec() DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(novaNames.MemcachedNamespace) - keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) - DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) keystoneAPI := keystone.GetKeystoneAPI(keystoneAPIName) Eventually(func(g Gomega) { g.Expect(k8sClient.Status().Update(ctx, keystoneAPI.DeepCopy())).Should(Succeed()) diff --git a/test/functional/nova_reconfiguration_test.go b/test/functional/nova_reconfiguration_test.go index 0580102d3..ce681afd3 100644 --- a/test/functional/nova_reconfiguration_test.go +++ b/test/functional/nova_reconfiguration_test.go @@ -1060,7 +1060,11 @@ var _ = Describe("Nova reconfiguration", func() { It("updates the KeystoneAuthURL of the sub components if keystone internal endpoint changes", func() { newInternalEndpoint := "https://keystone-internal" - keystone.UpdateKeystoneAPIEndpoint(novaNames.KeystoneAPIName, "internal", newInternalEndpoint) + // Create keystoneAPI first to get the correct name + keystoneAPIName := keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace) + + keystone.UpdateKeystoneAPIEndpoint(keystoneAPIName, "internal", newInternalEndpoint) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPIName) logger.Info("Reconfigured") SimulateReadyOfNovaTopServices()