Skip to content

Add transport URL secret rotation with consumer finalizer - #982

Open
lmiccini wants to merge 1 commit into
openstack-k8s-operators:mainfrom
lmiccini:finalize-secret-rotation
Open

Add transport URL secret rotation with consumer finalizer#982
lmiccini wants to merge 1 commit into
openstack-k8s-operators:mainfrom
lmiccini:finalize-secret-rotation

Conversation

@lmiccini

@lmiccini lmiccini commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

What this does

When infra-operator rotates a RabbitMQ transport URL (creating a new secret and user), consumer operators must hold a consumer finalizer on the old secret until all their pods have rolled out with the new credentials. Without this, infra-operator cleans up the old RabbitMQ user while pods are still connected with the old credentials, causing message-bus outages.

Approach (updated)

Note: this PR was reworked from the original grace-period design to an event-driven "applied input hash" design. The old approach released the finalizer after a fixed grace period based on the parent Ready condition, which was racy against the informer cache and could revoke credentials prematurely. The new approach releases the finalizer only once every child has provably rolled out.

  1. Add a consumer finalizer to the current transport URL secret early in reconcile. Status.TransportURLSecret is set for first-time setup only (empty or unchanged); during rotation the status is updated solely by FinalizeSecretRotation at the end of reconcile.

  2. Pass transportURL.Status.SecretName directly to sub-CR creation and config generation as a parameter — never read Status.TransportURLSecret for sub-CR specs.

  3. Each child controller records an AppliedInputSecretHash in its status, set only after statefulset.IsReadyForInput / deployment.IsReadyForInput confirms — via an uncached API read — that the workload is fully rolled out with the expected CONFIG_HASH.

  4. The parent mirrors a child's Ready condition only when its Generation == ObservedGeneration and AppliedInputSecretHash matches the current input hash; otherwise it sets the condition to Unknown.

  5. Guard: FinalizeSecretRotation removes the consumer finalizer from the old secret only when every child reports the expected hash and is ready. The guard is computed from Conditions.AllSubConditionIsTrue() (not IsReady()), because Conditions.Init() resets the Ready condition to Unknown on every reconcile.

The same pattern applies to notification transport URL secrets and application-credential secrets where applicable.

Dependency

Depends on the lib-common IsReadyForInput / FinalizeSecretRotation helpers (currently pinned via a replace to the fork commit while the lib-common PR is in review).

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lmiccini
Once this PR has been reviewed and has the lgtm label, please assign paramite for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@centosinfra-prod-github-app

Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/rdoproject.org/buildset/9494d42f46854fca8444aa9d344dfbc8

✔️ telemetry-openstack-meta-content-provider-master SUCCESS in 3h 01m 44s
telemetry-operator-multinode-cloudkitty RETRY_LIMIT in 7m 02s
✔️ telemetry-openstack-meta-content-provider-all-services-master SUCCESS in 2h 47m 32s
✔️ telemetry-operator-multinode-master SUCCESS in 1h 46m 46s
✔️ openstack-k8s-operators-content-provider SUCCESS in 1h 58m 29s
✔️ telemetry-operator-multinode-default-telemetry SUCCESS in 1h 39m 57s
✔️ functional-tests-osp18 SUCCESS in 2h 19m 13s

@lmiccini

Copy link
Copy Markdown
Contributor Author

/test telemetry-operator-build-deploy

@lmiccini

Copy link
Copy Markdown
Contributor Author

recheck

