Skip to content

Commit e722b54

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

14 files changed

Lines changed: 310 additions & 30 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: 49 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,24 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
303303
}
304304
}
305305

306+
// Add consumer finalizer to the new AC secret early, before deployment.
307+
// The old secret's finalizer is removed later (after all services deploy)
308+
// so that rapid rotations don't revoke a credential still in use by pods.
309+
if instance.Spec.Auth.ApplicationCredentialSecret != "" {
310+
if err := keystonev1.ManageACSecretFinalizer(ctx, h, instance.Namespace,
311+
instance.Spec.Auth.ApplicationCredentialSecret,
312+
"",
313+
nova.ACConsumerFinalizer); err != nil {
314+
instance.Status.Conditions.Set(condition.FalseCondition(
315+
condition.ServiceConfigReadyCondition,
316+
condition.ErrorReason,
317+
condition.SeverityWarning,
318+
condition.ServiceConfigReadyErrorMessage,
319+
err.Error()))
320+
return ctrl.Result{}, err
321+
}
322+
}
323+
306324
instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)
307325

308326
err = r.ensureKeystoneServiceUser(ctx, h, instance)
@@ -774,6 +792,25 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
774792
)
775793
}
776794

795+
// Manage the old AC secret's finalizer and status tracking.
796+
// On rotation (old != new), only remove the old secret's finalizer after
797+
// all sub-services are ready with the new credentials. This prevents
798+
// premature revocation during rapid rotations.
799+
isRotation := instance.Status.ApplicationCredentialSecret != "" && instance.Status.ApplicationCredentialSecret != instance.Spec.Auth.ApplicationCredentialSecret
800+
801+
if isRotation {
802+
allServicesReady := instance.Status.Conditions.AllSubConditionIsTrue()
803+
if allServicesReady {
804+
if err := keystonev1.RemoveACSecretConsumerFinalizer(ctx, h, instance.Namespace,
805+
instance.Status.ApplicationCredentialSecret, nova.ACConsumerFinalizer); err != nil {
806+
return ctrl.Result{}, err
807+
}
808+
instance.Status.ApplicationCredentialSecret = instance.Spec.Auth.ApplicationCredentialSecret
809+
}
810+
} else {
811+
instance.Status.ApplicationCredentialSecret = instance.Spec.Auth.ApplicationCredentialSecret
812+
}
813+
777814
Log.Info("Successfully reconciled")
778815
return ctrl.Result{}, nil
779816
}
@@ -1768,6 +1805,17 @@ func (r *NovaReconciler) reconcileDelete(
17681805
return err
17691806
}
17701807

1808+
// Remove consumer finalizer from AC secrets nova was consuming.
1809+
for _, secretName := range []string{
1810+
instance.Status.ApplicationCredentialSecret,
1811+
instance.Spec.Auth.ApplicationCredentialSecret,
1812+
} {
1813+
if err := keystonev1.RemoveACSecretConsumerFinalizer(ctx, h, instance.Namespace,
1814+
secretName, nova.ACConsumerFinalizer); err != nil {
1815+
return err
1816+
}
1817+
}
1818+
17711819
// Successfully cleaned up everything. So as the final step let's remove the
17721820
// finalizer from ourselves to allow the deletion of Nova CR itself
17731821
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 {

0 commit comments

Comments
 (0)