Skip to content

chore: deprecate old profiletypes in favor of containerprofiles - #55

Open
entlein wants to merge 4 commits into
kubescape:mainfrom
k8sstormcenter:migrate/sbob
Open

chore: deprecate old profiletypes in favor of containerprofiles#55
entlein wants to merge 4 commits into
kubescape:mainfrom
k8sstormcenter:migrate/sbob

Conversation

@entlein

@entlein entlein commented Jul 30, 2026

Copy link
Copy Markdown

The ApplicationProfile/NetworkNeighborhood CRDs are removed upstream. Remove the
GetApplicationProfile/GetNetworkNeighborhood/ListApplicationProfiles/
ListNetworkNeighborhoods client wrappers (no callers) and the tests covering
them. The mock's AP/NN methods stay only to satisfy the still-generated proto
StorageServiceClient interface; dropping the AP/NN RPCs and adding a
ListContainerProfiles RPC is a storage-side proto follow-up.

Summary by CodeRabbit

  • Changes

    • Storage profile retrieval now focuses exclusively on container profiles.
    • Removed application profile and network neighborhood retrieval and listing APIs.
  • Improvements

    • Enhanced container profile upload and download reliability, including streaming and large payload handling.
    • Improved error reporting for connection, transfer, and server-side failures.
  • Chores

    • Updated the Go toolchain and supporting libraries.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ba258a8-2232-4342-abf8-e206a989776a

📥 Commits

Reviewing files that changed from the base of the PR and between aa1d0a6 and f418abc.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod

📝 Walkthrough

Walkthrough

The PR updates Go dependencies, removes application and network profile storage RPCs and client methods, narrows GetProfile to container profiles, and adds unary and streaming storage-client tests.

Changes

Dependency refresh

Layer / File(s) Summary
Go module and dependency upgrades
go.mod
Go 1.25.8 and updated direct and indirect dependency versions are recorded.

Container profile storage API

Layer / File(s) Summary
Storage protocol contract
pkg/client/v1/proto/storage_service.proto
Application and network profile RPCs and messages are removed. GetProfileResponse retains only container_profile and reserves fields 4 and 5.
Storage client API cleanup
pkg/client/v1/storageclient.go, pkg/client/v1/storageclient_test.go
Unary application and network profile retrieval and listing methods, mocks, and related test cases are removed.
Container profile client validation
pkg/client/v1/storageclient_coverage_test.go, pkg/client/v1/storageclient_test.go
Connection, unary, streaming error, server-abort, chunking, and round-trip behavior are tested.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • kubescape/backend#44: Shares storage protobuf and client code and includes gRPC dependency updates.
  • kubescape/backend#47: Introduced related GetProfile fields and GetContainerProfile functionality.
  • kubescape/backend#50: Modifies the same storage service and client APIs while retaining container-profile streaming.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: deprecating older profile types in favor of container profiles.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Entlein added 3 commits July 30, 2026 21:20
The ApplicationProfile/NetworkNeighborhood CRDs are removed upstream. Remove the
GetApplicationProfile/GetNetworkNeighborhood/ListApplicationProfiles/
ListNetworkNeighborhoods client wrappers (no callers) and the tests covering
them. The mock's AP/NN methods stay only to satisfy the still-generated proto
StorageServiceClient interface; dropping the AP/NN RPCs and adding a
ListContainerProfiles RPC is a storage-side proto follow-up.

Signed-off-by: entlein <einentlein@gmail.com>
…roto

The storage migration removed the ApplicationProfile and NetworkNeighborhood
types, so the gRPC storage-service proto that embedded them no longer compiles
against the migrated storage. Drop them from the surface: remove the
ListApplicationProfiles / ListNetworkNeighborhoods rpcs and their request and
response messages, and the application_profile / network_neighborhood fields
from GetProfileResponse (reserved 4, 5). ContainerProfile is the only profile
type. Regenerate the message + gRPC bindings from the updated .proto, drop the
corresponding mock methods from the client test, and pin storage v0.0.290.

Signed-off-by: entlein <einentlein@gmail.com>
Close the coverage gaps on the storage gRPC client: GetContainerProfileStream /
SendContainerProfileStream error branches (server !Success, nil metadata,
unmarshal failure, mid-stream send/recv abort), the >4 MiB chunk-split proof
(client must split rather than ship one oversized frame), real bufconn
round-trips for the previously mock-only unary GetContainerProfile /
SendContainerProfile (incl. the not-found !Success path), and the
Connect/Close/IsConnected/GetAddress dial lifecycle. Coverage 68.0% -> 71.7%.
Test-only; extends the existing bufconn harness with error-injection knobs.

