Skip to content

fix(task): prevent disabled feature pipelines from leaking into the active graph - #1014

Merged
kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-prmmxknorvxt
Sep 16, 2026
Merged

kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-prmmxknorvxt

Conversation

@kyasbal

@kyasbal kyasbal commented Sep 16, 2026

Copy link
Copy Markdown
Member

Summary

ResolveGraph pulled query pipelines of disabled features into the active graph, so KHI ran Cloud Logging queries for features the user had unchecked.

Fixes #1013

Root cause

disabledTasks only contains the feature flag tasks themselves. Those are sinks at the downstream end of the DAG, while tryResolveActiveFeatureSubgraph walks upstream from a candidate. The marker and the traversal point in opposite directions, so the resolver never learns that an upstream producer belongs to a disabled feature.

Concretely, when Kubernetes container logs are unchecked, k8scontainer/query is still reached through the autocomplete/form chain that fans in via ScopeActiveFeatures, because every branch of that chain merges into AutocompleteMetricsK8sContainerTask, which is already in the graph through AutocompleteClusterIdentityTask.

Fix

Add a new Phase 2 to ResolveGraph, expandDisabledClosure, that runs right after the mandatory closure. It walks upstream from the disabled sinks over mandatory point-to-point dependencies and adds every task it reaches to disabledRefIDSet.

The safety argument is that once resolveMandatoryClosure returns, graphTaskMap holds the complete mandatory closure of every enabled feature plus every system required task. Therefore a task reachable from a disabled sink and absent from graphTaskMap serves disabled features only. Traversal stops as soon as it reaches a task inside graphTaskMap, so shared upstreams and required tasks are never disabled.

The real blast radius is wider than the issue describes

A regression test over the real registered DAG, run against the pre-fix code, showed the leak was not limited to container logs:

Enabled feature Leaked exclusive tasks of disabled features
serialport compute-api, gke-api, k8s-container, k8s-node, autoscaler queries
network-api autoscaler, csm-trafficlog, gke-api, k8s-container, k8s-event queries
k8s-auditlog (gcp) autoscaler, gke-api, k8s-container queries
k8s-node k8s-container, k8s-event queries

Notably k8s-node/query leaked when serialport was enabled, contradicting the issue's claim that the k8snode branch is safely rejected by the !hasMandatoryDeps guard. Whether that guard rejected a branch depended on candidate evaluation order, so the protection was accidental.

Tests

  • TestResolveGraph_DisabledFeatureClosure in graphresolver_test.go: four table-driven cases covering the multi-hop leak, no over-disabling of shared upstreams, protection of required tasks, and an upstream shared by two disabled features.
  • DisabledFeatureIsolation in the task graph conformance harness: enables exactly one feature at a time over the real DAG and asserts that no other feature's exclusive tasks appear in the resolved graph.

The conformance check derives "feature-exclusive" purely from declared dependencies:

exclusive(G) = mandatoryClosure({G}) \ mandatoryClosure(requiredTasks ∪ {every feature except G})

Defining it by differencing ResolveGraph outputs does not work, because the bug contaminates every baseline the resolver produces and the leak cancels out in the subtraction.

Behavior changes to be aware of

  • DryRun shares ResolveTaskGraph, so form metadata follows the resolved graph. Form fields belonging to a disabled feature, such as Namespaces(Container logs) and Pod names(Container logs), now correctly disappear when the feature is unchecked. This is a visible UI change.
  • The semantics become slightly stronger: a task that lives exclusively upstream of a disabled feature can no longer be pulled in through ScopeActiveFeatures either. This is intended, since running it means running work the user turned off. No production code currently uses point-to-point ScopeActiveFeatures, only the tag fan-in in NewInventoryTask.
…ctive graph

ResolveGraph only marks downstream feature sink tasks as disabled, but
tryResolveActiveFeatureSubgraph walks upstream, so it never encounters the
disabled marker. Propagate disabled reference IDs upstream through mandatory
point-to-point dependencies right after the mandatory closure phase, and add
a task graph conformance check asserting that enabling one feature never pulls
in tasks exclusively owned by a disabled feature.
@kyasbal kyasbal added type:bug Something isn't working as expected area:backend-core Core backend frameworks, DAG task runner, and server API labels Sep 16, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new phase to the task graph resolution algorithm, 'Disabled Feature Closure Expansion', which identifies and disables upstream tasks that exclusively serve disabled features. It includes corresponding unit tests in graphresolver_test.go and conformance tests in task_graph_conformance.go to verify disabled feature isolation. There are no review comments, so I have no feedback to provide.

@kyasbal
kyasbal added this pull request to the merge queue Sep 16, 2026
Merged via the queue into GoogleCloudPlatform:main with commit bd83494 Sep 16, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-prmmxknorvxt branch September 16, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-core Core backend frameworks, DAG task runner, and server API type:bug Something isn't working as expected

1 participant