Skip to content

refactor(storage): add ListContainerProfiles to ProfileClient - #1005

Merged
matthyx merged 2 commits into
mainfrom
refactor/storage-list-container-profiles
Oct 9, 2026
Merged

matthyx merged 2 commits into
mainfrom
refactor/storage-list-container-profiles

Conversation

@matthyx

@matthyx matthyx commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Description

Adds ListContainerProfiles(ctx context.Context, namespace string, opts metav1.ListOptions) (*v1beta1.ContainerProfileList, error) to the storage.ProfileClient interface, implemented on *storage.Storage and *storage.StorageHttpClientMock.

Value & Context

In subsequent phases (signed bundles and suggester), container profiles may be split into fragments or queried by labels (such as signature.kubescape.io/bundle=<name>). Adding ListContainerProfiles to ProfileClient prepares this extension point across the storage layer and cache mocks with full label-selector filtering support.

Testing

  • Added unit test TestStorageHttpClientMock_ListContainerProfiles covering namespace and label selector filtering.
  • Updated all test doubles implementing storage.ProfileClient across pkg/objectcache/containerprofilecache.
  • All tests pass cleanly (go test ./pkg/storage/... ./pkg/objectcache/...).

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You鈥檝e used the included review currently available.

Learn how review limits work.

Review configuration:

鈿欙笍 Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff72b896-c400-4443-ac4b-a9f850c1895a
馃摜 Commits

Reviewing files that changed from the base of the PR and between 67e455e and 4f9f395.

馃搾 Files selected for processing (10)
  • pkg/objectcache/containerprofilecache/containerprofilecache_test.go
  • pkg/objectcache/containerprofilecache/host_shared_data_test.go
  • pkg/objectcache/containerprofilecache/integration_helpers_test.go
  • pkg/objectcache/containerprofilecache/reconciler_checksum_test.go
  • pkg/objectcache/containerprofilecache/reconciler_notfound_test.go
  • pkg/objectcache/containerprofilecache/reconciler_test.go
  • pkg/storage/storage_interface.go
  • pkg/storage/storage_mock.go
  • pkg/storage/storage_mock_test.go
  • pkg/storage/v1/containerprofile.go
  • Autopilot 路 Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Performance Benchmark Results

Node-Agent Resource Usage
Metric BEFORE AFTER Delta
Avg CPU (cores) 0.219 0.217 -0.7%
Peak CPU (cores) 0.225 0.225 +0.2%
Peak CPU p95 (cores) 0.225 0.225 +0.3%
Avg Memory (MiB) 397.299 316.895 -20.2%
Peak Memory (MiB) 400.996 325.582 -18.8%
Dedup Effectiveness

No data available.

Copilot AI 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.

Copilot review overview

馃煛 Changes recommended

The mock silently accepts invalid selectors and does not implement cluster-wide namespace listing consistently with the real client.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds namespace-aware, label-filterable ContainerProfile listing to the storage abstraction and its test implementations.

Changes:

  • Extends ProfileClient with ListContainerProfiles.
  • Implements listing for real and mock storage clients.
  • Updates tests and cache test doubles for interface compatibility.
File Description
pkg/鈥媠torage/鈥媣1/鈥媍ontainerprofile.go Delegates profile listing to the typed storage client.
pkg/鈥媠torage/鈥媠torage_mock.go Adds in-memory namespace and label filtering.
pkg/鈥媠torage/鈥媠torage_mock_test.go Tests mock listing and filtering.
pkg/鈥媠torage/鈥媠torage_interface.go Extends the profile client interface.
pkg/鈥媜bjectcache/鈥媍ontainerprofilecache/鈥媟econciler_test.go Updates profile-client test doubles.
pkg/鈥媜bjectcache/鈥媍ontainerprofilecache/鈥媟econciler_notfound_test.go Updates scripted test client.
pkg/鈥媜bjectcache/鈥媍ontainerprofilecache/鈥媟econciler_checksum_test.go Updates checksum-related test clients.
pkg/鈥媜bjectcache/鈥媍ontainerprofilecache/鈥媔ntegration_helpers_test.go Updates integration storage stub.
pkg/鈥媜bjectcache/鈥媍ontainerprofilecache/鈥媓ost_shared_data_test.go Updates signaling test client.
pkg/鈥媜bjectcache/鈥媍ontainerprofilecache/鈥媍ontainerprofilecache_test.go Updates shared fake profile client.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/storage/storage_mock.go Outdated
Comment thread pkg/storage/storage_mock.go Outdated

Copilot AI 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.

Copilot review overview

馃煝 Approval recommended

The interface, implementations, test doubles, and selector tests are consistent and the previously reported issues are resolved.

Review effort: Balanced
Findings: None

Resolved since last review (2)

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
- propagate label selector parse errors in StorageHttpClientMock.ListContainerProfiles
- preserve metav1.NamespaceAll cluster-wide listing behavior

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
@matthyx
matthyx force-pushed the refactor/storage-list-container-profiles branch from 4b7a2ee to 4f9f395 Compare October 3, 2026 08:17
@matthyx
matthyx requested a balanced review from Copilot October 3, 2026 08:17

Copilot AI 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.

Copilot review overview

馃煝 Approval recommended

The implementation consistently extends production and mock clients with focused coverage for filtering and error behavior.

Review effort: Balanced
Findings: None

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Performance Benchmark Results

Node-Agent Resource Usage
Metric BEFORE AFTER Delta
Avg CPU (cores) 0.145 0.147 +1.6%
Peak CPU (cores) 0.152 0.160 +5.3%
Peak CPU p95 (cores) 0.150 0.156 +3.8%
Avg Memory (MiB) 398.860 318.905 -20.0%
Peak Memory (MiB) 400.766 327.465 -18.3%
Dedup Effectiveness

No data available.

@matthyx
matthyx merged commit cadcb96 into main Oct 9, 2026
70 of 72 checks passed
@matthyx
matthyx deleted the refactor/storage-list-container-profiles branch October 9, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Archive

Development

Successfully merging this pull request may close these issues.

2 participants