Repository navigation
feat(googlecloudcaik8s): implement GKE existing resource inspection via Cloud Asset Inventory - #991
Conversation
… and integrate with audit log pipeline Define the InitialResourceStateProvider interface to allow the audit log pipeline to receive pre-inspection resource states from inventory providers. - Define InitialResourceStateProvider contract and ClusterScopeNamespace constant. - Add EmptyInitialResourceStateProviderTask as the default fallback for environments without an inventory provider. - Suppress synthetic LogNotFound revisions in resourcemapper when an initial resource state exists. - Seed prevRevisionReader in manifest_generator_task with initial resource state so the first patch log merges onto the pre-existing state. - Unify cluster-scoped namespace string literals to the ClusterScopeNamespace constant.
There was a problem hiding this comment.
Code Review
This pull request introduces a new Google Cloud Asset Inventory (CAI) integration for GKE cluster inspection. It fetches cluster resource snapshots to reconstruct the initial state of Kubernetes resources before the audit log window opens, merging these snapshots with subsequent audit log patches. Key changes include adding the CAI client to the client factory, exporting OrderedMapNode, and implementing the InitialResourceStateProvider contract. Feedback on the changes suggests avoiding hex color conversion helpers in favor of raw style.Color values, chaining protobuf getters to eliminate redundant nil checks, and retrieving the call options injector optionally to support lightweight unit test fixtures.
…sourceStateProvider
…ia Cloud Asset Inventory Implement Cloud Asset Inventory (CAI) resource fetching and timeline mapping for GKE inspection. Populate pre-existing resource state into audit log timelines and provide full manifest restoration including TypeMeta and metadata fields. - Add cloud.google.com/go/asset dependency and integrate AssetClient into ClientFactory. - Export OrderedMapNode in structured package for manifest key ordering. - Define CAI contracts, generic CAIFetcher interface, log types, task IDs, and revision state types. - Implement caiFetcher supporting 100-asset chunking, quota project resolution, and progress callbacks. - Implement CAIClusterResourceFetcherTask with exact parent resource scoping, namespace query pushdown, chunking, and progress reporting. - Implement mapping logic to restore manifest TypeMeta (kind, apiVersion), decode base64 fieldsV1, and strip proto3 empty default metadata strings. - Implement CAIClusterResourceLogIngesterTask and CAIClusterResourceTimelineMapperTask to render unknown period and observed snapshot revisions on timelines. - Implement CAIInitialResourceStateProviderTask satisfying the InitialResourceStateProvider contract for the audit log pipeline. - Register all googlecloudcaik8s inspection tasks for Google Cloud GKE clusters.
…tor, protobuf getters, and log type color
eeab20e to
d7375c2
Compare
99a2c09
* chore(github): reorganize issue and PR label taxonomy (#971) * chore(github): reorganize issue and PR label taxonomy Reorganize GitHub issue and PR label system to improve discoverability, triage ergonomics, and release automation alignment: - Update .github/release.yml changelog categories to use new label names (type:feature, type:bug, type:perf, type:refactor, area:cicd, area:devenv, type:docs, type:chore). - Configure .github/ISSUE_TEMPLATE/bug-report.md with default labels "type:bug, status:needs-triage". - Configure .github/ISSUE_TEMPLATE/feature-request.md with default labels "type:feature, status:needs-triage". * fix(github): separate maintenance and dependencies categories in release notes * feat(k8sevent): replace resource UIDs with readable names in event summaries (#973) * feat(k8sevent): replace resource UIDs with readable names in event summaries - Add ResourceIdentity.SummaryTag() method to format resources as readable tags - Replace matched resource UIDs in Kubernetes event messages with readable tags in both GKE and OSS log ingesters - Map matched resource UIDs to corresponding resource timelines in ProcessLogByGroup - Add HasEventCount assertion helper to TimelineChangeSetAsserter * fix(review): address review comments on deduplicating formatEventSummary and HasEventCount * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule (#974) * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule * fix(agent): address review comments on collections comparison in go-coding-rule * feat(googlecloudk8scommon): default kind filter to all kinds except leases (#975) * feat(timeline): allow inline editing of search filter chips on click (#977) * feat(timeline): allow inline editing of search filter chips on click Enable in-place editing of search filter chips in ChipSearchBarComponent when clicked. Clicking a chip renders an inline text input with text pre-selected and auto-focused. Changes can be committed with Enter or blur, or cancelled with Escape. Delimiter splitting and whitespace removal are supported. * fix(review): address review comments on blur race condition and focus preservation * fix(inspection): resolve timezone offset fallback to UTC by unifying to timezoneShiftHours (#978) Following the Connect-RPC migration (#908), the timezone shift parameter was updated in Protobuf and backend RPC handlers to timezoneShiftHours (float64). However, TimeZoneShiftInputTask and the frontend InspectionClient retained references to the legacy timezoneShift key, causing inspections to always fall back to UTC time. This change: - Unifies the context key to TaskInputKeyTimezoneShiftHours in inspectioncore - Updates TimeZoneShiftInputTask to read TaskInputKeyTimezoneShiftHours - Updates backend-api.service.ts and its test to use timezoneShiftHours - Updates parser_test.go to float64(9) - Adds unit tests for TimeZoneShiftInputTask * fix(k8saudit): preserve immutable identity metadata after truncated logs (#979) * fix(k8saudit): preserve immutable identity metadata after truncated logs When Kubernetes audit logs contain truncated responses (audit.k8s.io/truncated: "true"), groupManifestGenerator reset prevRevisionReader to nil. Subsequent patch requests merged into an empty map reader, causing metadata.uid to be lost. Later tasks interpreted the missing UID as a new resource creation, incorrectly emitting a ChangeEventTypeCreation event and overwriting the initial revision at creationTimestamp. This commit updates manifest_generator_task to preserve immutable identity metadata (apiVersion, kind, metadata.name, metadata.namespace, metadata.uid, metadata.creationTimestamp) upon encountering truncated logs so that subsequent patches retain the resource identity. * fix(k8saudit): return preserved immutable identity reader for truncated log body When a log is truncated, groupManifestGenerator now returns the preserved immutable identity reader as ResourceBodyReader rather than nil. This allows the truncated log itself to retain its immutable identity metadata in the generated timeline revision, preventing the resource body from appearing completely empty in the UI and downstream tasks. * feat(cicd): support manual tag and release draft generation via workflow_dispatch (#980) * feat(cicd): support manual tag creation and release draft generation via workflow_dispatch Add a workflow_dispatch trigger to .github/workflows/release.yaml, allowing maintainers to initiate tag creation and release draft generation directly from the GitHub Actions Web UI without local terminal operations. - Accept a required tag_name input parameter (e.g., v1.2.3 or v1.2.3-beta-1) - Validate tag format and verify uniqueness via git ls-remote before starting builds - Create and push the Git tag after successful binary compilation - Automatically generate release notes from categorised commit history * fix(cicd): pass step outputs via env to prevent template injection * refactor(inspection): remove legacy LabelKeyInspectionTypes and InspectionTypeLabel (#981) Remove deprecated LabelKeyInspectionTypes, InspectionTypeLabel, and legacy fallback logic from inspection runner. Update tests and documentation to use InspectionTypeLabelSelector. * feat(inspection): set default environment name in composer form (#982) Add WithDefaultValueFunc to InputComposerEnvironmentNameTask so that when Composer environments are fetched via autocomplete, the first environment is automatically selected as the default value if no previous selection was made. * feat(dev): support configurable ports and hosts for multi-workspace and cloudtop (#983) * feat(dev): support configurable ports and hosts for multi-workspace and cloudtop Support configuring ports and hosts via environment variables for KHI development servers and test runners. - Makefile: allow overriding WEB_HOST, WEB_PORT, BACKEND_HOST, BACKEND_PORT, STORYBOOK_HOST, STORYBOOK_PORT, and KARMA_PORT. Add --allowed-hosts flag automatically when WEB_HOST is 0.0.0.0. - Angular proxy: forward to BACKEND_HOST and BACKEND_PORT, normalizing 0.0.0.0 to 127.0.0.1 for HTTP proxy target. - Karma: configure port from KARMA_PORT, bind to 127.0.0.1, and set --remote-debugging-port=0 to avoid debugging port collisions in headless Chrome. * fix(dev): update karma beginsPattern regex to match 127.0.0.1 in tasks.json * feat(task): add task description label and WithTaskDescription option (#985) * feat(task): add task description label and WithTaskDescription option * chore: add license header to label_test.go * refactor(task): simplify WithTaskDescription using WithLabelValue * test(task): replace TestWithTaskDescription with TestWithLabelValue * feat(inspection): add checkbox form field type (#986) * feat(inspection): add checkbox form field type Add a checkbox form field type so inspection tasks can take boolean input in the New Inspection dialog. - proto: add CheckboxFormField with readonly and default_value, FormField.kind checkbox, and ParameterValue.checkbox_value. - metadata: add CheckboxParameterFormField and its serialization. - formtask: add CheckboxFormTaskBuilder that builds a Task[bool] on top of FormTaskBuilderBase[bool]. It is not generic because a checkbox only ever represents a boolean state. - server: convert CheckboxParameterFormField to and from the proto messages. - web: add CheckboxParameterComponent, register it in GroupParameterComponent, and convert the checkbox field and value in the inspection converter. The checkbox reuses the common label instead of holding its own text. * fix(inspection): address review comments on validator, test mock, and add license headers * refactor(inspection): remove redundant LogSorterTask and NewLogSorterByTimeTask (#988) Remove NewLogSorterByTimeTask and its usages in commonlogk8saudit and googlecloudclustercomposer. In KHI, all upstream log providers already provide logs in chronological order, and filter/grouper tasks preserve log order. The intermediate LogSorter performed redundant slice cloning and sorting without functional necessity. - Deleted NewLogSorterByTimeTask from pkg/core/inspection/taskbase - Removed LogSorterTask and its registration from commonlogk8saudit - Removed AirflowDagProcessorManagerLogSorterTask from googlecloudclustercomposer - Rewired downstream grouper/ingester tasks directly to upstream filter tasks - Updated pipeline documentation and Mermaid diagrams * feat(commonlogk8saudit): add initial resource state provider contract and integrate with audit log pipeline (#990) * feat(commonlogk8saudit): add initial resource state provider contract and integrate with audit log pipeline Define the InitialResourceStateProvider interface to allow the audit log pipeline to receive pre-inspection resource states from inventory providers. - Define InitialResourceStateProvider contract and ClusterScopeNamespace constant. - Add EmptyInitialResourceStateProviderTask as the default fallback for environments without an inventory provider. - Suppress synthetic LogNotFound revisions in resourcemapper when an initial resource state exists. - Seed prevRevisionReader in manifest_generator_task with initial resource state so the first patch log merges onto the pre-existing state. - Unify cluster-scoped namespace string literals to the ClusterScopeNamespace constant. * docs(commonlogk8saudit): document thread-safety contract on InitialResourceStateProvider * feat(googlecloudcaik8s): implement GKE existing resource inspection via Cloud Asset Inventory (#991) * feat(commonlogk8saudit): add initial resource state provider contract and integrate with audit log pipeline Define the InitialResourceStateProvider interface to allow the audit log pipeline to receive pre-inspection resource states from inventory providers. - Define InitialResourceStateProvider contract and ClusterScopeNamespace constant. - Add EmptyInitialResourceStateProviderTask as the default fallback for environments without an inventory provider. - Suppress synthetic LogNotFound revisions in resourcemapper when an initial resource state exists. - Seed prevRevisionReader in manifest_generator_task with initial resource state so the first patch log merges onto the pre-existing state. - Unify cluster-scoped namespace string literals to the ClusterScopeNamespace constant. * docs(commonlogk8saudit): document thread-safety contract on InitialResourceStateProvider * feat(googlecloudcaik8s): implement GKE existing resource inspection via Cloud Asset Inventory Implement Cloud Asset Inventory (CAI) resource fetching and timeline mapping for GKE inspection. Populate pre-existing resource state into audit log timelines and provide full manifest restoration including TypeMeta and metadata fields. - Add cloud.google.com/go/asset dependency and integrate AssetClient into ClientFactory. - Export OrderedMapNode in structured package for manifest key ordering. - Define CAI contracts, generic CAIFetcher interface, log types, task IDs, and revision state types. - Implement caiFetcher supporting 100-asset chunking, quota project resolution, and progress callbacks. - Implement CAIClusterResourceFetcherTask with exact parent resource scoping, namespace query pushdown, chunking, and progress reporting. - Implement mapping logic to restore manifest TypeMeta (kind, apiVersion), decode base64 fieldsV1, and strip proto3 empty default metadata strings. - Implement CAIClusterResourceLogIngesterTask and CAIClusterResourceTimelineMapperTask to render unknown period and observed snapshot revisions on timelines. - Implement CAIInitialResourceStateProviderTask satisfying the InitialResourceStateProvider contract for the audit log pipeline. - Register all googlecloudcaik8s inspection tasks for Google Cloud GKE clusters. * fix(googlecloudcaik8s): address review comments on call options injector, protobuf getters, and log type color * fix(googlecloudcaik8s): set VerbUpdate on CAI snapshot revision when creation timestamp is present (#994) When a Kubernetes resource snapshot in Cloud Asset Inventory (CAI) contains metadata.creationTimestamp preceding observedTime by at least the skew tolerance, an initial body-less creation revision (state ExistingLogNotFound, VerbType VerbCreate) is prepended to represent the resource creation before the inspection window. In this case, the snapshot revision at observedTime represents an observed state of an already-existing resource, rather than an additional creation event. Setting VerbType to VerbUpdate avoids rendering two consecutive "Create" events for the same resource timeline. If no creation revision is prepended (e.g. creationTimestamp is missing or within skew tolerance), the snapshot revision retains VerbCreate as the initial anchor for the resource timeline. * test(web): support containerized frontend testing and harden karma configuration (#995) * feat(inspection): include job command in metadata and allow starting inspection from job command (#993) * feat(inspection): include job command in metadata and allow starting inspection from job command fix(merge): resolve generated proto conflicts on plpwpmxw * fix(new-inspection): flatten RxJS initialization stream and enhance test coverage for job command startup * style(startup): replace job command button with a text link and refine link styling * fix(web): address review feedback and fix GroupParameterFormField typing in test * fix(web): restore protected visibility and strengthen dialog open assertions * refactor(web): refactor inspection metadata dialog into smart-dumb components with accordion layout (#996) * refactor(web): refactor inspection metadata dialog into smart-dumb components with accordion layout * fix(web): prevent timer leak, remove dead output and fix grid area alignment in metadata code viewer * fix(web): cleanup unused chips module, unused model fields, align grid areas, and remove redundant panel descriptions * fix(web): remove unused CommonModule, fix error tracking key, and rename layout viewModel input * refactor(web): extract formatBytes into shared utility and unexport internal metadata formatters * fix(web): remove defensive checks on guaranteed metadata properties * refactor(web): remove inner code viewer badges across metadata accordion items * feat(web): format inspection metadata start and end times with timezoneShift in ISO 8601 * fix(web): address PR review comments on byte/time formatters, test querying, and job command integration --------- Co-authored-by: kept1994 <keigof@google.com>
* feat(task): redefine Task interface, dependencies, and builder primitives in coretask (GoogleCloudPlatform#972) * chore(github): reorganize issue and PR label taxonomy (GoogleCloudPlatform#971) * chore(github): reorganize issue and PR label taxonomy Reorganize GitHub issue and PR label system to improve discoverability, triage ergonomics, and release automation alignment: - Update .github/release.yml changelog categories to use new label names (type:feature, type:bug, type:perf, type:refactor, area:cicd, area:devenv, type:docs, type:chore). - Configure .github/ISSUE_TEMPLATE/bug-report.md with default labels "type:bug, status:needs-triage". - Configure .github/ISSUE_TEMPLATE/feature-request.md with default labels "type:feature, status:needs-triage". * fix(github): separate maintenance and dependencies categories in release notes * feat(k8sevent): replace resource UIDs with readable names in event summaries (GoogleCloudPlatform#973) * feat(k8sevent): replace resource UIDs with readable names in event summaries - Add ResourceIdentity.SummaryTag() method to format resources as readable tags - Replace matched resource UIDs in Kubernetes event messages with readable tags in both GKE and OSS log ingesters - Map matched resource UIDs to corresponding resource timelines in ProcessLogByGroup - Add HasEventCount assertion helper to TimelineChangeSetAsserter * fix(review): address review comments on deduplicating formatEventSummary and HasEventCount * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule (GoogleCloudPlatform#974) * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule * fix(agent): address review comments on collections comparison in go-coding-rule * feat(task): add edge attributes and dependency descriptors to taskid * feat(task): redefine Task interface, dependencies, and builder primitives in coretask * fix(task): address PR review comments on PR GoogleCloudPlatform#972 * feat(task): add priority options and multi-stage execution labels for FanIn dependencies * feat(task): implement GraphResolver with fan-in cycle pruning and migrate monorepo to Task System v3 (GoogleCloudPlatform#976) * feat(task): implement 4-phase GraphResolver, concrete edge tracking, and memory lifecycle in LocalRunner * refactor(inspection): modernize inspection taskbase and runner for edge attributes * refactor(task): migrate inspection tasks across monorepo to new task system * feat(task): implement priority-based fan-in pruning and cycle detection in GraphResolver * fix(review): address review comments on formtask aliases, inventory task multi-stage, and cycle tests * feat(task): support stage-aware fan-in binding in TaskGraphMetadata and TaskSet * feat(task): split cyclic multi-stage consumer tasks into DAG stages in GraphResolver * test(inspection): verify end-to-end multi-stage inventory aggregation with cyclic producer * fix(task): resolve LocalRunner stage tracking data race and improve naming * refactor(task): eliminate dead BoundReferenceIDsWithTag and normalize task-scoped tag metadata * refactor(task): decompose cycle resolution helpers and add edge routing tests * refactor(task): clean up taskset doc comment, runner identifiers, and taskid parameter naming * refactor(task): decompose cycle resolution helpers and extract graph utilities into graphresolver_graphutil.go * test(task): add upstream PtP edge routing test for split multi-stage consumer * refactor(task): eliminate obsolete refToTask and refToImplID maps in cycle resolution * refactor(task): decompose cycle resolution and stage expansion functions * refactor(task): standardize PointToPoint identifiers and fix inverted test description * refactor(task): rename TaskEdge endpoints to SourceImplID and TargetImplID * refactor(task): extract stage expansion and rerouting into graphresolver_stage.go * fix(task): reroute fan-in edges from split producer and ensure deterministic stage edges * refactor(task): align stage identifier names and test mock field naming * refactor(task): extract stage tests into graphresolver_stage_test.go and co-locate stageTask * fix(task): prevent premature deletion of self-loop stage results and add runner test * refactor(task): decompose rerouteFanInEdges in graphresolver_stage.go * refactor(task): standardize remainingStagesByRefID and boundFanInRefIDsByTaskImpl identifiers * test(task): add unit tests for graphresolver_graphutil.go * fix(task): replace scalar cmp.Diff with direct equality in runner_test.go and add stage assertions * refactor(task): eliminate abbreviations and align identifiers in stage resolution and tests * refactor(task): rename rem and remDep to remainingDependents in LocalRunner * refactor(task): align stage edge identifiers and non-split naming in stage resolution * refactor(task): flatten control flow nesting in LocalRunner cleanup * refactor(task): fix point-to-point doc comment and disambiguate split consumer IDs * refactor(task): rename BoundReferenceIDsForTaskWithTag to BoundReferenceIDsForTaskImplWithTag * refactor(task): align stageTaskPairs, producer identifiers, and table-driven graphutil tests * refactor(task): prune cyclic fan-in candidate edges into single-stage DAG and unify dependency scopes * chore: merge main into epic/task-system-v3 (GoogleCloudPlatform#984) * chore(github): reorganize issue and PR label taxonomy (GoogleCloudPlatform#971) * chore(github): reorganize issue and PR label taxonomy Reorganize GitHub issue and PR label system to improve discoverability, triage ergonomics, and release automation alignment: - Update .github/release.yml changelog categories to use new label names (type:feature, type:bug, type:perf, type:refactor, area:cicd, area:devenv, type:docs, type:chore). - Configure .github/ISSUE_TEMPLATE/bug-report.md with default labels "type:bug, status:needs-triage". - Configure .github/ISSUE_TEMPLATE/feature-request.md with default labels "type:feature, status:needs-triage". * fix(github): separate maintenance and dependencies categories in release notes * feat(k8sevent): replace resource UIDs with readable names in event summaries (GoogleCloudPlatform#973) * feat(k8sevent): replace resource UIDs with readable names in event summaries - Add ResourceIdentity.SummaryTag() method to format resources as readable tags - Replace matched resource UIDs in Kubernetes event messages with readable tags in both GKE and OSS log ingesters - Map matched resource UIDs to corresponding resource timelines in ProcessLogByGroup - Add HasEventCount assertion helper to TimelineChangeSetAsserter * fix(review): address review comments on deduplicating formatEventSummary and HasEventCount * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule (GoogleCloudPlatform#974) * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule * fix(agent): address review comments on collections comparison in go-coding-rule * feat(googlecloudk8scommon): default kind filter to all kinds except leases (GoogleCloudPlatform#975) * feat(timeline): allow inline editing of search filter chips on click (GoogleCloudPlatform#977) * feat(timeline): allow inline editing of search filter chips on click Enable in-place editing of search filter chips in ChipSearchBarComponent when clicked. Clicking a chip renders an inline text input with text pre-selected and auto-focused. Changes can be committed with Enter or blur, or cancelled with Escape. Delimiter splitting and whitespace removal are supported. * fix(review): address review comments on blur race condition and focus preservation * fix(inspection): resolve timezone offset fallback to UTC by unifying to timezoneShiftHours (GoogleCloudPlatform#978) Following the Connect-RPC migration (GoogleCloudPlatform#908), the timezone shift parameter was updated in Protobuf and backend RPC handlers to timezoneShiftHours (float64). However, TimeZoneShiftInputTask and the frontend InspectionClient retained references to the legacy timezoneShift key, causing inspections to always fall back to UTC time. This change: - Unifies the context key to TaskInputKeyTimezoneShiftHours in inspectioncore - Updates TimeZoneShiftInputTask to read TaskInputKeyTimezoneShiftHours - Updates backend-api.service.ts and its test to use timezoneShiftHours - Updates parser_test.go to float64(9) - Adds unit tests for TimeZoneShiftInputTask * fix(k8saudit): preserve immutable identity metadata after truncated logs (GoogleCloudPlatform#979) * fix(k8saudit): preserve immutable identity metadata after truncated logs When Kubernetes audit logs contain truncated responses (audit.k8s.io/truncated: "true"), groupManifestGenerator reset prevRevisionReader to nil. Subsequent patch requests merged into an empty map reader, causing metadata.uid to be lost. Later tasks interpreted the missing UID as a new resource creation, incorrectly emitting a ChangeEventTypeCreation event and overwriting the initial revision at creationTimestamp. This commit updates manifest_generator_task to preserve immutable identity metadata (apiVersion, kind, metadata.name, metadata.namespace, metadata.uid, metadata.creationTimestamp) upon encountering truncated logs so that subsequent patches retain the resource identity. * fix(k8saudit): return preserved immutable identity reader for truncated log body When a log is truncated, groupManifestGenerator now returns the preserved immutable identity reader as ResourceBodyReader rather than nil. This allows the truncated log itself to retain its immutable identity metadata in the generated timeline revision, preventing the resource body from appearing completely empty in the UI and downstream tasks. * feat(cicd): support manual tag and release draft generation via workflow_dispatch (GoogleCloudPlatform#980) * feat(cicd): support manual tag creation and release draft generation via workflow_dispatch Add a workflow_dispatch trigger to .github/workflows/release.yaml, allowing maintainers to initiate tag creation and release draft generation directly from the GitHub Actions Web UI without local terminal operations. - Accept a required tag_name input parameter (e.g., v1.2.3 or v1.2.3-beta-1) - Validate tag format and verify uniqueness via git ls-remote before starting builds - Create and push the Git tag after successful binary compilation - Automatically generate release notes from categorised commit history * fix(cicd): pass step outputs via env to prevent template injection * refactor(inspection): remove legacy LabelKeyInspectionTypes and InspectionTypeLabel (GoogleCloudPlatform#981) Remove deprecated LabelKeyInspectionTypes, InspectionTypeLabel, and legacy fallback logic from inspection runner. Update tests and documentation to use InspectionTypeLabelSelector. * feat(inspection): set default environment name in composer form (GoogleCloudPlatform#982) Add WithDefaultValueFunc to InputComposerEnvironmentNameTask so that when Composer environments are fetched via autocomplete, the first environment is automatically selected as the default value if no previous selection was made. --------- Co-authored-by: kept1994 <keigof@google.com> * chore: merge main into epic/task-system-v3 (GoogleCloudPlatform#987) * chore(github): reorganize issue and PR label taxonomy (GoogleCloudPlatform#971) * chore(github): reorganize issue and PR label taxonomy Reorganize GitHub issue and PR label system to improve discoverability, triage ergonomics, and release automation alignment: - Update .github/release.yml changelog categories to use new label names (type:feature, type:bug, type:perf, type:refactor, area:cicd, area:devenv, type:docs, type:chore). - Configure .github/ISSUE_TEMPLATE/bug-report.md with default labels "type:bug, status:needs-triage". - Configure .github/ISSUE_TEMPLATE/feature-request.md with default labels "type:feature, status:needs-triage". * fix(github): separate maintenance and dependencies categories in release notes * feat(k8sevent): replace resource UIDs with readable names in event summaries (GoogleCloudPlatform#973) * feat(k8sevent): replace resource UIDs with readable names in event summaries - Add ResourceIdentity.SummaryTag() method to format resources as readable tags - Replace matched resource UIDs in Kubernetes event messages with readable tags in both GKE and OSS log ingesters - Map matched resource UIDs to corresponding resource timelines in ProcessLogByGroup - Add HasEventCount assertion helper to TimelineChangeSetAsserter * fix(review): address review comments on deduplicating formatEventSummary and HasEventCount * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule (GoogleCloudPlatform#974) * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule * fix(agent): address review comments on collections comparison in go-coding-rule * feat(googlecloudk8scommon): default kind filter to all kinds except leases (GoogleCloudPlatform#975) * feat(timeline): allow inline editing of search filter chips on click (GoogleCloudPlatform#977) * feat(timeline): allow inline editing of search filter chips on click Enable in-place editing of search filter chips in ChipSearchBarComponent when clicked. Clicking a chip renders an inline text input with text pre-selected and auto-focused. Changes can be committed with Enter or blur, or cancelled with Escape. Delimiter splitting and whitespace removal are supported. * fix(review): address review comments on blur race condition and focus preservation * fix(inspection): resolve timezone offset fallback to UTC by unifying to timezoneShiftHours (GoogleCloudPlatform#978) Following the Connect-RPC migration (GoogleCloudPlatform#908), the timezone shift parameter was updated in Protobuf and backend RPC handlers to timezoneShiftHours (float64). However, TimeZoneShiftInputTask and the frontend InspectionClient retained references to the legacy timezoneShift key, causing inspections to always fall back to UTC time. This change: - Unifies the context key to TaskInputKeyTimezoneShiftHours in inspectioncore - Updates TimeZoneShiftInputTask to read TaskInputKeyTimezoneShiftHours - Updates backend-api.service.ts and its test to use timezoneShiftHours - Updates parser_test.go to float64(9) - Adds unit tests for TimeZoneShiftInputTask * fix(k8saudit): preserve immutable identity metadata after truncated logs (GoogleCloudPlatform#979) * fix(k8saudit): preserve immutable identity metadata after truncated logs When Kubernetes audit logs contain truncated responses (audit.k8s.io/truncated: "true"), groupManifestGenerator reset prevRevisionReader to nil. Subsequent patch requests merged into an empty map reader, causing metadata.uid to be lost. Later tasks interpreted the missing UID as a new resource creation, incorrectly emitting a ChangeEventTypeCreation event and overwriting the initial revision at creationTimestamp. This commit updates manifest_generator_task to preserve immutable identity metadata (apiVersion, kind, metadata.name, metadata.namespace, metadata.uid, metadata.creationTimestamp) upon encountering truncated logs so that subsequent patches retain the resource identity. * fix(k8saudit): return preserved immutable identity reader for truncated log body When a log is truncated, groupManifestGenerator now returns the preserved immutable identity reader as ResourceBodyReader rather than nil. This allows the truncated log itself to retain its immutable identity metadata in the generated timeline revision, preventing the resource body from appearing completely empty in the UI and downstream tasks. * feat(cicd): support manual tag and release draft generation via workflow_dispatch (GoogleCloudPlatform#980) * feat(cicd): support manual tag creation and release draft generation via workflow_dispatch Add a workflow_dispatch trigger to .github/workflows/release.yaml, allowing maintainers to initiate tag creation and release draft generation directly from the GitHub Actions Web UI without local terminal operations. - Accept a required tag_name input parameter (e.g., v1.2.3 or v1.2.3-beta-1) - Validate tag format and verify uniqueness via git ls-remote before starting builds - Create and push the Git tag after successful binary compilation - Automatically generate release notes from categorised commit history * fix(cicd): pass step outputs via env to prevent template injection * refactor(inspection): remove legacy LabelKeyInspectionTypes and InspectionTypeLabel (GoogleCloudPlatform#981) Remove deprecated LabelKeyInspectionTypes, InspectionTypeLabel, and legacy fallback logic from inspection runner. Update tests and documentation to use InspectionTypeLabelSelector. * feat(inspection): set default environment name in composer form (GoogleCloudPlatform#982) Add WithDefaultValueFunc to InputComposerEnvironmentNameTask so that when Composer environments are fetched via autocomplete, the first environment is automatically selected as the default value if no previous selection was made. * feat(dev): support configurable ports and hosts for multi-workspace and cloudtop (GoogleCloudPlatform#983) * feat(dev): support configurable ports and hosts for multi-workspace and cloudtop Support configuring ports and hosts via environment variables for KHI development servers and test runners. - Makefile: allow overriding WEB_HOST, WEB_PORT, BACKEND_HOST, BACKEND_PORT, STORYBOOK_HOST, STORYBOOK_PORT, and KARMA_PORT. Add --allowed-hosts flag automatically when WEB_HOST is 0.0.0.0. - Angular proxy: forward to BACKEND_HOST and BACKEND_PORT, normalizing 0.0.0.0 to 127.0.0.1 for HTTP proxy target. - Karma: configure port from KARMA_PORT, bind to 127.0.0.1, and set --remote-debugging-port=0 to avoid debugging port collisions in headless Chrome. * fix(dev): update karma beginsPattern regex to match 127.0.0.1 in tasks.json * feat(task): add task description label and WithTaskDescription option (GoogleCloudPlatform#985) * feat(task): add task description label and WithTaskDescription option * chore: add license header to label_test.go * refactor(task): simplify WithTaskDescription using WithLabelValue * test(task): replace TestWithTaskDescription with TestWithLabelValue --------- Co-authored-by: kept1994 <keigof@google.com> * feat(inspection,web): implement Task Graph Diagnostics debug page and DAG viewer (GoogleCloudPlatform#989) * docs(task): remove obsolete OrderOnly and explain dependency scopes * feat(api,inspection): implement InspectionTaskGraphService and task output type metadata * feat(web): implement Task Graph Diagnostics debug page and DAG viewer * test(web): fix mock task fixtures and truncation expectation in dag viewer specs * fix(inspection): skip monitoring metric client creation when cluster identity is incomplete in autocomplete tasks * feat(inspection,web): add live inspection run task graph dialog and streaming watch RPC (GoogleCloudPlatform#992) * test(web): support containerized frontend testing and harden karma configuration (GoogleCloudPlatform#995) * feat(api,inspection): add task graph run snapshot and streaming watch RPC * refactor(web): move dag viewer components to the shared component area * feat(web): add inspection run task graph dialog and visual enhancements to dag viewer * fix(web): reset consecutiveErrors on snapshot and expand stream observation unit tests * chore: merge main into epic/task-system-v3 (GoogleCloudPlatform#997) * chore(github): reorganize issue and PR label taxonomy (GoogleCloudPlatform#971) * chore(github): reorganize issue and PR label taxonomy Reorganize GitHub issue and PR label system to improve discoverability, triage ergonomics, and release automation alignment: - Update .github/release.yml changelog categories to use new label names (type:feature, type:bug, type:perf, type:refactor, area:cicd, area:devenv, type:docs, type:chore). - Configure .github/ISSUE_TEMPLATE/bug-report.md with default labels "type:bug, status:needs-triage". - Configure .github/ISSUE_TEMPLATE/feature-request.md with default labels "type:feature, status:needs-triage". * fix(github): separate maintenance and dependencies categories in release notes * feat(k8sevent): replace resource UIDs with readable names in event summaries (GoogleCloudPlatform#973) * feat(k8sevent): replace resource UIDs with readable names in event summaries - Add ResourceIdentity.SummaryTag() method to format resources as readable tags - Replace matched resource UIDs in Kubernetes event messages with readable tags in both GKE and OSS log ingesters - Map matched resource UIDs to corresponding resource timelines in ProcessLogByGroup - Add HasEventCount assertion helper to TimelineChangeSetAsserter * fix(review): address review comments on deduplicating formatEventSummary and HasEventCount * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule (GoogleCloudPlatform#974) * docs(agent): clarify cmp.Diff usage and test assertion examples in go-coding-rule * fix(agent): address review comments on collections comparison in go-coding-rule * feat(googlecloudk8scommon): default kind filter to all kinds except leases (GoogleCloudPlatform#975) * feat(timeline): allow inline editing of search filter chips on click (GoogleCloudPlatform#977) * feat(timeline): allow inline editing of search filter chips on click Enable in-place editing of search filter chips in ChipSearchBarComponent when clicked. Clicking a chip renders an inline text input with text pre-selected and auto-focused. Changes can be committed with Enter or blur, or cancelled with Escape. Delimiter splitting and whitespace removal are supported. * fix(review): address review comments on blur race condition and focus preservation * fix(inspection): resolve timezone offset fallback to UTC by unifying to timezoneShiftHours (GoogleCloudPlatform#978) Following the Connect-RPC migration (GoogleCloudPlatform#908), the timezone shift parameter was updated in Protobuf and backend RPC handlers to timezoneShiftHours (float64). However, TimeZoneShiftInputTask and the frontend InspectionClient retained references to the legacy timezoneShift key, causing inspections to always fall back to UTC time. This change: - Unifies the context key to TaskInputKeyTimezoneShiftHours in inspectioncore - Updates TimeZoneShiftInputTask to read TaskInputKeyTimezoneShiftHours - Updates backend-api.service.ts and its test to use timezoneShiftHours - Updates parser_test.go to float64(9) - Adds unit tests for TimeZoneShiftInputTask * fix(k8saudit): preserve immutable identity metadata after truncated logs (GoogleCloudPlatform#979) * fix(k8saudit): preserve immutable identity metadata after truncated logs When Kubernetes audit logs contain truncated responses (audit.k8s.io/truncated: "true"), groupManifestGenerator reset prevRevisionReader to nil. Subsequent patch requests merged into an empty map reader, causing metadata.uid to be lost. Later tasks interpreted the missing UID as a new resource creation, incorrectly emitting a ChangeEventTypeCreation event and overwriting the initial revision at creationTimestamp. This commit updates manifest_generator_task to preserve immutable identity metadata (apiVersion, kind, metadata.name, metadata.namespace, metadata.uid, metadata.creationTimestamp) upon encountering truncated logs so that subsequent patches retain the resource identity. * fix(k8saudit): return preserved immutable identity reader for truncated log body When a log is truncated, groupManifestGenerator now returns the preserved immutable identity reader as ResourceBodyReader rather than nil. This allows the truncated log itself to retain its immutable identity metadata in the generated timeline revision, preventing the resource body from appearing completely empty in the UI and downstream tasks. * feat(cicd): support manual tag and release draft generation via workflow_dispatch (GoogleCloudPlatform#980) * feat(cicd): support manual tag creation and release draft generation via workflow_dispatch Add a workflow_dispatch trigger to .github/workflows/release.yaml, allowing maintainers to initiate tag creation and release draft generation directly from the GitHub Actions Web UI without local terminal operations. - Accept a required tag_name input parameter (e.g., v1.2.3 or v1.2.3-beta-1) - Validate tag format and verify uniqueness via git ls-remote before starting builds - Create and push the Git tag after successful binary compilation - Automatically generate release notes from categorised commit history * fix(cicd): pass step outputs via env to prevent template injection * refactor(inspection): remove legacy LabelKeyInspectionTypes and InspectionTypeLabel (GoogleCloudPlatform#981) Remove deprecated LabelKeyInspectionTypes, InspectionTypeLabel, and legacy fallback logic from inspection runner. Update tests and documentation to use InspectionTypeLabelSelector. * feat(inspection): set default environment name in composer form (GoogleCloudPlatform#982) Add WithDefaultValueFunc to InputComposerEnvironmentNameTask so that when Composer environments are fetched via autocomplete, the first environment is automatically selected as the default value if no previous selection was made. * feat(dev): support configurable ports and hosts for multi-workspace and cloudtop (GoogleCloudPlatform#983) * feat(dev): support configurable ports and hosts for multi-workspace and cloudtop Support configuring ports and hosts via environment variables for KHI development servers and test runners. - Makefile: allow overriding WEB_HOST, WEB_PORT, BACKEND_HOST, BACKEND_PORT, STORYBOOK_HOST, STORYBOOK_PORT, and KARMA_PORT. Add --allowed-hosts flag automatically when WEB_HOST is 0.0.0.0. - Angular proxy: forward to BACKEND_HOST and BACKEND_PORT, normalizing 0.0.0.0 to 127.0.0.1 for HTTP proxy target. - Karma: configure port from KARMA_PORT, bind to 127.0.0.1, and set --remote-debugging-port=0 to avoid debugging port collisions in headless Chrome. * fix(dev): update karma beginsPattern regex to match 127.0.0.1 in tasks.json * feat(task): add task description label and WithTaskDescription option (GoogleCloudPlatform#985) * feat(task): add task description label and WithTaskDescription option * chore: add license header to label_test.go * refactor(task): simplify WithTaskDescription using WithLabelValue * test(task): replace TestWithTaskDescription with TestWithLabelValue * feat(inspection): add checkbox form field type (GoogleCloudPlatform#986) * feat(inspection): add checkbox form field type Add a checkbox form field type so inspection tasks can take boolean input in the New Inspection dialog. - proto: add CheckboxFormField with readonly and default_value, FormField.kind checkbox, and ParameterValue.checkbox_value. - metadata: add CheckboxParameterFormField and its serialization. - formtask: add CheckboxFormTaskBuilder that builds a Task[bool] on top of FormTaskBuilderBase[bool]. It is not generic because a checkbox only ever represents a boolean state. - server: convert CheckboxParameterFormField to and from the proto messages. - web: add CheckboxParameterComponent, register it in GroupParameterComponent, and convert the checkbox field and value in the inspection converter. The checkbox reuses the common label instead of holding its own text. * fix(inspection): address review comments on validator, test mock, and add license headers * refactor(inspection): remove redundant LogSorterTask and NewLogSorterByTimeTask (GoogleCloudPlatform#988) Remove NewLogSorterByTimeTask and its usages in commonlogk8saudit and googlecloudclustercomposer. In KHI, all upstream log providers already provide logs in chronological order, and filter/grouper tasks preserve log order. The intermediate LogSorter performed redundant slice cloning and sorting without functional necessity. - Deleted NewLogSorterByTimeTask from pkg/core/inspection/taskbase - Removed LogSorterTask and its registration from commonlogk8saudit - Removed AirflowDagProcessorManagerLogSorterTask from googlecloudclustercomposer - Rewired downstream grouper/ingester tasks directly to upstream filter tasks - Updated pipeline documentation and Mermaid diagrams * feat(commonlogk8saudit): add initial resource state provider contract and integrate with audit log pipeline (GoogleCloudPlatform#990) * feat(commonlogk8saudit): add initial resource state provider contract and integrate with audit log pipeline Define the InitialResourceStateProvider interface to allow the audit log pipeline to receive pre-inspection resource states from inventory providers. - Define InitialResourceStateProvider contract and ClusterScopeNamespace constant. - Add EmptyInitialResourceStateProviderTask as the default fallback for environments without an inventory provider. - Suppress synthetic LogNotFound revisions in resourcemapper when an initial resource state exists. - Seed prevRevisionReader in manifest_generator_task with initial resource state so the first patch log merges onto the pre-existing state. - Unify cluster-scoped namespace string literals to the ClusterScopeNamespace constant. * docs(commonlogk8saudit): document thread-safety contract on InitialResourceStateProvider * feat(googlecloudcaik8s): implement GKE existing resource inspection via Cloud Asset Inventory (GoogleCloudPlatform#991) * feat(commonlogk8saudit): add initial resource state provider contract and integrate with audit log pipeline Define the InitialResourceStateProvider interface to allow the audit log pipeline to receive pre-inspection resource states from inventory providers. - Define InitialResourceStateProvider contract and ClusterScopeNamespace constant. - Add EmptyInitialResourceStateProviderTask as the default fallback for environments without an inventory provider. - Suppress synthetic LogNotFound revisions in resourcemapper when an initial resource state exists. - Seed prevRevisionReader in manifest_generator_task with initial resource state so the first patch log merges onto the pre-existing state. - Unify cluster-scoped namespace string literals to the ClusterScopeNamespace constant. * docs(commonlogk8saudit): document thread-safety contract on InitialResourceStateProvider * feat(googlecloudcaik8s): implement GKE existing resource inspection via Cloud Asset Inventory Implement Cloud Asset Inventory (CAI) resource fetching and timeline mapping for GKE inspection. Populate pre-existing resource state into audit log timelines and provide full manifest restoration including TypeMeta and metadata fields. - Add cloud.google.com/go/asset dependency and integrate AssetClient into ClientFactory. - Export OrderedMapNode in structured package for manifest key ordering. - Define CAI contracts, generic CAIFetcher interface, log types, task IDs, and revision state types. - Implement caiFetcher supporting 100-asset chunking, quota project resolution, and progress callbacks. - Implement CAIClusterResourceFetcherTask with exact parent resource scoping, namespace query pushdown, chunking, and progress reporting. - Implement mapping logic to restore manifest TypeMeta (kind, apiVersion), decode base64 fieldsV1, and strip proto3 empty default metadata strings. - Implement CAIClusterResourceLogIngesterTask and CAIClusterResourceTimelineMapperTask to render unknown period and observed snapshot revisions on timelines. - Implement CAIInitialResourceStateProviderTask satisfying the InitialResourceStateProvider contract for the audit log pipeline. - Register all googlecloudcaik8s inspection tasks for Google Cloud GKE clusters. * fix(googlecloudcaik8s): address review comments on call options injector, protobuf getters, and log type color * fix(googlecloudcaik8s): set VerbUpdate on CAI snapshot revision when creation timestamp is present (GoogleCloudPlatform#994) When a Kubernetes resource snapshot in Cloud Asset Inventory (CAI) contains metadata.creationTimestamp preceding observedTime by at least the skew tolerance, an initial body-less creation revision (state ExistingLogNotFound, VerbType VerbCreate) is prepended to represent the resource creation before the inspection window. In this case, the snapshot revision at observedTime represents an observed state of an already-existing resource, rather than an additional creation event. Setting VerbType to VerbUpdate avoids rendering two consecutive "Create" events for the same resource timeline. If no creation revision is prepended (e.g. creationTimestamp is missing or within skew tolerance), the snapshot revision retains VerbCreate as the initial anchor for the resource timeline. * test(web): support containerized frontend testing and harden karma configuration (GoogleCloudPlatform#995) * feat(inspection): include job command in metadata and allow starting inspection from job command (GoogleCloudPlatform#993) * feat(inspection): include job command in metadata and allow starting inspection from job command fix(merge): resolve generated proto conflicts on plpwpmxw * fix(new-inspection): flatten RxJS initialization stream and enhance test coverage for job command startup * style(startup): replace job command button with a text link and refine link styling * fix(web): address review feedback and fix GroupParameterFormField typing in test * fix(web): restore protected visibility and strengthen dialog open assertions * refactor(web): refactor inspection metadata dialog into smart-dumb components with accordion layout (GoogleCloudPlatform#996) * refactor(web): refactor inspection metadata dialog into smart-dumb components with accordion layout * fix(web): prevent timer leak, remove dead output and fix grid area alignment in metadata code viewer * fix(web): cleanup unused chips module, unused model fields, align grid areas, and remove redundant panel descriptions * fix(web): remove unused CommonModule, fix error tracking key, and rename layout viewModel input * refactor(web): extract formatBytes into shared utility and unexport internal metadata formatters * fix(web): remove defensive checks on guaranteed metadata properties * refactor(web): remove inner code viewer badges across metadata accordion items * feat(web): format inspection metadata start and end times with timezoneShift in ISO 8601 * fix(web): address PR review comments on byte/time formatters, test querying, and job command integration --------- Co-authored-by: kept1994 <keigof@google.com> * test(task): add comprehensive task graph conformance tests for all registered tasks (GoogleCloudPlatform#998) * refactor(composer): remove unused ComposerEnvironmentListFetcher dead code * test(task): add comprehensive task graph conformance tests for all registered tasks * refactor(googlecloud): remove orphaned ComposerService and composer API client from ClientFactory * test(inspection): enforce non-empty form task labels and full inspection coverage in reachability test * fix(test): record inspection completion within Layer3 and guard reachability against partial subtest filters * docs(agent): update deprecated GetTaskResultOptional references to GetOptionalTaskResult in agent skills and rules (GoogleCloudPlatform#1000) * docs: remove non-existent Order-Only edge kind references from concept docs --------- Co-authored-by: kept1994 <keigof@google.com>
Summary
This PR implements Cloud Asset Inventory (CAI) resource snapshot extraction and timeline mapping for GKE cluster inspection. It enables KHI to inspect pre-existing cluster resources even before the first audit log appears in the inspection window, restoring complete resource manifests and supplying initial states to the audit log pipeline.
Key Changes
cloud.google.com/go/assetdependency.AssetClientinstantiation, caching, and lifecycle management inClientFactory.CAIFetcherinterface and implementcaiFetchersupporting 100-asset batching, quota project resolution, error handling, and chunk progress callbacks.OrderedMapNodeinpkg/common/structuredto support canonical manifest key ordering.kindandapiVersion) from CAI asset types and resource metadata.managedFields[].fieldsV1.Rawinto structured JSON objects.clusterName: "",selfLink: "",generateName: "",namespace: "",subresource: "") to match standard Kubernetes YAML serialization and prevent false diffs against audit logs.CAIClusterResourceFetcherTask: Fetches asset snapshots with parent resource scoping, namespace query pushdown, and progress reporting.CAIClusterResourceLogIngesterTask: Ingests snapshots into KHI raw log representations.CAIClusterResourceTimelineMapperTask: Maps snapshots to KHI timelines, rendering the unknown period prior to the snapshot and the observed snapshot revision.CAIInitialResourceStateProviderTask: ImplementsInitialResourceStateProviderfrom feat(commonlogk8saudit): add initial resource state provider contract and integrate with audit log pipeline #990, supplying pre-existing manifests to the audit log pipeline.registration.gofor Google Cloud GKE inspection.Testing
cai_fetcher_test.go(mock Asset gRPC server)mapping_test.go(TypeMeta resolution, Base64 decoding, empty metadata stripping)cai_cluster_resource_fetcher_task_test.gocai_cluster_resource_log_ingester_task_test.gocai_cluster_resource_timeline_mapper_task_test.gocai_initial_resource_state_provider_test.gomake build-go,make test-go, andmake lint-go.