Repository navigation
refactor(task): separate feature activation gate from data dependencies via WithFeatureGate - #1051
Conversation
…es via WithFeatureGate Separate the feature activation gate (LabelKeyFeatureGateTaskRef / WithFeatureGate) from data dependencies (Dependencies()) when resolving ScopeActiveFeatures task edges and tags, and remove the unused LabelKeySubsequentTaskRefs label. Also display Feature Gate metadata in the Task Graph Debug UI and DAG Viewer. TAG=agy
There was a problem hiding this comment.
Code Review
This pull request introduces a "Feature Gate" mechanism to the task graph resolution system, replacing the previous subsequent task reference and disabled closure expansion logic. Tasks can now declare a feature gate reference via WithFeatureGate, allowing them to be pulled into the graph under ScopeActiveFeatures only if their gating task is active. The changes span the backend resolver, various discovery tasks, and the frontend DAG viewer which now displays feature gate badges. The review feedback identifies a critical issue in pkg/task/inspection/googlecloud/k8scontainer/impl/mapper.go where an accidental dependency on csmcp.LogToTimelineMapperTaskID was introduced, causing tight coupling between the container logs feature and the CSM feature, as well as an unused import that would trigger Go compilation errors.
| "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/common/k8saudit" | ||
| "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/googlecloud/csmcp" | ||
| "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/googlecloud/gcpcommon" |
There was a problem hiding this comment.
This import of csmcp is unused once the accidental dependency on csmcp.LogToTimelineMapperTaskID is removed. Removing it prevents Go compilation errors due to unused imports.
| "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/common/k8saudit" | |
| "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/googlecloud/csmcp" | |
| "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/googlecloud/gcpcommon" | |
| "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/common/k8saudit" | |
| "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/googlecloud/gcpcommon" |
There was a problem hiding this comment.
Kept intentionally as csmcp.LogToTimelineMapperTaskID.Ref() is required in k8scontainer.TailTask (see reply below).
| []coretask.Dependency{ | ||
| k8scontainer.LogToTimelineMapperTaskID.Ref(), | ||
| k8scontainer.PodPhaseTimelineMapperTaskID.Ref(), | ||
| k8scontainer.NodeNameDiscoveryTaskID.Ref(), | ||
| csmcp.LogToTimelineMapperTaskID.Ref(), | ||
| }, |
There was a problem hiding this comment.
Adding csmcp.LogToTimelineMapperTaskID.Ref() as a dependency of k8scontainer.TailTask accidentally couples the common k8scontainer feature to the csmcp (Anthos Service Mesh Control Plane) feature. This causes CSM tasks to be unconditionally pulled into the execution graph whenever container logs are enabled, which contradicts the PR's goal of preventing unselected feature pipelines (like CSM) from being pulled in. Since the legacy discovery task dependency was removed, this line should simply be deleted without adding a CSM dependency.
[]coretask.Dependency{
k8scontainer.LogToTimelineMapperTaskID.Ref(),
k8scontainer.PodPhaseTimelineMapperTaskID.Ref(),
},There was a problem hiding this comment.
This dependency is intentional. csmcp (pkg/task/inspection/googlecloud/csmcp) does not have its own FeatureTaskLabel or log query task; it is a sub-mapper of Kubernetes Container Logs (k8scontainer) that filters k8scontainer.ListLogEntriesTaskID for in-cluster istiod discovery container logs and maps xDS connection events onto Pod timelines.
Previously, SerializeTask referenced TagTimelineMapper with FromActiveFeatures, which implicitly pulled in csmcp.LogToTimelineMapperTask whenever k8scontainer.TailTask was enabled (since its upstream dependencies k8scontainer.ListLogEntriesTask and k8scontainer.LogIngesterTask were active). Because SerializeTask now uses FromActiveGraph, k8scontainer.TailTask must explicitly depend on csmcp.LogToTimelineMapperTaskID.Ref() (matching the other container log mappers); otherwise csmcp tasks become completely unreachable across all inspection types and fail NoUnreachableTasks conformance tests.
5322f71
Summary
LabelKeyFeatureGateTaskRefandWithFeatureGate(featureTaskRef)so tasks resolved viaScopeActiveFeaturesdeclare their feature activation gate independently of their execution data dependencies (Dependencies()).WithFeatureGatenow default to ungated when referenced viaScopeActiveFeatures, andSerializeTaskexplicitly usesFromActiveGraphforTagLogIngesterandTagTimelineMapper, preventing unselected feature pipelines (e.g., CAI or CSM tasks) from being pulled into the execution graph.WithFeatureGateon all 10 concrete Discovery tasks, remove legacy reverseF1 -> D1dependencies from the 4TailTasks, and remove the unusedLabelKeySubsequentTaskRefslabel and helpers.FeatureGatemetadata across the Task Graph Debug Registry Table, Task Neighborhood Panel, DAG Node cards, and DAG Node Detail Panel.Test Plan
make test-goUSE_CONTAINER=1 make test-webmake pre-commit