Skip to content

Add transport URL secret rotation with consumer finalizer - #428

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#428
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 requested a review from afaranha August 11, 2026 11:40
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

[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 millevy 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

@openshift-ci
openshift-ci Bot requested a review from mauricioharley August 11, 2026 11:40
@lmiccini
lmiccini force-pushed the finalize-secret-rotation branch from ebacebe to f65df4a Compare August 13, 2026 09:39
@lmiccini
lmiccini force-pushed the finalize-secret-rotation branch from f65df4a to 8abe575 Compare August 17, 2026 08:41
@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/3eb0b3ceaa1b4d12b0300aaf6d3354c3

openstack-k8s-operators-content-provider FAILURE in 12m 42s
⚠️ barbican-operator-kuttl SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider (non-voting)
⚠️ barbican-operator-tempest SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider (non-voting)

@lmiccini
lmiccini force-pushed the finalize-secret-rotation branch 2 times, most recently from 1c1d6e9 to f24d92a Compare August 18, 2026 10:25
@lmiccini

Copy link
Copy Markdown
Contributor Author

/test precommit-check

@lmiccini
lmiccini force-pushed the finalize-secret-rotation branch from f24d92a to 19f8039 Compare August 19, 2026 08:15
@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: f933c717-0004-4aba-a5a5-cf8ad518691c


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 22, 2026

Copy link
Copy Markdown

PR needs rebase.

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant