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

Copy link
Copy Markdown
Contributor

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 consumer finalizer to the current transport URL secret early in reconcile. Set instance.Status.TransportURLSecret for first-time setup only (when empty or unchanged); during rotation the status is updated solely by FinalizeSecretRotation at 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. Use statefulset.IsReady() / deployment.IsReady() from lib-common in all sub-CR controllers for accurate rollout status.

  4. Use object.ManageRotationGracePeriod() to enforce a 60-second grace period before evaluating the rotation guard. This gives sub-CRs time to detect config changes, update their workloads, and roll pods — without relying on informer cache freshness.

  5. Guard: CredentialRotationGuardReady(true, conditions) — evaluates AllSubConditionIsTrue after the grace period expires. Only when all sub-CR conditions are True does FinalizeSecretRotation remove the consumer finalizer from the old secret.

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

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 consumer finalizer to the current transport URL secret early
   in reconcile. Set instance.Status.TransportURLSecret for first-time
   setup only (when empty or unchanged); during rotation the status
   is updated solely by FinalizeSecretRotation at 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. Use statefulset.IsReady() / deployment.IsReady() from lib-common
   in all sub-CR controllers for accurate rollout status.

4. Use object.ManageRotationGracePeriod() to enforce a 60-second
   grace period before evaluating the rotation guard. This gives
   sub-CRs time to detect config changes, update their workloads,
   and roll pods — without relying on informer cache freshness.

5. Guard: CredentialRotationGuardReady(true, conditions) — evaluates
   AllSubConditionIsTrue after the grace period expires. Only when
   all sub-CR conditions are True does FinalizeSecretRotation remove
   the consumer finalizer from the old secret.

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@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

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