Skip to content

refactor(task): separate feature activation gate from data dependencies via WithFeatureGate - #1051

Merged
kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-vmtmvyskmonq
Sep 28, 2026
Merged

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

Conversation

@kyasbal

@kyasbal kyasbal commented Sep 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Separate Feature Activation Gate from Data Dependencies: Introduce LabelKeyFeatureGateTaskRef and WithFeatureGate(featureTaskRef) so tasks resolved via ScopeActiveFeatures declare their feature activation gate independently of their execution data dependencies (Dependencies()).
  • Fix Unconditional Pulling of Ungated Tasks: Tasks without WithFeatureGate now default to ungated when referenced via ScopeActiveFeatures, and SerializeTask explicitly uses FromActiveGraph for TagLogIngester and TagTimelineMapper, preventing unselected feature pipelines (e.g., CAI or CSM tasks) from being pulled into the execution graph.
  • Migrate Discovery Tasks & Clean Up Legacy Edges: Configure WithFeatureGate on all 10 concrete Discovery tasks, remove legacy reverse F1 -> D1 dependencies from the 4 TailTasks, and remove the unused LabelKeySubsequentTaskRefs label and helpers.
  • Task Graph Debug UI & DAG Viewer: Display FeatureGate metadata across the Task Graph Debug Registry Table, Task Neighborhood Panel, DAG Node cards, and DAG Node Detail Panel.

Test Plan

  • make test-go
  • USE_CONTAINER=1 make test-web
  • make pre-commit
…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
@kyasbal
kyasbal requested a review from RyuSA as a code owner September 28, 2026 05:54
@kyasbal kyasbal added the area:backend-core Core backend frameworks, DAG task runner, and server API label Sep 28, 2026
@kyasbal
kyasbal requested a review from jyane as a code owner September 28, 2026 05:54
@kyasbal kyasbal added area:backend-parser Log parsers and log timeline mapper tasks area:frontend Web frontend application and UI components labels Sep 28, 2026
@kyasbal
kyasbal requested a review from kkuchima as a code owner September 28, 2026 05:54
@kyasbal kyasbal added the type:refactor Code refactoring without behavioral change label Sep 28, 2026
@kyasbal
kyasbal requested review from K53 and renamoo as code owners September 28, 2026 05:54

@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 "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.

Comment on lines 30 to 32
"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"

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.

high

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.

Suggested change
"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"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Kept intentionally as csmcp.LogToTimelineMapperTaskID.Ref() is required in k8scontainer.TailTask (see reply below).

Comment on lines 361 to 365
[]coretask.Dependency{
k8scontainer.LogToTimelineMapperTaskID.Ref(),
k8scontainer.PodPhaseTimelineMapperTaskID.Ref(),
k8scontainer.NodeNameDiscoveryTaskID.Ref(),
csmcp.LogToTimelineMapperTaskID.Ref(),
},

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.

high

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(),
	},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@kyasbal
kyasbal added this pull request to the merge queue Sep 28, 2026
Merged via the queue into GoogleCloudPlatform:main with commit 5322f71 Sep 28, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-vmtmvyskmonq branch September 28, 2026 06:32
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 area:backend-parser Log parsers and log timeline mapper tasks area:frontend Web frontend application and UI components type:refactor Code refactoring without behavioral change

1 participant