Repository navigation
fix(tenant): ship sub-tenant logs and metrics to the ancestor monitoring - #5257
IvanHunters wants to merge 3 commits into
Conversation
A sub-tenant that resolves its monitoring to an ancestor (the usual case when the sub-tenant runs no monitoring of its own) runs monitoring agents that write to the ancestor's vlinsert and vminsert. Two tenant-policy gaps dropped that traffic: the sub-tenant egress allowed vminsert but not vlinsert, and the ancestor had no ingress accepting descendants on the ingest endpoints. Logs and metrics never arrived, while the agents' HelmRelease still reported Ready, which hid the failure. Add vlinsert to the ancestor egress, and add <tenant>-ingress-monitoring, which accepts the descendants that point their namespace.cozystack.io/monitoring label at this tenant on vlinsert and vminsert. Assisted-by: LLM Signed-off-by: IvanHunters <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
myasnikovdaniil
left a comment
There was a problem hiding this comment.
Only half of root cause from #5256 is real, and the fix doesn't cover the most common layout.
-
Missing
vlinsertin sub-tenant egress is real, fluent-bit timeouts from the issue are explained by it alone. But same change already sits in your #3439, which is approved code-wise and waits only for description edits, so please keep only one of them. -
Ancestor ingress doesn't block descendants.
allow-external-communicationin the same template (networkpolicy.yaml:17-30) gives every pod of every tenantingress fromEntities: [world, cluster], andclusterentity in cilium matches all pods of the cluster, allow rules are additive. Metrics in #5256 were not arriving because of wrong remote write URL (#5258, fixed by #5024), and workaround in the issue was tested with both policies at once. So-ingress-monitoringchanges nothing and its comment ("Without it the egress allow has no counterpart and delivery is dropped") describes mechanism that doesn't exist. Please drop it, or if you have hubble output with ingress drop on ancestorvlinsertwhile only egress fix is applied, add it to PR. -
Prefix walk never reaches
tenant-rootbelow first level (#4726). Common setup is monitoring only intenant-root(tenant default ismonitoring: false) and others inherit it, and with this PR rendered egress is:tenant-a (ns tenant-root): vminsert, vlinsert @ tenant-root tenant-a-b (ns tenant-a): vminsert, vlinsert @ tenant-a tenant-a-b-c (ns tenant-a-b): vminsert, vlinsert @ tenant-a, tenant-a-bSo guest cluster in
tenant-a-bsending totenant-rootis still dropped on egress, while release note claims general fix. Walk also opensvlinsertof every ancestor instead of the one that owns monitoring for this tenant. Effective owner is already computed innamespace.yaml:64-67(_namespace.monitoring, or tenant itself withmonitoring: true), so egress can target it with one rule: owner namespace +app.kubernetes.io/nameinvlinsert,vminsert. It works for any depth.
If ingress policy stays for some reason, absence test doesn't catch anything: I replaced the guard with {{- if true }}, policy rendered with monitoring: false and all 3 tests still passed.
Sub-tenant monitoring agents that resolve to an ancestor shipped metrics and logs through a namespace-prefix walk that never reached tenant-root from below the first level. Target the inherited monitoring owner namespace directly with one egress rule covering vminsert and vlinsert, so delivery works at any depth. Drop the -ingress-monitoring policy: the ancestor already accepts the ingress through its allow-external-communication rule (fromEntities: cluster), so the separate policy added nothing. Assisted-by: LLM Signed-off-by: IvanHunters <[email protected]>
myasnikovdaniil
left a comment
There was a problem hiding this comment.
Previous points are fixed, depth case renders right now. Only tests are left.
-
"renders no monitoring egress rule when the tenant owns its monitoring" doesn't set
_namespace.monitoring, but in real cluster it is never empty (cozystack-basicsalways sets it fortenant-rootand every child inherits it). So removing theif .Values.monitoringoverride keeps all 82 tests green, while this override is the only thing that makes self-owned tenant differ from inheriting one. Please add_namespace.monitoring: tenant-rootto itsset, with it test fails on removed override. -
"does not render the removed ingress-monitoring policy" can't fail: I put old policy back on its place, it renders with
monitoring: trueand test still passes. Main never had this policy, so just drop the test.
Set _namespace.monitoring on the self-owned case so the monitoring: true override is what the assertion depends on; without it the owner is empty either way and the test passes even if the override is removed. Drop the ingress-monitoring absence test: that policy never existed on main, so there is nothing to guard against. Assisted-by: LLM Signed-off-by: IvanHunters <[email protected]>
|
Both addressed in
|
myasnikovdaniil
left a comment
There was a problem hiding this comment.
Both points fixed, tests now fail on removal of any part of owner rule (vlinsert, owner namespace, self guard, monitoring: true override).
PR description still says unittests cover absence of separate ingress policy, please drop that part before merge. Also release note says egress dropped all ingest below first level, but it was only when owner is tenant-root, with intermediate owner metrics passed before too.
What this PR does
A tenant (and the guest clusters inside it) whose monitoring resolves to an ancestor runs monitoring agents (Fluent Bit + VMAgent) that write to the owner tenant's
vlinsert(logs) andvminsert(metrics). The generated tenant Cilium egress dropped part of this traffic:vminsertbut nevervlinsert, so log shipping was dropped at the source (fluent-bitno upstream connections available to vlinsert-generic.<owner>.svc:9481).tenant-rootfrom below the first level. In the common layout where onlytenant-roothas monitoring and descendants inherit it, a guest two levels deep had its ingest traffic dropped on egress.This change replaces the prefix walk with a single egress rule that targets the monitoring owner namespace directly. The owner is the value already computed in
namespace.yamland inherited through_namespace.monitoring, so it resolves to the real owner at any depth and covers bothvminsertandvlinsertin one rule. The rule is skipped when the tenant owns its monitoring (writes stay in-namespace) or when no ancestor owns it.No ingress policy is added on the owner side: the owner tenant already accepts the traffic through its
allow-external-communicationrule (fromEntities: [world, cluster]), which matches every pod in the cluster.Helm unittests cover the owner-targeted egress one level down, the deep case targeting
tenant-root, the self-owned case (no rule rendered), and the absence of a separate ingress policy.Fixes #5256
Downstream repositories
Release note
Summary by CodeRabbit
vminsertandvlinsert, including when that owner is not the tenant’s parent.