Signed-off-by: entlein <einentlein@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
pkg/client/v1/storageclient_test.go (2)

253-273: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Nit: redundant tt := tt and stale test name.

Line 255 re-declares tt inside the subtest closure, which shadows nothing useful — the classic capture workaround belongs before t.Run, and it is unnecessary altogether on Go 1.22+. Also, the test now exercises GetContainerProfile, so TestStorageClient_GetProfile is a misleading name.

♻️ Suggested cleanup
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			tt := tt
 			mockClient := &mockStorageServiceClient{
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/client/v1/storageclient_test.go` around lines 253 - 273, Remove the
redundant inner tt := tt capture from the t.Run closure, relying on the
project’s Go version semantics, and rename the enclosing test from
TestStorageClient_GetProfile to accurately reflect its GetContainerProfile
coverage.

582-596: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Abort path records chunk count but not received bytes.

The abort branch sets cpReceivedChunks while leaving cpReceivedBytes unchanged; there are no mid-stream abort tests that would catch this so far. Also, fmt is already imported in this test file, so fmt.Errorf is not an issue.

♻️ Optional: record bytes on abort too
 		if abort {
 			s.mu.Lock()
+			s.cpReceivedBytes = buf
 			s.cpReceivedChunks = count
 			s.mu.Unlock()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/client/v1/storageclient_test.go` around lines 582 - 596, Update the abort
branch in the stream handler to assign the accumulated buf to cpReceivedBytes
before returning the error, while preserving the existing cpReceivedChunks
update and synchronization.
pkg/client/v1/proto/storage_service.proto (1)

122-126: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reserving 4 and 5 is right; the kind doc is now stale.

GetProfileRequest.kind (Line 95) still documents "applicationProfile" and "networkNeighborhood" as accepted values, but the response can no longer carry them. Worth updating that comment (and the generated bindings) in the same change so the contract reads consistently.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/client/v1/proto/storage_service.proto` around lines 122 - 126, Update the
documentation for GetProfileRequest.kind to remove applicationProfile and
networkNeighborhood and describe only the currently supported kind values,
consistent with the response fields and reserved numbers. Regenerate the
protobuf bindings so the generated API documentation reflects the updated
contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@go.mod`:
- Line 20: Update the direct google.golang.org/grpc dependency in go.mod from
v1.80.0 to the fixed release addressing GHSA-hrxh-6v49-42gf / GO-2026-6061, then
rerun vulnerability scanning. If the scanner still requires an exception,
document that the affected service/server paths are not used in production.

---

Nitpick comments:
In `@pkg/client/v1/proto/storage_service.proto`:
- Around line 122-126: Update the documentation for GetProfileRequest.kind to
remove applicationProfile and networkNeighborhood and describe only the
currently supported kind values, consistent with the response fields and
reserved numbers. Regenerate the protobuf bindings so the generated API
documentation reflects the updated contract.

In `@pkg/client/v1/storageclient_test.go`:
- Around line 253-273: Remove the redundant inner tt := tt capture from the
t.Run closure, relying on the project’s Go version semantics, and rename the
enclosing test from TestStorageClient_GetProfile to accurately reflect its
GetContainerProfile coverage.
- Around line 582-596: Update the abort branch in the stream handler to assign
the accumulated buf to cpReceivedBytes before returning the error, while
preserving the existing cpReceivedChunks update and synchronization.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 195220f6-3b10-471a-83c6-2482e38e9d17

📥 Commits

Reviewing files that changed from the base of the PR and between ff7bd6b and aa1d0a6.

⛔ Files ignored due to path filters (3)
  • go.sum is excluded by !**/*.sum
  • pkg/client/v1/proto/storage_service.pb.go is excluded by !**/*.pb.go
  • pkg/client/v1/proto/storage_service_grpc.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (5)
  • go.mod
  • pkg/client/v1/proto/storage_service.proto
  • pkg/client/v1/storageclient.go
  • pkg/client/v1/storageclient_coverage_test.go
  • pkg/client/v1/storageclient_test.go
💤 Files with no reviewable changes (1)
  • pkg/client/v1/storageclient.go

Comment thread go.mod Outdated
Signed-off-by: entlein <einentlein@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: WIP

Development

Successfully merging this pull request may close these issues.

2 participants