Skip to content

Commit 721f79d

Browse files
committed
Add AC finalizer management
Signed-off-by: Veronika Fisarova <vfisarov@redhat.com>
1 parent 4d37539 commit 721f79d

10 files changed

Lines changed: 233 additions & 19 deletions

File tree

api/bases/nova.openstack.org_nova.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,13 @@ spec:
19141914
from nova-api
19151915
format: int32
19161916
type: integer
1917+
applicationCredentialSecret:
1918+
description: |-
1919+
ApplicationCredentialSecret - the AC secret nova is currently
1920+
consuming and protecting with the openstack.org/nova-ac-consumer
1921+
finalizer. Tracked so the controller can remove its finalizer from the
1922+
old secret when the openstack-operator rotates the reference.
1923+
type: string
19171924
conditions:
19181925
description: Conditions
19191926
items:

api/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.4
44

55
require (
66
github.com/google/go-cmp v0.7.0
7-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260416122644-5476763a36b6
7+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260508091801-73f228e6af31
88
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260518125357-72bdd580c587
99
github.com/robfig/cron/v3 v3.0.1
1010
k8s.io/api v0.31.14
@@ -43,6 +43,7 @@ require (
4343
github.com/prometheus/client_model v0.6.2 // indirect
4444
github.com/prometheus/common v0.65.0 // indirect
4545
github.com/prometheus/procfs v0.16.1 // indirect
46+
github.com/rogpeppe/go-internal v1.13.1 // indirect
4647
github.com/spf13/pflag v1.0.7 // indirect
4748
github.com/x448/float16 v0.8.4 // indirect
4849
go.yaml.in/yaml/v2 v2.4.2 // indirect

api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ github.com/onsi/ginkgo/v2 v2.28.2 h1:DTrMfpqxiNUyQ3Y0zhn1n3cOO2euFgQPYIpkWwxVFps
7878
github.com/onsi/ginkgo/v2 v2.28.2/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE=
7979
github.com/onsi/gomega v1.41.0 h1:OwKp4pXNgVxf6sCplzYo794OFNuoL2q2SBMU5NSWOjA=
8080
github.com/onsi/gomega v1.41.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A=
81-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260416122644-5476763a36b6 h1:117Gu9HCSu2tAp579WnCJ9QtnslH2qnPB8UFvn8ZpqE=
82-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260416122644-5476763a36b6/go.mod h1:i7l8cihvFktd/LSuyvL2z6OcwauarQGoVhDMePL4VyI=
81+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260508091801-73f228e6af31 h1:FWa0vNs175LpV1eSZ60YOGFdbJ3LqxQ1fxfprBRg7T4=
82+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260508091801-73f228e6af31/go.mod h1:/S2AN21zV70V1XuL0Of2dCjYWNkKwQSyNI8l/iQVrMs=
8383
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260518125357-72bdd580c587 h1:p03uEXoSreyu7LpFmb9YyYM8tEx2D2+7qqhLXNWHTq0=
8484
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260518125357-72bdd580c587/go.mod h1:JC04T5G4E/he5ukonV1oCqa0QzFkLv761VbLruVghJM=
8585
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=

api/nova/v1beta1/nova_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ type NovaStatus struct {
185185

186186
//ObservedGeneration - the most recent generation observed for this service. If the observed generation is less than the spec generation, then the controller has not processed the latest changes.
187187
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
188+
189+
// ApplicationCredentialSecret - the AC secret nova is currently
190+
// consuming and protecting with the openstack.org/nova-ac-consumer
191+
// finalizer. Tracked so the controller can remove its finalizer from the
192+
// old secret when the openstack-operator rotates the reference.
193+
ApplicationCredentialSecret string `json:"applicationCredentialSecret,omitempty"`
188194
}
189195

190196
//+kubebuilder:object:root=true

config/crd/bases/nova.openstack.org_nova.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,13 @@ spec:
19141914
from nova-api
19151915
format: int32
19161916
type: integer
1917+
applicationCredentialSecret:
1918+
description: |-
1919+
ApplicationCredentialSecret - the AC secret nova is currently
1920+
consuming and protecting with the openstack.org/nova-ac-consumer
1921+
finalizer. Tracked so the controller can remove its finalizer from the
1922+
old secret when the openstack-operator rotates the reference.
1923+
type: string
19171924
conditions:
19181925
description: Conditions
19191926
items:

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ require (
1010
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.7.7
1111
github.com/onsi/ginkgo/v2 v2.28.2
1212
github.com/onsi/gomega v1.41.0
13-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260416122644-5476763a36b6
14-
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260420052838-77f94aef5af2
13+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260508091801-73f228e6af31
14+
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260520090027-4d7b7a01c0bf
1515
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260518125357-72bdd580c587
16-
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20260417092244-81c71b39e981
17-
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20260417092244-81c71b39e981
16+
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20260506154724-30a976ba8ef0
17+
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20260518125357-72bdd580c587
1818
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260413152655-564a51226a2a
1919
github.com/openstack-k8s-operators/nova-operator/api v0.0.0-20221209164002-f9e6b9363961
2020
go.uber.org/zap v1.28.0
@@ -65,7 +65,7 @@ require (
6565
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
6666
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6767
github.com/openshift/api v3.9.0+incompatible // indirect
68-
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260417092244-81c71b39e981 // indirect
68+
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260506154724-30a976ba8ef0 // indirect
6969
github.com/pkg/errors v0.9.1 // indirect
7070
github.com/prometheus/client_golang v1.22.0 // indirect
7171
github.com/prometheus/client_model v0.6.2 // indirect

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ github.com/onsi/gomega v1.41.0 h1:OwKp4pXNgVxf6sCplzYo794OFNuoL2q2SBMU5NSWOjA=
118118
github.com/onsi/gomega v1.41.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A=
119119
github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e h1:E1OdwSpqWuDPCedyUt0GEdoAE+r5TXy7YS21yNEo+2U=
120120
github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
121-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260416122644-5476763a36b6 h1:117Gu9HCSu2tAp579WnCJ9QtnslH2qnPB8UFvn8ZpqE=
122-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260416122644-5476763a36b6/go.mod h1:i7l8cihvFktd/LSuyvL2z6OcwauarQGoVhDMePL4VyI=
123-
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260420052838-77f94aef5af2 h1:h7pTz90cHqX6nTYjYDphuitIfD4UpM9yGnI3AbLdHrY=
124-
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260420052838-77f94aef5af2/go.mod h1:SpO4CL7c5/1HG+61fP6kWhL2+3aqR+5SNatdZueKrz8=
121+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260508091801-73f228e6af31 h1:FWa0vNs175LpV1eSZ60YOGFdbJ3LqxQ1fxfprBRg7T4=
122+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20260508091801-73f228e6af31/go.mod h1:/S2AN21zV70V1XuL0Of2dCjYWNkKwQSyNI8l/iQVrMs=
123+
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260520090027-4d7b7a01c0bf h1:FoKK0zNo48i4ZMFxScupCK/YAmy6Ps4IILz3CK4BCTI=
124+
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20260520090027-4d7b7a01c0bf/go.mod h1:VNX1Mda2u5+yGxycIyVrgABucitMDR9ct3Lj6ROS92I=
125125
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260518125357-72bdd580c587 h1:p03uEXoSreyu7LpFmb9YyYM8tEx2D2+7qqhLXNWHTq0=
126126
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260518125357-72bdd580c587/go.mod h1:JC04T5G4E/he5ukonV1oCqa0QzFkLv761VbLruVghJM=
127-
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20260417092244-81c71b39e981 h1:jN3Kvt+RYUTaL9EXeeeIqRXVjqeNF74SuLTDXmi4X2Y=
128-
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20260417092244-81c71b39e981/go.mod h1:7yqbVpg0k0vW+kZks+TMU/cd1ovoejyHfVPWcyGYLHI=
129-
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260417092244-81c71b39e981 h1:X3/Gc+i0ZxaROExrpLXonz9EPhftlubFnOK4aSkRLvo=
130-
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260417092244-81c71b39e981/go.mod h1:3loLaPUDQyvbPekylZd9OCLF+EXH2klRI9IeeQhuMcs=
131-
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20260417092244-81c71b39e981 h1:KAQ8T+Ri3JWgsyK1D6QybScMh6fpkYUUA+0ntnOiAl4=
132-
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20260417092244-81c71b39e981/go.mod h1:dEjz8zHRIlP3vnMmWdHytlLeSZ6BHcIiSTPM7xTQxFg=
127+
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20260506154724-30a976ba8ef0 h1:kMie+G0aHlGwDHjimjj8AUxTl2R7LGfai/8pev2T+TY=
128+
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20260506154724-30a976ba8ef0/go.mod h1:7yqbVpg0k0vW+kZks+TMU/cd1ovoejyHfVPWcyGYLHI=
129+
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260506154724-30a976ba8ef0 h1:wuzSibIT9F/5RbMmxvBVFj6fy2vtKo58nibzmk5L4PM=
130+
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260506154724-30a976ba8ef0/go.mod h1:tft3oDiN+v6wX3ILPXGUM/gCLJz6QtrPN63hxpJ3E24=
131+
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20260518125357-72bdd580c587 h1:jpouKcgs2Kc5z2JHIpvsXMxEonfXLgzX3KswuBoeKQ0=
132+
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20260518125357-72bdd580c587/go.mod h1:nLS2oK4pBo756JNN1cPgr44S0X9V11QScgVla89Ojok=
133133
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260413152655-564a51226a2a h1:1VRHhhCE8U0+Q6jPNppxcklIVfK7gZ2Js9VaLpPR7sw=
134134
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20260413152655-564a51226a2a/go.mod h1:g/xgMnzNHxdTkqnEgAKwVOv75uPN4nuApbkGqSvASvs=
135135
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=

internal/controller/nova/nova_controller.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import (
5656

5757
novav1 "github.com/openstack-k8s-operators/nova-operator/api/nova/v1beta1"
5858
"github.com/openstack-k8s-operators/nova-operator/internal/nova"
59-
"github.com/openstack-k8s-operators/nova-operator/internal/nova/api"
59+
novaapi "github.com/openstack-k8s-operators/nova-operator/internal/nova/api"
6060

6161
memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1"
6262
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
@@ -303,6 +303,22 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
303303
}
304304
}
305305

306+
if instance.Spec.Auth.ApplicationCredentialSecret != "" || instance.Status.ApplicationCredentialSecret != "" {
307+
if err := keystonev1.ManageACSecretFinalizer(ctx, h, instance.Namespace,
308+
instance.Spec.Auth.ApplicationCredentialSecret,
309+
instance.Status.ApplicationCredentialSecret,
310+
nova.ACConsumerFinalizer); err != nil {
311+
instance.Status.Conditions.Set(condition.FalseCondition(
312+
condition.ServiceConfigReadyCondition,
313+
condition.ErrorReason,
314+
condition.SeverityWarning,
315+
condition.ServiceConfigReadyErrorMessage,
316+
err.Error()))
317+
return ctrl.Result{}, err
318+
}
319+
}
320+
instance.Status.ApplicationCredentialSecret = instance.Spec.Auth.ApplicationCredentialSecret
321+
306322
instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)
307323

308324
err = r.ensureKeystoneServiceUser(ctx, h, instance)
@@ -1768,6 +1784,17 @@ func (r *NovaReconciler) reconcileDelete(
17681784
return err
17691785
}
17701786

1787+
// Remove consumer finalizer from AC secrets nova was consuming.
1788+
for _, secretName := range []string{
1789+
instance.Status.ApplicationCredentialSecret,
1790+
instance.Spec.Auth.ApplicationCredentialSecret,
1791+
} {
1792+
if err := keystonev1.RemoveACSecretConsumerFinalizer(ctx, h, instance.Namespace,
1793+
secretName, nova.ACConsumerFinalizer); err != nil {
1794+
return err
1795+
}
1796+
}
1797+
17711798
// Successfully cleaned up everything. So as the final step let's remove the
17721799
// finalizer from ourselves to allow the deletion of Nova CR itself
17731800
updated := controllerutil.RemoveFinalizer(instance, h.GetFinalizer())

internal/nova/common.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ const (
3030
NovaUserID int64 = 42436
3131
)
3232

33+
const (
34+
// ACConsumerFinalizer is added to AC secrets that nova is actively consuming
35+
ACConsumerFinalizer = "openstack.org/nova-ac-consumer"
36+
)
37+
3338
// GetScriptSecretName returns the name of the Secret used for the
3439
// db sync scripts
3540
func GetScriptSecretName(crName string) string {

test/functional/nova/nova_controller_test.go

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
3838
novav1 "github.com/openstack-k8s-operators/nova-operator/api/nova/v1beta1"
3939
controllers "github.com/openstack-k8s-operators/nova-operator/internal/controller/nova"
40+
nova "github.com/openstack-k8s-operators/nova-operator/internal/nova"
4041

4142
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4243

@@ -2157,4 +2158,164 @@ var _ = Describe("application credentials", func() {
21572158
}, timeout, interval).Should(Succeed())
21582159
})
21592160
})
2161+
2162+
When("ApplicationCredential consumer finalizer is managed", func() {
2163+
var acSecretName string
2164+
2165+
BeforeEach(func() {
2166+
acSecretName = "ac-nova-a1b2c-secret" //nolint:gosec // G101
2167+
ac := &corev1.Secret{
2168+
ObjectMeta: metav1.ObjectMeta{
2169+
Namespace: novaNames.NovaName.Namespace,
2170+
Name: acSecretName,
2171+
},
2172+
Data: map[string][]byte{
2173+
keystonev1.ACIDSecretKey: []byte("a1b2ctest-ac-id"),
2174+
keystonev1.ACSecretSecretKey: []byte("test-ac-secret"),
2175+
},
2176+
}
2177+
DeferCleanup(k8sClient.Delete, ctx, ac)
2178+
Expect(k8sClient.Create(ctx, ac)).To(Succeed())
2179+
2180+
DeferCleanup(k8sClient.Delete, ctx, CreateNovaSecret(novaNames.NovaName.Namespace, SecretName))
2181+
DeferCleanup(k8sClient.Delete, ctx, CreateNovaMessageBusSecret(cell0))
2182+
DeferCleanup(
2183+
mariadb.DeleteDBService,
2184+
mariadb.CreateDBService(
2185+
novaNames.NovaName.Namespace,
2186+
"openstack",
2187+
corev1.ServiceSpec{
2188+
Ports: []corev1.ServicePort{{Port: 3306}},
2189+
},
2190+
),
2191+
)
2192+
memcachedSpec := infra.GetDefaultMemcachedSpec()
2193+
DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(novaNames.NovaName.Namespace, MemcachedInstance, memcachedSpec))
2194+
infra.SimulateMemcachedReady(novaNames.MemcachedNamespace)
2195+
2196+
DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(novaNames.NovaName.Namespace))
2197+
2198+
rawNova := map[string]any{
2199+
"apiVersion": "nova.openstack.org/v1beta1",
2200+
"kind": "Nova",
2201+
"metadata": map[string]any{
2202+
"name": novaNames.NovaName.Name,
2203+
"namespace": novaNames.NovaName.Namespace,
2204+
},
2205+
"spec": map[string]any{
2206+
"secret": SecretName,
2207+
"apiDatabaseAccount": novaNames.APIMariaDBDatabaseAccount.Name,
2208+
"cellTemplates": map[string]any{
2209+
"cell0": map[string]any{
2210+
"cellDatabaseAccount": cell0.MariaDBAccountName.Name,
2211+
"apiDatabaseAccount": novaNames.APIMariaDBDatabaseAccount.Name,
2212+
"hasAPIAccess": true,
2213+
"dbPurge": map[string]any{
2214+
"schedule": "1 0 * * *",
2215+
},
2216+
},
2217+
},
2218+
"messagingBus": map[string]any{
2219+
"cluster": cell0.TransportURLName.Name,
2220+
},
2221+
"auth": map[string]any{
2222+
"applicationCredentialSecret": acSecretName,
2223+
},
2224+
},
2225+
}
2226+
DeferCleanup(th.DeleteInstance, th.CreateUnstructured(rawNova))
2227+
})
2228+
2229+
It("should add the consumer finalizer to the AC secret", func() {
2230+
Eventually(func(g Gomega) {
2231+
secret := th.GetSecret(types.NamespacedName{
2232+
Namespace: novaNames.NovaName.Namespace,
2233+
Name: acSecretName,
2234+
})
2235+
g.Expect(secret.Finalizers).To(
2236+
ContainElement(nova.ACConsumerFinalizer))
2237+
}, timeout, interval).Should(Succeed())
2238+
})
2239+
2240+
It("should track the consumed AC secret in status", func() {
2241+
Eventually(func(g Gomega) {
2242+
n := GetNova(novaNames.NovaName)
2243+
g.Expect(n.Status.ApplicationCredentialSecret).To(Equal(acSecretName))
2244+
}, timeout, interval).Should(Succeed())
2245+
})
2246+
2247+
It("should move the finalizer from the old to the new secret on rotation", func() {
2248+
Eventually(func(g Gomega) {
2249+
secret := th.GetSecret(types.NamespacedName{
2250+
Namespace: novaNames.NovaName.Namespace,
2251+
Name: acSecretName,
2252+
})
2253+
g.Expect(secret.Finalizers).To(
2254+
ContainElement(nova.ACConsumerFinalizer))
2255+
}, timeout, interval).Should(Succeed())
2256+
2257+
newACSecretName := "ac-nova-x9y8z-secret" //nolint:gosec // G101
2258+
newSecret := &corev1.Secret{
2259+
ObjectMeta: metav1.ObjectMeta{
2260+
Namespace: novaNames.NovaName.Namespace,
2261+
Name: newACSecretName,
2262+
},
2263+
Data: map[string][]byte{
2264+
keystonev1.ACIDSecretKey: []byte("x9y8zrotated-ac-id"),
2265+
keystonev1.ACSecretSecretKey: []byte("rotated-ac-secret"),
2266+
},
2267+
}
2268+
DeferCleanup(k8sClient.Delete, ctx, newSecret)
2269+
Expect(k8sClient.Create(ctx, newSecret)).To(Succeed())
2270+
2271+
Eventually(func(g Gomega) {
2272+
n := GetNova(novaNames.NovaName)
2273+
n.Spec.Auth.ApplicationCredentialSecret = newACSecretName
2274+
g.Expect(k8sClient.Update(ctx, n)).Should(Succeed())
2275+
}, timeout, interval).Should(Succeed())
2276+
2277+
Eventually(func(g Gomega) {
2278+
secret := th.GetSecret(types.NamespacedName{
2279+
Namespace: novaNames.NovaName.Namespace,
2280+
Name: newACSecretName,
2281+
})
2282+
g.Expect(secret.Finalizers).To(
2283+
ContainElement(nova.ACConsumerFinalizer))
2284+
}, timeout, interval).Should(Succeed())
2285+
2286+
Eventually(func(g Gomega) {
2287+
secret := th.GetSecret(types.NamespacedName{
2288+
Namespace: novaNames.NovaName.Namespace,
2289+
Name: acSecretName,
2290+
})
2291+
g.Expect(secret.Finalizers).NotTo(
2292+
ContainElement(nova.ACConsumerFinalizer))
2293+
}, timeout, interval).Should(Succeed())
2294+
2295+
Eventually(func(g Gomega) {
2296+
n := GetNova(novaNames.NovaName)
2297+
g.Expect(n.Status.ApplicationCredentialSecret).To(Equal(newACSecretName))
2298+
}, timeout, interval).Should(Succeed())
2299+
})
2300+
2301+
It("should remove the consumer finalizer from AC secret on CR deletion", func() {
2302+
Eventually(func(g Gomega) {
2303+
secret := th.GetSecret(types.NamespacedName{
2304+
Namespace: novaNames.NovaName.Namespace,
2305+
Name: acSecretName,
2306+
})
2307+
g.Expect(secret.Finalizers).To(
2308+
ContainElement(nova.ACConsumerFinalizer))
2309+
}, timeout, interval).Should(Succeed())
2310+
2311+
th.DeleteInstance(GetNova(novaNames.NovaName))
2312+
2313+
secret := th.GetSecret(types.NamespacedName{
2314+
Namespace: novaNames.NovaName.Namespace,
2315+
Name: acSecretName,
2316+
})
2317+
Expect(secret.Finalizers).NotTo(
2318+
ContainElement(nova.ACConsumerFinalizer))
2319+
})
2320+
})
21602321
})

0 commit comments

Comments
 (0)