Skip to content

Conversation

@michalskrivanek
Copy link
Contributor

@michalskrivanek michalskrivanek commented Oct 14, 2025

it skips the default filter for active leases only. E.g.: jmp get leases -l board=foo --all will use only_active=false to list leases matching the board=foo selector including the ended ones

Summary by CodeRabbit

  • New Features

    • List leases supports an "all" option to include ended leases; default returns only active leases.
    • Pagination, namespace and label filtering behave consistently for predictable paginated listings.
  • Chores

    • Streamlined protobuf/code-generation tooling and build configuration to simplify developer generation workflows.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

ListLeases now builds a variadic listOptions slice (namespace, selector, pageSize, pageToken) and conditionally appends controller.MatchingActiveLeases() when req.OnlyActive is nil or true; List is called with listOptions.... A Makefile protobuf-gen target and updates to buf.gen.yaml were added.

Changes

Cohort / File(s) Summary
Lease listing behavior
internal/service/client/v1/client_service.go
Build a dynamic listOptions slice (namespace, label selector, pageSize, pageToken); append controller.MatchingActiveLeases() when req.OnlyActive is nil or true; call List with listOptions....
Protobuf generation Make target
Makefile
Add phony protobuf-gen target that runs buf generate inside a Podman container using docker.io/bufbuild/buf:latest, mounting repo to /workspace.
Buf generation config
buf.gen.yaml
Add managed.disable entries for two modules, set go_package_prefix override to github.com/jumpstarter-dev/jumpstarter-controller/internal/protocol, and add main as an input branch under inputs.git_repo.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant S as ClientService
  participant K as Controller/List API

  C->>S: ListLeases(req: namespace, selector, pageSize, pageToken, OnlyActive)
  S->>S: Assemble listOptions: namespace, selector, pageSize, pageToken
  alt OnlyActive is nil or true
    S->>S: Append controller.MatchingActiveLeases()
    Note right of S #DFF0D8: Active-only filter appended
  else OnlyActive is false
    Note right of S #F0F0F0: Active filter omitted
  end
  S->>K: List(...listOptions)
  K-->>S: LeaseList (paged)
  S-->>C: Return LeaseList
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop through opts, tidy every trail,
namespace, selector, a paging tale.
If OnlyActive nods, I fetch the bright—
else I gather dawn and dusk alike.
Buf drums beat; the rabbit tips his hat. 🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly summarizes the primary change—adding a backwards-compatible only_active flag to the list leases operation—and directly matches the PR’s objectives without extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 451f279 and 0e8db20.

📒 Files selected for processing (1)
  • Makefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Makefile
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: e2e-tests-28d6b1cc3b49ab9ae176918ab9709a2e2522c97e
  • GitHub Check: e2e-tests (ubuntu-24.04)
  • GitHub Check: lint-go
  • GitHub Check: e2e-tests (ubuntu-24.04-arm)
  • GitHub Check: deploy-kind
  • GitHub Check: 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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (1)
internal/service/client/v1/client_service.go (1)

138-167: Consider adding tests for the new filter parsing logic.

The filter parsing and conditional application logic is well-implemented. To ensure robustness, consider adding tests for edge cases:

  • Empty filter string
  • "all" token only
  • "all" with other selectors (e.g., "all,board=foo")
  • Multiple "all" tokens (e.g., "all,all,key=value")
  • Leading/trailing whitespace and commas
  • Invalid label selectors after removing "all"

If test files exist, search for the test suite:

#!/bin/bash
# Description: Find test files for ClientService to add coverage for the new logic

fd -e go -e test.go | xargs rg -l "TestClientService|Test.*ListLeases"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 441f24d and ca26bd3.

