Skip to content

Commit a55e983

Browse files
Merge main into epic/file-schema-v6 (#666)
* Removing unused CORS code (#619) * Removing unused CORS code * Update pkg/core/init/default/defaultextension.go Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: kyasbal <kyasbal1994@gmail.com> --------- Signed-off-by: kyasbal <kyasbal1994@gmail.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Replaced unsafe innerHTML with textContent (#620) * feat(startup): implement smart component and integrate data loading (#599) * feat(startup): add inspection list components * feat(startup): implement smart component and integrate data loading #558 * Fix name of the function pointed out by the review * chore: fix make setup error in jj and update dev guide (#629) * chore: fix make setup error in jj and update dev guide * fix commented issues on review * fixed minor issues on Makefile (#644) * Merge epic/csm-parser into main (#645) * Add Inventory/Discovery tasks for parsing the map from NEG name to BS name (#635) * Add fleet PJ form task and query task to gather CSM TD audit logs (#636) * Add Inventory/Discovery tasks for parsing the map from NEG name to BS name * Adding form task to receive the fleet project and query task to gather logs from Cloud Logging * Add timeline mapper for TD resource logs (#637) * Add Inventory/Discovery tasks for parsing the map from NEG name to BS name * Adding form task to receive the fleet project and query task to gather logs from Cloud Logging * Add timeline mapper for traffic director resource logs * 🐛 fix set-input suggestion being wrapped for every lines (#638) * fix set-input suggestion being wrapped for every lines * Update web/src/app/timeline-toolbar/components/set-input-popup.component.scss Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: kyasbal <kyasbal1994@gmail.com> --------- Signed-off-by: kyasbal <kyasbal1994@gmail.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Fix bugs to register the CSM TD parser tasks (#647) * Fix the same issue of #638 (#659) * Adding make clean command (#651) * Addming make clean command * fixed commented points * Removing unused old headers on frontend (#660) * removed prefix 'v2' in shader files (#661) * rename commonlogk8sauditv2 to commonlogk8saudit (#662) --------- Signed-off-by: kyasbal <kyasbal1994@gmail.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 73f6816 commit a55e983

122 files changed

Lines changed: 680 additions & 1791 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ include scripts/make/*.mk
2727
# Development commands
2828
# ====================================================================================
2929

30+
## Clean
31+
.PHONY: clean
32+
clean: ## Clean build artifacts and generated files
33+
@echo "Cleaning Go binaries..."
34+
rm -rf ./bin ./khi ./khi-debug
35+
@echo "Cleaning frontend artifacts..."
36+
rm -rf ./pkg/server/dist web/.angular web/coverage
37+
@echo "Cleaning test and coverage reports..."
38+
rm -rf go-cover.html go-cover.output result.json
39+
@echo "Cleaning intermediate generated files..."
40+
find . -path "./web" -prune -o -path "./.git" -prune -o -type f -name "zzz_*.go" -exec rm -f {} + -o -type f -name "zzz_*.json" -exec rm -f {} +
41+
rm -rf pkg/generated
42+
rm -rf web/src/app/zzz-generated.scss web/src/app/zzz-generated.ts web/angular.json web/src/environments/version.*.ts
43+
@echo "Cleaning make dummy files..."
44+
rm -rf scripts/make/*.done
45+
3046
## Test
3147
.PHONY: test
3248
test: test-web test-go ## Run all tests
File renamed without changes.

pkg/task/inspection/commonlogk8sauditv2/contract/fieldset.go renamed to pkg/task/inspection/commonlogk8saudit/contract/fieldset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commonlogk8sauditv2_contract
15+
package commonlogk8saudit_contract
1616

1717
import (
1818
"github.com/GoogleCloudPlatform/khi/pkg/common/structured"

pkg/task/inspection/commonlogk8sauditv2/contract/inventory.go renamed to pkg/task/inspection/commonlogk8saudit/contract/inventory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commonlogk8sauditv2_contract
15+
package commonlogk8saudit_contract
1616

1717
import (
1818
inspectiontaskbase "github.com/GoogleCloudPlatform/khi/pkg/core/inspection/taskbase"

pkg/task/inspection/commonlogk8sauditv2/contract/manifestmapper.go renamed to pkg/task/inspection/commonlogk8saudit/contract/manifestmapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commonlogk8sauditv2_contract
15+
package commonlogk8saudit_contract
1616

1717
import (
1818
"context"

pkg/task/inspection/commonlogk8sauditv2/contract/taskid.go renamed to pkg/task/inspection/commonlogk8saudit/contract/taskid.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commonlogk8sauditv2_contract
15+
package commonlogk8saudit_contract
1616

1717
import (
1818
"github.com/GoogleCloudPlatform/khi/pkg/common/patternfinder"
@@ -23,7 +23,7 @@ import (
2323
)
2424

2525
// TaskIDPrefix is the prefix for all task IDs in this package.
26-
var TaskIDPrefix = "khi.google.com/k8s-common-auditlog-v2/"
26+
var TaskIDPrefix = "khi.google.com/k8s-common-auditlog/"
2727

2828
// K8sAuditLogProviderRef is the task reference for the task to fetch k8s audit log.
2929
// The actual implementation for this reference must provide log array with the K8sAuditLogFieldSet.

pkg/task/inspection/commonlogk8sauditv2/contract/type.go renamed to pkg/task/inspection/commonlogk8saudit/contract/type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commonlogk8sauditv2_contract
15+
package commonlogk8saudit_contract
1616

1717
import (
1818
"fmt"

pkg/task/inspection/commonlogk8sauditv2/impl/common_task.go renamed to pkg/task/inspection/commonlogk8saudit/impl/common_task.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commonlogk8sauditv2_impl
15+
package commonlogk8saudit_impl
1616

1717
import (
1818
inspectiontaskbase "github.com/GoogleCloudPlatform/khi/pkg/core/inspection/taskbase"
19-
commonlogk8sauditv2_contract "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/commonlogk8sauditv2/contract"
19+
commonlogk8saudit_contract "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/commonlogk8saudit/contract"
2020
)
2121

2222
// LogSorterTask is the task to sort logs by time.
2323
var LogSorterTask = inspectiontaskbase.NewLogSorterByTimeTask(
24-
commonlogk8sauditv2_contract.LogSorterTaskID,
25-
commonlogk8sauditv2_contract.SuccessLogFilterTaskID.Ref(),
24+
commonlogk8saudit_contract.LogSorterTaskID,
25+
commonlogk8saudit_contract.SuccessLogFilterTaskID.Ref(),
2626
)

pkg/task/inspection/commonlogk8sauditv2/impl/conditionmapper_task.go renamed to pkg/task/inspection/commonlogk8saudit/impl/conditionmapper_task.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commonlogk8sauditv2_impl
15+
package commonlogk8saudit_impl
1616

1717
import (
1818
"context"
@@ -27,12 +27,12 @@ import (
2727
"github.com/GoogleCloudPlatform/khi/pkg/model/history"
2828
"github.com/GoogleCloudPlatform/khi/pkg/model/history/resourcepath"
2929
"github.com/GoogleCloudPlatform/khi/pkg/model/log"
30-
commonlogk8sauditv2_contract "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/commonlogk8sauditv2/contract"
30+
commonlogk8saudit_contract "github.com/GoogleCloudPlatform/khi/pkg/task/inspection/commonlogk8saudit/contract"
3131
)
3232

3333
// ConditionLogToTimelineMapperTask is a ManifestLogToTimelineMapper task that tracks and records the history of Kubernetes resource conditions.
3434
// It analyzes status.conditions fields in audit logs to generate revisions for each condition type (e.g., Ready, Scheduled).
35-
var ConditionLogToTimelineMapperTask = commonlogk8sauditv2_contract.NewManifestLogToTimelineMapper[*conditionLogToTimelineMapperTaskState](&conditionLogToTimelineMapperTaskSetting{
35+
var ConditionLogToTimelineMapperTask = commonlogk8saudit_contract.NewManifestLogToTimelineMapper[*conditionLogToTimelineMapperTaskState](&conditionLogToTimelineMapperTaskSetting{
3636
minimumDeltaTimeToCreateInferredCreationRevision: 10 * time.Second,
3737
})
3838

@@ -48,8 +48,8 @@ type conditionLogToTimelineMapperTaskSetting struct {
4848
minimumDeltaTimeToCreateInferredCreationRevision time.Duration
4949
}
5050

51-
// Process implements commonlogk8sauditv2_contract.ManifestLogToTimelineMapperTaskSetting.
52-
func (c *conditionLogToTimelineMapperTaskSetting) Process(ctx context.Context, passIndex int, event commonlogk8sauditv2_contract.ResourceChangeEvent, cs *history.ChangeSet, builder *history.Builder, prevResource *conditionLogToTimelineMapperTaskState) (*conditionLogToTimelineMapperTaskState, error) {
51+
// Process implements commonlogk8saudit_contract.ManifestLogToTimelineMapperTaskSetting.
52+
func (c *conditionLogToTimelineMapperTaskSetting) Process(ctx context.Context, passIndex int, event commonlogk8saudit_contract.ResourceChangeEvent, cs *history.ChangeSet, builder *history.Builder, prevResource *conditionLogToTimelineMapperTaskState) (*conditionLogToTimelineMapperTaskState, error) {
5353
if event.EventTargetBodyReader == nil {
5454
return prevResource, nil
5555
}
@@ -63,17 +63,17 @@ func (c *conditionLogToTimelineMapperTaskSetting) Process(ctx context.Context, p
6363
}
6464
}
6565

66-
// TaskID implements commonlogk8sauditv2_contract.ManifestLogToTimelineMapperTaskSetting.
66+
// TaskID implements commonlogk8saudit_contract.ManifestLogToTimelineMapperTaskSetting.
6767
func (c *conditionLogToTimelineMapperTaskSetting) TaskID() taskid.TaskImplementationID[struct{}] {
68-
return commonlogk8sauditv2_contract.ConditionLogToTimelineMapperTaskID
68+
return commonlogk8saudit_contract.ConditionLogToTimelineMapperTaskID
6969
}
7070

71-
// ResourcePairs implements commonlogk8sauditv2_contract.ManifestLogToTimelineMapperTaskSetting.
72-
func (c *conditionLogToTimelineMapperTaskSetting) ResourcePairs(ctx context.Context, groupedLogs commonlogk8sauditv2_contract.ResourceManifestLogGroupMap) ([]commonlogk8sauditv2_contract.ResourcePair, error) {
73-
result := []commonlogk8sauditv2_contract.ResourcePair{}
71+
// ResourcePairs implements commonlogk8saudit_contract.ManifestLogToTimelineMapperTaskSetting.
72+
func (c *conditionLogToTimelineMapperTaskSetting) ResourcePairs(ctx context.Context, groupedLogs commonlogk8saudit_contract.ResourceManifestLogGroupMap) ([]commonlogk8saudit_contract.ResourcePair, error) {
73+
result := []commonlogk8saudit_contract.ResourcePair{}
7474
for _, group := range groupedLogs {
75-
if group.Resource.Type() == commonlogk8sauditv2_contract.Resource {
76-
result = append(result, commonlogk8sauditv2_contract.ResourcePair{
75+
if group.Resource.Type() == commonlogk8saudit_contract.Resource {
76+
result = append(result, commonlogk8saudit_contract.ResourcePair{
7777
TargetGroup: group.Resource,
7878
})
7979
}
@@ -83,15 +83,15 @@ func (c *conditionLogToTimelineMapperTaskSetting) ResourcePairs(ctx context.Cont
8383

8484
// processFirstPass collects all available condition types from the log.
8585
// This is necessary because some conditions might appear later in the history, and we need to know about them upfront to track their state correctly.
86-
func (c *conditionLogToTimelineMapperTaskSetting) processFirstPass(ctx context.Context, event commonlogk8sauditv2_contract.ResourceChangeEvent, cs *history.ChangeSet, builder *history.Builder, state *conditionLogToTimelineMapperTaskState) (*conditionLogToTimelineMapperTaskState, error) {
86+
func (c *conditionLogToTimelineMapperTaskSetting) processFirstPass(ctx context.Context, event commonlogk8saudit_contract.ResourceChangeEvent, cs *history.ChangeSet, builder *history.Builder, state *conditionLogToTimelineMapperTaskState) (*conditionLogToTimelineMapperTaskState, error) {
8787
if state == nil {
8888
state = &conditionLogToTimelineMapperTaskState{
8989
AvailableTypes: map[string]struct{}{},
9090
ConditionWalkers: map[string]*conditionWalker{},
9191
}
9292
}
9393
commonFieldSet := log.MustGetFieldSet(event.Log, &log.CommonFieldSet{})
94-
k8sFieldSet := log.MustGetFieldSet(event.Log, &commonlogk8sauditv2_contract.K8sAuditLogFieldSet{})
94+
k8sFieldSet := log.MustGetFieldSet(event.Log, &commonlogk8saudit_contract.K8sAuditLogFieldSet{})
9595
ownerPath := resourcepath.ResourcePath{
9696
Path: event.EventTargetResource.ResourcePathString(),
9797
ParentRelationship: enum.RelationshipChild,
@@ -123,9 +123,9 @@ func (c *conditionLogToTimelineMapperTaskSetting) processFirstPass(ctx context.C
123123

124124
// processSecondPass generates revisions for each condition type based on the collected available types.
125125
// It handles standard updates, inferred creations (when creation time is missing from the log), and deletions.
126-
func (c *conditionLogToTimelineMapperTaskSetting) processSecondPass(ctx context.Context, event commonlogk8sauditv2_contract.ResourceChangeEvent, cs *history.ChangeSet, builder *history.Builder, state *conditionLogToTimelineMapperTaskState) (*conditionLogToTimelineMapperTaskState, error) {
126+
func (c *conditionLogToTimelineMapperTaskSetting) processSecondPass(ctx context.Context, event commonlogk8saudit_contract.ResourceChangeEvent, cs *history.ChangeSet, builder *history.Builder, state *conditionLogToTimelineMapperTaskState) (*conditionLogToTimelineMapperTaskState, error) {
127127
commonFieldSet := log.MustGetFieldSet(event.Log, &log.CommonFieldSet{})
128-
k8sFieldSet := log.MustGetFieldSet(event.Log, &commonlogk8sauditv2_contract.K8sAuditLogFieldSet{})
128+
k8sFieldSet := log.MustGetFieldSet(event.Log, &commonlogk8saudit_contract.K8sAuditLogFieldSet{})
129129
ownerPath := resourcepath.ResourcePath{
130130
Path: event.EventTargetResource.ResourcePathString(),
131131
ParentRelationship: enum.RelationshipChild,
@@ -147,7 +147,7 @@ func (c *conditionLogToTimelineMapperTaskSetting) processSecondPass(ctx context.
147147
}
148148
slices.Sort(sortedKeys)
149149

150-
if event.EventType == commonlogk8sauditv2_contract.ChangeEventTypeTargetCreation {
150+
if event.EventType == commonlogk8saudit_contract.ChangeEventTypeTargetCreation {
151151
creationTime, found := GetCreationTimestamp(event.EventTargetBodyReader)
152152
if found {
153153
if commonFieldSet.Timestamp.Sub(creationTime) > c.minimumDeltaTimeToCreateInferredCreationRevision {
@@ -175,7 +175,7 @@ func (c *conditionLogToTimelineMapperTaskSetting) processSecondPass(ctx context.
175175
walker.CheckAndRecord(commonFieldSet, k8sFieldSet, currentConditions[key], cs)
176176
}
177177

178-
if event.EventType == commonlogk8sauditv2_contract.ChangeEventTypeTargetDeletion {
178+
if event.EventType == commonlogk8saudit_contract.ChangeEventTypeTargetDeletion {
179179
for _, key := range sortedKeys {
180180
walker := state.ConditionWalkers[key]
181181
if walker == nil {
@@ -198,27 +198,27 @@ func (c *conditionLogToTimelineMapperTaskSetting) processSecondPass(ctx context.
198198
return state, nil
199199
}
200200

201-
// Dependencies implements commonlogk8sauditv2_contract.ManifestLogToTimelineMapperTaskSetting.
201+
// Dependencies implements commonlogk8saudit_contract.ManifestLogToTimelineMapperTaskSetting.
202202
func (c *conditionLogToTimelineMapperTaskSetting) Dependencies() []taskid.UntypedTaskReference {
203203
return []taskid.UntypedTaskReference{}
204204
}
205205

206-
// PassCount implements commonlogk8sauditv2_contract.ManifestLogToTimelineMapperTaskSetting.
206+
// PassCount implements commonlogk8saudit_contract.ManifestLogToTimelineMapperTaskSetting.
207207
func (c *conditionLogToTimelineMapperTaskSetting) PassCount() int {
208208
return 2
209209
}
210210

211-
// GroupedLogTask implements commonlogk8sauditv2_contract.ManifestLogToTimelineMapperTaskSetting.
212-
func (c *conditionLogToTimelineMapperTaskSetting) GroupedLogTask() taskid.TaskReference[commonlogk8sauditv2_contract.ResourceManifestLogGroupMap] {
213-
return commonlogk8sauditv2_contract.ResourceLifetimeTrackerTaskID.Ref()
211+
// GroupedLogTask implements commonlogk8saudit_contract.ManifestLogToTimelineMapperTaskSetting.
212+
func (c *conditionLogToTimelineMapperTaskSetting) GroupedLogTask() taskid.TaskReference[commonlogk8saudit_contract.ResourceManifestLogGroupMap] {
213+
return commonlogk8saudit_contract.ResourceLifetimeTrackerTaskID.Ref()
214214
}
215215

216-
// LogIngesterTask implements commonlogk8sauditv2_contract.ManifestLogToTimelineMapperTaskSetting.
216+
// LogIngesterTask implements commonlogk8saudit_contract.ManifestLogToTimelineMapperTaskSetting.
217217
func (c *conditionLogToTimelineMapperTaskSetting) LogIngesterTask() taskid.TaskReference[[]*log.Log] {
218-
return commonlogk8sauditv2_contract.K8sAuditLogIngesterTaskID.Ref()
218+
return commonlogk8saudit_contract.K8sAuditLogIngesterTaskID.Ref()
219219
}
220220

221-
var _ commonlogk8sauditv2_contract.ManifestLogToTimelineMapperTaskSetting[*conditionLogToTimelineMapperTaskState] = (*conditionLogToTimelineMapperTaskSetting)(nil)
221+
var _ commonlogk8saudit_contract.ManifestLogToTimelineMapperTaskSetting[*conditionLogToTimelineMapperTaskState] = (*conditionLogToTimelineMapperTaskSetting)(nil)
222222

223223
// conditionStateToRevisionState converts a Kubernetes condition status string ("True", "False", etc.) to a KHI RevisionState enum.
224224
func conditionStateToRevisionState(conditionState string) enum.RevisionState {
@@ -268,15 +268,15 @@ func newConditionWalker(parentResource resourcepath.ResourcePath, stateType stri
268268
}
269269

270270
// checkLastTransitionTimes memorizes the last transition time of the condition. This value is used for complementing values for logs without the full status information.
271-
func (c *conditionWalker) checkLastTransitionTimes(commonLog *log.CommonFieldSet, k8sAuditLog *commonlogk8sauditv2_contract.K8sAuditLogFieldSet, condition *model.K8sResourceStatusCondition) {
271+
func (c *conditionWalker) checkLastTransitionTimes(commonLog *log.CommonFieldSet, k8sAuditLog *commonlogk8saudit_contract.K8sAuditLogFieldSet, condition *model.K8sResourceStatusCondition) {
272272
if condition != nil && condition.Status != "" && condition.LastTransitionTime != "" {
273273
c.lastTransitionStates[condition.LastTransitionTime] = condition
274274
}
275275
}
276276

277277
// CheckAndRecord compares the current condition with the previous state and records a revision if there is a significant change.
278278
// It tracks changes in Status, LastTransitionTime, and LastHeartbeatTime (ProbeLikeTime).
279-
func (c *conditionWalker) CheckAndRecord(commonLog *log.CommonFieldSet, k8sAuditLog *commonlogk8sauditv2_contract.K8sAuditLogFieldSet, condition *model.K8sResourceStatusCondition, cs *history.ChangeSet) {
279+
func (c *conditionWalker) CheckAndRecord(commonLog *log.CommonFieldSet, k8sAuditLog *commonlogk8saudit_contract.K8sAuditLogFieldSet, condition *model.K8sResourceStatusCondition, cs *history.ChangeSet) {
280280
if condition == nil {
281281
if c.lastStatus != "n/a" {
282282
cs.AddRevision(c.conditionPath(), &history.StagingResourceRevision{

0 commit comments

Comments
 (0)