Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report: Custom leader label values not applied due to env filtering #1105

Open
arthlr opened this issue Apr 10, 2025 · 0 comments
Open

Comments

@arthlr
Copy link

arthlr commented Apr 10, 2025

The environment variables KUBERNETES_LEADER_LABEL_VALUE and KUBERNETES_STANDBY_LEADER_LABEL_VALUE are not available within the Patroni process due to Spilo’s default environment variable filtering in the entrypoint script. This prevents custom leader label values from being applied correctly.

Steps to Reproduce

  • Set KUBERNETES_LEADER_LABEL_VALUE or KUBERNETES_STANDBY_LEADER_LABEL_VALUE in the Spilo environment.
  • Deploy Spilo and observe the runtime environment of the Patroni
  • Trigger the callback_role.py callback during a role
  • Notice that LEADER_LABEL_VALUE falls back to default instead of using the intended custom value.

Expected Behavior

The variables should be available to Patroni at runtime, allowing the callback_role.py script to correctly use the customized label values.

Actual Behavior

The variables are filtered out and not exposed to the Patroni subprocess, leading to unintended fallback behavior in the callback logic.

Environment

  • Spilo version: spilo-17:4.0-p2
  • Postgres-Operator: 1.14
  • Patroni: 4.0.4
  • Kubernetes: 1.31

Proposed Fix

Update the run script to include KUBERNETES_LEADER_LABEL_VALUE and KUBERNETES_STANDBY_LEADER_LABEL_VALUE in the whitelist of environment variables passed to the Patroni subprocess.

Additional Context

This issue critically affects Patroni clusters that depend on customized Kubernetes label values to manage cluster behavior—particularly for endpoint updates. When these environment variables are not exposed to the callback_role.py script, Kubernetes endpoint updates may silently be skip, potentially rendering the cluster unreachable or unavailable.

The bug effectively nullifies any configuration relying on KUBERNETES_LEADER_LABEL_VALUE and KUBERNETES_STANDBY_LEADER_LABEL_VALUE, as the callback script cannot access these values at runtime.

As a result, this issue has become a blocker for upgrading to:

  • Postgres-Operator v1.14
  • PostgreSQL 17
  • Patroni 4

Let me know if you'd like me to create a follow-up issue for documentation updates or to cross-reference this issue with the associated Pull Request.

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

No branches or pull requests

1 participant