[release-v1.43] fix(apiserver): allow queryserver egress to Linseed via guardian on managed clusters - #5261
Merged
rene-dekker merged 1 commit intoAug 28, 2026
Conversation
…anaged clusters A managed cluster runs no local Linseed, so the queryserver reaches it through guardian. The apiserver-access policy only permitted the local Linseed pods, which select nothing on a managed cluster, so the request fell through to the trailing Pass and was denied by whatever the customer's tiers enforce. Branch the rule on ManagementClusterConnection, the same condition LINSEED_URL already uses. The calico-system policy table already had managed entries, but SelectPolicyByProvider only switches on the provider, so both managed cases were asserting the unmanaged fixture and could not have caught this. Switch to SelectPolicyByClusterTypeAndProvider and add the managed fixtures. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a managed-cluster connectivity gap where the API server’s query server could not reach Linseed via Guardian due to the calico-system.apiserver-access policy only allowing egress to the (non-existent) local Linseed pods on managed clusters, causing policy-related UI/API calls to fail under customer default-deny tiers.
Changes:
- Add an explicit egress allow rule to Guardian when
ManagementClusterConnectionis present (managed cluster case), ensuring it is evaluated before the trailingPass. - Add managed-cluster expected-policy fixtures (standard + OpenShift DNS variants).
- Update the calico-system policy rendering table test to select expected fixtures by both cluster type and provider, and add targeted unit tests for the Guardian egress rule.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/render/apiserver.go | Conditionally appends Guardian egress allow rule for managed clusters before adding the trailing Pass rule. |
| pkg/render/apiserver_test.go | Adds unit tests for the managed Guardian egress rule and updates fixture selection logic to cover managed/unmanaged + OpenShift combinations. |
| pkg/render/testutils/expected_policies/apiserver_managed.json | New expected calico-system apiserver-access policy fixture for managed (non-OpenShift DNS) clusters, including Guardian egress allow. |
| pkg/render/testutils/expected_policies/apiserver_managed_ocp.json | New expected fixture for managed OpenShift clusters, including OpenShift DNS rules and Guardian egress allow. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Brian-McM
approved these changes
Aug 28, 2026
rene-dekker
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Cherry-pick of #5240.
A managed cluster runs no local Linseed, so the query server reaches it through guardian —
the URL
LinseedEndpointreturns asLINSEED_URL. Thecalico-system.apiserver-accesspolicy permitted only the local Linseed pods, whose selector matches nothing on a managed
cluster, so the connection fell through to the policy's trailing
Pass. Thecalico-systemtier's default-deny excludes
calico-apiserverby design, so the traffic is then evaluatedagainst the customer's tiers, where any default-deny drops it. The Manager policy board
renders empty and policy activity requests return 500.
This branch predates the
pkg/enterprise/apiserverextension mechanism (#4871), so the ruleis branched directly in
calicoSystemAPIServerPolicyoncfg.ManagementClusterConnection—the same condition
LINSEED_URLalready uses a few hundred lines away in the same file.The
calico-systempolicy table already hadfor managedentries, butSelectPolicyByProvideronly switches on the provider, so both managed cases were assertingthe unmanaged fixture and could not have caught this. The table now uses
SelectPolicyByClusterTypeAndProvideragainst newapiserver_managed.jsonandapiserver_managed_ocp.jsonfixtures.The inert local-Linseed rule is left in place. It selects no pods on a managed cluster, so it
is harmless, and removing it would churn the base fixtures across every backport branch.
release-v1.41(CE v3.23.0-1.0) carries neither the egress rule norLINSEED_URL, so theaffected range starts here.
Addresses CI-2048.
Testing
Verified on a live managed cluster on the master change (#5240): with the customer's
default-deny in a tier after
calico-system, the original operator returned the reported 500on
GET /policiesafter a 19.5s guardian timeout, and the fixed operator returned 200 in0.58s with the
calico-systemtier present. The deny stayed applied across both runs and onlythe operator image changed.
On this branch: full
pkg/rendersuite green,make static-checksreports 0 issues, and newspecs cover the rule being rendered ahead of the trailing
Passon a managed cluster andabsent otherwise.
Release Note
For PR author
make gen-filesmake gen-versionsFor PR reviewers
A note for code reviewers - all pull requests must have the following:
kind/bugif this is a bugfix.kind/enhancementif this is a a new feature.enterpriseif this PR applies to Calico Enterprise only.🤖 Generated with Claude Code