Skip to content

Add IsReadyForInput to statefulset and deployment packages - #733

Merged
stuggi merged 1 commit into
openstack-k8s-operators:mainfrom
lmiccini:ensure-fresh
Aug 18, 2026
Merged

Add IsReadyForInput to statefulset and deployment packages#733
stuggi merged 1 commit into
openstack-k8s-operators:mainfrom
lmiccini:ensure-fresh

Conversation

@lmiccini

@lmiccini lmiccini commented Aug 13, 2026

Copy link
Copy Markdown
Contributor
Each package now exposes IsReadyForInput, which reads the workload
directly from a client.Reader (typically an uncached API reader) and
confirms that the rollout is complete AND the pod template carries a
CONFIG_HASH environment variable matching the expected value.

This lets child controllers verify their StatefulSet/Deployment is
truly running the desired configuration before reporting readiness,
eliminating the informer cache race where stale status could cause a
parent to release credential finalizers prematurely.

@lmiccini lmiccini changed the title Add EnsureFresh helper to bypass informer cache during rotation Add IsReadyForInput to statefulset and deployment packages Aug 14, 2026
@lmiccini
lmiccini force-pushed the ensure-fresh branch 2 times, most recently from 59e9f79 to 299ce44 Compare August 14, 2026 08:24
IsReadyForInput reads a StatefulSet/Deployment directly from an uncached
API reader and reports whether the workload is fully rolled out with the
expected configuration: IsReady must pass and a container must carry a
CONFIG_HASH env var whose literal value equals the expected hash. This lets
a parent correlate a child's readiness with the specific input it applied,
so a rotated secret's old consumer finalizer is only released once the new
config has provably rolled out.

Config-hash matching lives in a single shared helper, env.ConfigHashMatches:
- An empty configHash never matches, so a not-yet-computed (or cleared) hash
  cannot be treated as "applied" and trigger a premature finalizer release.
- Both init and regular containers are scanned.
- Only a literal CONFIG_HASH value is compared; a value sourced via ValueFrom
  is ignored, per the operator convention of injecting a literal hash.

deployment.ConfigHashEnvVar and statefulset.ConfigHashEnvVar are kept as
aliases of env.ConfigHashEnvVar for backward compatibility.

The Helper.apiReader field and its Get/SetAPIReader accessors are omitted:
call sites pass the reconciler's own APIReader directly to IsReadyForInput,
so a Helper-held reader would be an unused nil-default footgun.

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

@stuggi stuggi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm

@stuggi
stuggi merged commit e18950d into openstack-k8s-operators:main Aug 18, 2026
2 checks passed
@lmiccini
lmiccini deleted the ensure-fresh branch August 18, 2026 07:42
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