Skip to content

Add credential rotation helpers for secret rotation#706

Open
lmiccini wants to merge 2 commits into
openstack-k8s-operators:mainfrom
lmiccini:finalize-secret-rotation
Open

Add credential rotation helpers for secret rotation#706
lmiccini wants to merge 2 commits into
openstack-k8s-operators:mainfrom
lmiccini:finalize-secret-rotation

Conversation

@lmiccini

@lmiccini lmiccini commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Add shared helpers for transport URL secret rotation across all
openstack-k8s-operators consumer operators:

  • object.ManageSecretConsumerFinalizer: adds a consumer finalizer
    to a secret so the provider knows consumers still depend on it
  • object.RemoveSecretConsumerFinalizer: removes the finalizer
  • object.FinalizeSecretRotation: the rotation guard — if old != new
    and guard is ready, removes finalizer from old and returns new;
    otherwise returns old to preserve the reference
  • object.ManageRotationGracePeriod: time-based grace period that
    gives sub-CRs time to detect config changes, roll pods, and
    update conditions before the guard evaluates readiness
  • condition.CredentialRotationGuardReady: returns true when all
    sub-CR specs are stable and all mirrored conditions are True
  • condition.ServiceInstanceIsReady: generation/observedGeneration
    guard with replica count and DeploymentReadyCondition check
  • statefulset.IsReady: checks ReadyReplicas, UpdatedReplicas,
    ObservedGeneration, and CurrentRevision == UpdateRevision so
    DeploymentReady is only True when all pods have rolled
  • deployment.IsReady: checks ReadyReplicas, UpdatedReplicas,
    Status.Replicas, and ObservedGeneration

Note: statefulset.IsReady now additionally requires
CurrentRevision == UpdateRevision compared to the previous
implementation. This tightens the readiness check to prevent
declaring ready during in-progress rolling updates.

@lmiccini lmiccini force-pushed the finalize-secret-rotation branch 9 times, most recently from d67d41c to a7dc750 Compare June 24, 2026 06:39
@lmiccini lmiccini changed the title Add credential rotation helpers and EnsureFresh cache bypass Add credential rotation helpers for secret rotation Jun 24, 2026
@lmiccini lmiccini force-pushed the finalize-secret-rotation branch 3 times, most recently from eb31dc5 to 24d9d88 Compare June 24, 2026 07:22
Comment thread modules/common/object/metadata.go Outdated
Comment thread modules/common/condition/funcs.go Outdated
Comment thread modules/common/statefulset/statefulset.go
Comment thread modules/common/object/metadata.go Outdated
Add shared helpers for transport URL secret rotation across all
openstack-k8s-operators consumer operators:

- object.ManageSecretConsumerFinalizer: adds a consumer finalizer
  to a secret so the provider knows consumers still depend on it
- object.RemoveSecretConsumerFinalizer: removes the finalizer
- object.FinalizeSecretRotation: the rotation guard — if old != new
  and guard is ready, removes finalizer from old and returns new;
  otherwise returns old to preserve the reference
- object.ManageRotationGracePeriod: time-based grace period that
  gives sub-CRs time to detect config changes, roll pods, and
  update conditions before the guard evaluates readiness
- condition.CredentialRotationGuardReady: returns true when all
  sub-CR specs are stable and all mirrored conditions are True
- condition.ServiceInstanceIsReady: generation/observedGeneration
  guard with replica count and DeploymentReadyCondition check
- statefulset.IsReady: checks ReadyReplicas, UpdatedReplicas,
  ObservedGeneration, and CurrentRevision == UpdateRevision so
  DeploymentReady is only True when all pods have rolled
- deployment.IsReady: checks ReadyReplicas, UpdatedReplicas,
  Status.Replicas, and ObservedGeneration

Note: statefulset.IsReady now additionally requires
CurrentRevision == UpdateRevision compared to the previous
implementation. This tightens the readiness check to prevent
declaring ready during in-progress rolling updates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lmiccini lmiccini force-pushed the finalize-secret-rotation branch from 24d9d88 to 5ec8001 Compare June 24, 2026 11:59
SimulateStatefulSetReplicaReadyWithPods and
SimulateDeploymentReadyWithPods fail when called multiple times
because they unconditionally Create pods that may already exist.
This prevents using them inside Eventually loops, which is needed
for operators like designate where multiple controllers compete
and readiness simulation must be retried.

Changes:
- Check if pod exists before creating; update annotations on
  existing pods instead of failing
- Fix nil Annotations map that could panic when template has
  no annotations
- Use deterministic pod names for Deployments ({name}-{index}
  instead of GenerateName) so pods can be found on re-call

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