Repository navigation
Conversation
|
❗ By default, the pull request is configured to backport to all release branches.
|
…list too long errors This change sets enableServiceLinks to false in all bootstrap job pod specs (initdb, join, recovery, etc.) to prevent the 'exec /manager: argument list too long' error that occurs in namespaces with many services. While PR cloudnative-pg#6323 fixed this issue for regular cluster instance pods by introducing the cnpg.io/podPatch annotation, bootstrap jobs are created separately and were not covered by that fix. Since these jobs use the same bootstrap-controller init container that fails when receiving excessive environment variables from Kubernetes service links, they experience the same issue in high-density namespaces. This issue was reported in a production environment with 465 PostgreSQL databases in a single namespace, where the bootstrap controller in job pods would fail to start during cluster initialization or when adding new replicas. Bootstrap jobs do not require service discovery via environment variables as they use DNS or explicit connection strings from secrets, making this a safe default. Fixes cloudnative-pg#6234 Signed-off-by: Jonathan Siegel <[email protected]>
|
Hi @usiegj00, thank you so much for your contribution and apologies for the delay. In today's office hours, we agreed to set |
Extend the enableServiceLinks=false default from bootstrap jobs to the PostgreSQL instance pods. Setting EnableServiceLinks to false on the instance PodSpec built by createClusterPodSpec prevents the "exec /manager: argument list too long" error in namespaces with many services, without relying on the cnpg.io/podPatch annotation workaround from cloudnative-pg#6323. Also aligns the service-links field formatting in the bootstrap job spec. Signed-off-by: Jonathan Siegel <[email protected]>
|
Thanks @gbartolini, and no problem on the delay. I've updated the PR to match the office-hours decision:
|
|
@gbartolini could this get merged? I really want to see this in the new release. It fixes bugs and actually also fixes performance issues for wal-restore and backups. We have 25k environment variables and https://github.com/cloudnative-pg/plugin-barman-cloud/blob/2db8cc37074254633293762a3a1b33b88334f5ca/internal/cnpgi/common/common.go#L76-L99 is an O(n^2) algorithm. There is a fix for the algorithm here: cloudnative-pg/plugin-barman-cloud#1114, but it would not have been a problem if the 25k environment variables was not there in the first place. |
gnarlex
left a comment
There was a problem hiding this comment.
Thanks for you contribution :) Change is quite small and shouldn't cause regressions, since nothing depends on the service links.
@gbartolini could you review as well?
Create the bootstrap pod with enableServiceLinks: false, so Kubernetes no longer injects environment variables for every Service in the namespace into it. The bootstrap pod does not use these variables. In a namespace with many Services they make the container fail to start with "argument list too long". Setting the value in the operator also removes the need for a mutating policy (such as Kyverno) to set it. On releases without the fix for opensearch-project#1364, such a policy makes the operator recreate the bootstrap pod in a loop. CloudNativePG made the same change for its bootstrap job pods (cloudnative-pg/cloudnative-pg#8943, which fixes cloudnative-pg/cloudnative-pg#6234). Signed-off-by: Daniil Molkov <[email protected]>
Summary
This PR fixes the "argument list too long" error in bootstrap job pods that occurs in namespaces with many services, completing the fix started in PR #6323.
Problem
Issue #6234 reported that bootstrap controller containers fail with
exec /manager: argument list too longin namespaces with many services (reported in production with 465 PostgreSQL databases).Critical limitation: Even with the
cnpg.io/podPatchannotation settingenableServiceLinks: falsefor regular cluster instance pods (fixed in PR #6323), clusters still cannot launch at this scale because bootstrap job pods were not covered by that fix.Why job pods are affected:
pkg/specs/jobs.goviaCreatePrimaryJob()buildInstance()function where the patch annotation is appliedSolution
Set
enableServiceLinks: falsedirectly in the job pod spec inpkg/specs/jobs.go. This affects all bootstrap job types:initdbjobs (initialize new cluster)joinjobs (join replica to cluster)pg_basebackupjobsAlternative Solutions Considered
We considered several approaches:
cnpg.io/podPatchannotation to cover job podsenableServiceLinksHowever, setting
enableServiceLinks: falsedirectly in the job spec appears to have no negative side-effects. Bootstrap jobs do not require service discovery via environment variables as they use DNS or explicit connection strings from secrets, making this a safe and simple default that resolves this critical aspect of large-cluster scaling challenges.Testing
EnableServiceLinksis set tofalseRelated Issues
Fixes #6234