📒 Files selected for processing (1)
  • internal/service/client/v1/client_service.go (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/service/client/v1/client_service.go (2)
internal/controller/lease.go (1)
  • MatchingActiveLeases (12-26)
api/v1alpha1/lease_types.go (1)
  • LeaseList (91-95)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: lint-go
  • GitHub Check: deploy-kind
  • GitHub Check: tests
  • GitHub Check: e2e-tests-28d6b1cc3b49ab9ae176918ab9709a2e2522c97e
  • GitHub Check: e2e-tests (ubuntu-24.04-arm)
  • GitHub Check: e2e-tests (ubuntu-24.04)
🔇 Additional comments (3)
internal/service/client/v1/client_service.go (3)

22-22: LGTM!

The strings import is necessary for the new filter parsing logic.


123-126: LGTM!

The documentation clearly explains the default behavior and the special "all" token usage.


138-147: No changes needed for empty filter handling

labels.Parse("") already returns an “everything” selector without error, so the existing logic correctly handles the “all” token and empty filters.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
internal/service/client/v1/client_service.go (1)

161-164: Default active-only behavior preserved; “all” opt-out is clear

This keeps the existing active-only default and makes including ended leases explicit via “all”. Good.

🧹 Nitpick comments (2)
internal/service/client/v1/client_service.go (2)

154-159: Optional: add pagination options only when set

Avoid sending zero/empty values. No behavior change, just cleaner options.

-	listOptions := []kclient.ListOption{
-		kclient.InNamespace(namespace),
-		kclient.MatchingLabelsSelector{Selector: selector},
-		kclient.Limit(int64(req.PageSize)),
-		kclient.Continue(req.PageToken),
-	}
+	listOptions := []kclient.ListOption{
+		kclient.InNamespace(namespace),
+		kclient.MatchingLabelsSelector{Selector: selector},
+	}
+	if req.PageSize > 0 {
+		listOptions = append(listOptions, kclient.Limit(int64(req.PageSize)))
+	}
+	if req.PageToken != "" {
+		listOptions = append(listOptions, kclient.Continue(req.PageToken))
+	}

123-127: Doc tweak: clarify “all” token and case-sensitivity

Suggest mentioning that “all” is a special, case-insensitive token and can be combined with standard selectors; parentheses in label selectors are supported.

-// By default, only active leases (without the ended label) are returned.
-// To include ended leases, add "all" to the comma-separated filter list as a special case
+// By default, only active leases (without the ended label) are returned.
+// To include ended leases, add the special token "all" (case-insensitive) to the comma-separated filter list,
+// e.g., `all,board=foo` or `env in (a,b),ALL`.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca26bd3 and c9ade57.

📒 Files selected for processing (1)
  • internal/service/client/v1/client_service.go (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/service/client/v1/client_service.go (2)
internal/controller/lease.go (1)
  • MatchingActiveLeases (12-26)
api/v1alpha1/lease_types.go (1)
  • LeaseList (91-95)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: tests
  • GitHub Check: deploy-kind
  • GitHub Check: lint-go
  • GitHub Check: e2e-tests (ubuntu-24.04-arm)
  • GitHub Check: e2e-tests-28d6b1cc3b49ab9ae176918ab9709a2e2522c97e
  • GitHub Check: e2e-tests (ubuntu-24.04)

by setting the new optional active_only bool to false.
Defaults to true.
using the upstream jumpstarter-protocol. This finally doesn't mess up imports.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0139b33 and 451f279.

⛔ Files ignored due to path filters (5)
  • internal/protocol/jumpstarter/client/v1/client.pb.go is excluded by !**/*.pb.go
  • internal/protocol/jumpstarter/v1/common.pb.go is excluded by !**/*.pb.go
  • internal/protocol/jumpstarter/v1/jumpstarter.pb.go is excluded by !**/*.pb.go
  • internal/protocol/jumpstarter/v1/kubernetes.pb.go is excluded by !**/*.pb.go
  • internal/protocol/jumpstarter/v1/router.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (3)
  • Makefile (1 hunks)
  • buf.gen.yaml (2 hunks)
  • internal/service/client/v1/client_service.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/service/client/v1/client_service.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: tests
  • GitHub Check: lint-go
  • GitHub Check: e2e-tests (ubuntu-24.04-arm)
  • GitHub Check: e2e-tests (ubuntu-24.04)
  • GitHub Check: deploy-kind
  • GitHub Check: e2e-tests-28d6b1cc3b49ab9ae176918ab9709a2e2522c97e

@mangelajo mangelajo changed the title Add "all" as a special selector for leases Add a backwards compatible only_active flag on list leases Oct 15, 2025
@mangelajo mangelajo merged commit 3ca8e81 into jumpstarter-dev:main Oct 15, 2025
8 checks passed
@michalskrivanek michalskrivanek deleted the all branch October 16, 2025 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants