Skip to content

fix(auth): persist generated auth secret and enforce fallback projection - #5

Merged
immanuel-peter merged 4 commits into
mainfrom
issue/fix-auth-secret-desired-state
Mar 1, 2026
Merged

fix(auth): persist generated auth secret and enforce fallback projection#5
immanuel-peter merged 4 commits into
mainfrom
issue/fix-auth-secret-desired-state

Conversation

@immanuel-peter

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the auth-default regression where clusters could run without requirepass when spec.authSecret was omitted.

Closes #4.

Problem

When spec.authSecret was nil:

  • Controller generated <cluster>-auth but did not persist it in desired state.
  • Instance manager only applied auth when spec.authSecret was present.
  • Result: Redis could stay unauthenticated despite an auth Secret existing.

What changed

  • Controller now persists auto-generated auth reference to spec.authSecret on the main RedisCluster resource.
  • Secret reconciliation now uses an effective auth-secret resolver with deterministic fallback to <cluster>-auth.
  • Instance manager applies the same resolver for requirepass/masterauth.
  • Added a dedicated fatal path for upgrades/transient windows:
    • if fallback <cluster>-auth/password is missing or empty, reconcile now returns an error instead of silently continuing.
  • Docs updated to reflect default auth generation + persistence + enforcement.
  • Smoke test hardened:
    • unauthenticated redis-cli ping must fail (NOAUTH/auth-required),
    • authenticated ping must succeed.

Tests

  • Added controller unit test verifying persisted spec.authSecret for auto-generated auth.
  • Added instance-manager unit tests for:
    • fallback auth success,
    • fallback auth missing => explicit error,
    • top-level reconcile treats fallback-missing as fatal.
  • Existing tests updated where needed for explicit auth secret setup.
  • Validation run:
    • go test ./... passed
    • make lint passed

- patch `RedisCluster.spec.authSecret` when auto-generating `<cluster>-auth`
- resolve effective auth secret consistently in controller and instance manager
- fail instance reconcile when fallback `<cluster>-auth/password` is missing or empty
- add unit tests for persisted spec and fatal fallback-auth behavior
- harden smoke test to assert unauthenticated `PING` fails and authenticated `PING` succeeds
- update docs to describe default auth generation, persistence, and enforcement
@cursor

cursor Bot commented Feb 28, 2026

Copy link
Copy Markdown

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on March 20.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb5e740f85

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
}

authSecretName := effectiveAuthSecretName(cluster)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle empty authSecret names before applying fallback

reconcileSecrets now derives authSecretName via effectiveAuthSecretName, which falls back to <cluster>-auth when spec.authSecret.name is blank, but the auto-generation/persistence path still runs only when spec.authSecret is nil. Because the CRD schema requires name but does not enforce a non-empty value (config/crd/bases/redis.io_redisclusters.yaml), a cluster with authSecret: {name: ""} skips ensureAuthSecret yet still uses fallback resolution, so the projected password file is never guaranteed and the instance reconciler can repeatedly hit errFallbackAuthSecretUnavailable instead of converging.

Useful? React with 👍 / 👎.

- install envtest tools before running integration tests in CI
- make cross-cluster integration test use explicit auth secret config
- replace pgrep-based redis kill with /proc scan for container portability
- remove unsupported redis-benchmark flag in chaos rolling update test
- isolate chaos write/probe keys from baseline integrity key prefixes
- harden fencing-annotation polling with bounded API get timeout
- retry unauthenticated smoke ping checks and exec explicitly in redis container
- ignore temp logs directory in .gitignore
- project auth/ACL keys as /projected/<secret>/<key> for data and sentinel pods
- update projection tests to assert KeyToPath mappings
- run rolling-update benchmark in a dedicated client pod outside Redis restarts
- wait for failover via fence/phase/primary-change and fix fence poll context
- authenticate local instance-manager Redis client using projected auth secret
- add helper functions and tests for effective auth secret resolution
- force authenticated leader key scans and prefer ready pods for chaos client commands
- wait for leader reachability before chaos baseline flush/write operations
- run primary-kill workload from dedicated workload client pod
- replace rolling-update redis-benchmark with a resilient cancellable write loop
- avoid rolling workload key-prefix collisions with integrity assertions
- drop brittle rolling-update offset regression check across primary restarts
@immanuel-peter
immanuel-peter merged commit ae628b3 into main Mar 1, 2026
9 checks passed
@immanuel-peter
immanuel-peter deleted the issue/fix-auth-secret-desired-state branch March 1, 2026 06:34
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.

Auto-generated auth secret is not persisted in desired state, allowing Redis to run without auth

1 participant