Comment on lines +766 to +768
if instance.Status.NotificationsURLSecret != nil {
rotationPending = *instance.Status.NotificationsURLSecret != "" &&
*instance.Status.NotificationsURLSecret != currentNotifSecret

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instance.Status.NotificationsURLSecret variable is unconditionally overwritten before rotationPending is calculated and it never changes so that means that here, the "*instance.Status.NotificationsURLSecret != currentNotifSecret" condition is always false, and thus this controller never activates the 60-second grace period.

This also happens in ceilometer_controller, but it is correctly handled in the cloudkitty_controller.

This might do the trick:

Suggested change
if instance.Status.NotificationsURLSecret != nil {
rotationPending = *instance.Status.NotificationsURLSecret != "" &&
*instance.Status.NotificationsURLSecret != currentNotifSecret
rotationPending := oldNotifSecret != "" && oldNotifSecret != currentNotifSecret

Comment on lines +914 to +918
rotationPending := false
if instance.Status.NotificationsURLSecret != nil {
rotationPending = *instance.Status.NotificationsURLSecret != "" &&
*instance.Status.NotificationsURLSecret != currentNotifSecret
}

@jlarriba jlarriba Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in autoscaling, this could be:

Suggested change
rotationPending := false
if instance.Status.NotificationsURLSecret != nil {
rotationPending = *instance.Status.NotificationsURLSecret != "" &&
*instance.Status.NotificationsURLSecret != currentNotifSecret
}
rotationPending := oldNotifSecret != "" && oldNotifSecret != currentNotifSecret

@lmiccini
lmiccini force-pushed the finalize-secret-rotation branch from 33b3a65 to b1ff781 Compare August 17, 2026 08:42
@centosinfra-prod-github-app

Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/rdoproject.org/buildset/738dc346f355489b98355c15fb6e1e37

✔️ telemetry-openstack-meta-content-provider-master SUCCESS in 3h 53m 34s
telemetry-operator-multinode-cloudkitty RETRY_LIMIT in 10m 27s
✔️ telemetry-openstack-meta-content-provider-all-services-master SUCCESS in 4h 15m 35s
✔️ telemetry-operator-multinode-master SUCCESS in 1h 42m 17s
✔️ openstack-k8s-operators-content-provider SUCCESS in 2h 28m 12s
✔️ telemetry-operator-multinode-default-telemetry SUCCESS in 1h 39m 27s
✔️ functional-tests-osp18 SUCCESS in 2h 21m 12s

@lmiccini
lmiccini force-pushed the finalize-secret-rotation branch 2 times, most recently from 0f28b65 to 507992b Compare August 19, 2026 11:22
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: cdef839e-4a59-406f-8161-88a89b00a5fb


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

When infra-operator rotates a RabbitMQ transport URL (creating a new
secret and user), consumer operators must hold a consumer finalizer on
the old secret until all their pods have rolled out with the new
credentials. Without this, infra-operator cleans up the old RabbitMQ
user while pods are still connected with old credentials, causing
message bus outages.

Design:

1. Add a consumer finalizer to the current transport URL secret early
   in reconcile. Set instance.Status.TransportURLSecret for first-time
   setup only (empty or unchanged); during rotation the status is
   updated solely by FinalizeSecretRotation at the end of reconcile.

2. Pass transportURL.Status.SecretName directly to sub-CR creation
   functions and config generation as a parameter — never read from
   instance.Status.TransportURLSecret for sub-CR specs.

3. Each child (sub-CR) controller records an AppliedInputSecretHash in
   its status, set only after statefulset.IsReadyForInput /
   deployment.IsReadyForInput confirms — via an uncached API read —
   that the workload is fully rolled out with the expected CONFIG_HASH.

4. The parent mirrors a child's Ready condition only when its
   Generation == ObservedGeneration and AppliedInputSecretHash matches
   the current input hash; otherwise it sets the condition to Unknown.

5. Guard: FinalizeSecretRotation removes the consumer finalizer from
   the old secret only when every child reports the expected hash and
   is ready.

The same pattern applies to notification transport URL secrets and
application credential secrets where applicable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@lmiccini: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/telemetry-operator-build-deploy-kuttl 507992b link true /test telemetry-operator-build-deploy-kuttl

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@centosinfra-prod-github-app

Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/rdoproject.org/buildset/3ae269ef1732440fa3ee5081a1966774

✔️ telemetry-openstack-meta-content-provider-master SUCCESS in 3h 08m 39s
telemetry-operator-multinode-cloudkitty NODE_FAILURE Node(set) request 099-0000174807 failed in 0s
✔️ telemetry-openstack-meta-content-provider-all-services-master SUCCESS in 1h 23m 54s
telemetry-operator-multinode-master NODE_FAILURE Node(set) request 099-0000174836 failed in 0s
✔️ openstack-k8s-operators-content-provider SUCCESS in 2h 09m 18s
✔️ telemetry-operator-multinode-default-telemetry SUCCESS in 1h 43m 53s
✔️ functional-tests-osp18 SUCCESS in 2h 28m 47s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants