Skip to content

Conversation

@yaacov
Copy link
Owner

@yaacov yaacov commented Nov 28, 2025

Summary by CodeRabbit

  • Performance

    • Standardized watch-mode polling across listing commands to a shorter, centralized default interval (now 5s), improving refresh responsiveness.
  • Chores

    • Removed many redundant hard-coded polling values and unified interval handling for more consistent behavior across the CLI.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 28, 2025

Walkthrough

Replaced hard-coded watch polling durations with a new centralized constant watch.DefaultInterval (set to 5s) and removed unused time imports across many list/watch call sites. No public signatures or other control flow/behavioral changes were introduced.

Changes

Cohort / File(s) Summary
Inventory List Functions
pkg/cmd/get/inventory/clusters.go, pkg/cmd/get/inventory/datacenters.go, pkg/cmd/get/inventory/datastores.go, pkg/cmd/get/inventory/datavolumes.go, pkg/cmd/get/inventory/disks.go, pkg/cmd/get/inventory/ec2.go, pkg/cmd/get/inventory/folders.go, pkg/cmd/get/inventory/hosts.go, pkg/cmd/get/inventory/namespaces.go, pkg/cmd/get/inventory/networks.go, pkg/cmd/get/inventory/openstack.go, pkg/cmd/get/inventory/profiles.go, pkg/cmd/get/inventory/providers.go, pkg/cmd/get/inventory/pvcs.go, pkg/cmd/get/inventory/resource_pools.go, pkg/cmd/get/inventory/storage.go, pkg/cmd/get/inventory/vms.go
Replaced hard-coded 10s watch intervals with watch.DefaultInterval; removed unused time imports. No other logic, error handling, or signatures changed.
Command List Functions
pkg/cmd/get/hook/list.go, pkg/cmd/get/host/list.go, pkg/cmd/get/mapping/list.go, pkg/cmd/get/plan/list.go, pkg/cmd/get/provider/list.go
Replaced hard-coded 15s watch intervals with watch.DefaultInterval (and removed unused time imports where applicable). No other logic or signature changes.
Plan VMs Function
pkg/cmd/get/plan/vms.go
Replaced hard-coded 20s watch interval with watch.DefaultInterval; removed unused time import. No other behavioral changes.
Watch Utility
pkg/util/watch/watch.go
Added exported constant DefaultInterval (set to 5s) in package watch. No other API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Homogeneous, repetitive changes (literal durations → watch.DefaultInterval) across many files.
  • Spot-check these areas:
    • pkg/util/watch/watch.go (verify exported constant naming/value and intended visibility).
    • Representative list/watch call sites where different original values existed (e.g., files that moved from 20s/15s vs. 10s) to confirm the uniform replacement is intended.
    • Any tests or documentation referencing previous durations (not present in this diff).

Possibly related PRs

Poem

🐰
Five seconds now, a steady beat,
No scattered sleeps upon the street.
From hosts to plans the timers sing,
A tiny hop, a constant spring.
Rabbit cheers — the watches bring!

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 '5s interval' directly describes the main change: standardizing watch polling intervals to a 5-second default across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch more-watch

📜 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 900676c and 4c0e502.

📒 Files selected for processing (24)
  • pkg/cmd/get/hook/list.go (1 hunks)
  • pkg/cmd/get/host/list.go (1 hunks)
  • pkg/cmd/get/inventory/clusters.go (1 hunks)
  • pkg/cmd/get/inventory/datacenters.go (1 hunks)
  • pkg/cmd/get/inventory/datastores.go (1 hunks)
  • pkg/cmd/get/inventory/datavolumes.go (1 hunks)
  • pkg/cmd/get/inventory/disks.go (1 hunks)
  • pkg/cmd/get/inventory/ec2.go (4 hunks)
  • pkg/cmd/get/inventory/folders.go (1 hunks)
  • pkg/cmd/get/inventory/hosts.go (1 hunks)
  • pkg/cmd/get/inventory/namespaces.go (1 hunks)
  • pkg/cmd/get/inventory/networks.go (1 hunks)
  • pkg/cmd/get/inventory/openstack.go (8 hunks)
  • pkg/cmd/get/inventory/profiles.go (2 hunks)
  • pkg/cmd/get/inventory/providers.go (1 hunks)
  • pkg/cmd/get/inventory/pvcs.go (1 hunks)
  • pkg/cmd/get/inventory/resource_pools.go (1 hunks)
  • pkg/cmd/get/inventory/storage.go (1 hunks)
  • pkg/cmd/get/inventory/vms.go (1 hunks)
  • pkg/cmd/get/mapping/list.go (1 hunks)
  • pkg/cmd/get/plan/list.go (1 hunks)
  • pkg/cmd/get/plan/vms.go (1 hunks)
  • pkg/cmd/get/provider/list.go (1 hunks)
  • pkg/util/watch/watch.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (17)
  • pkg/cmd/get/inventory/clusters.go
  • pkg/cmd/get/inventory/hosts.go
  • pkg/cmd/get/host/list.go
  • pkg/cmd/get/inventory/namespaces.go
  • pkg/cmd/get/provider/list.go
  • pkg/cmd/get/inventory/disks.go
  • pkg/cmd/get/inventory/networks.go
  • pkg/cmd/get/inventory/resource_pools.go
  • pkg/cmd/get/inventory/pvcs.go
  • pkg/cmd/get/inventory/storage.go
  • pkg/cmd/get/mapping/list.go
  • pkg/cmd/get/inventory/profiles.go
  • pkg/cmd/get/inventory/datavolumes.go
  • pkg/cmd/get/inventory/openstack.go
  • pkg/cmd/get/inventory/datacenters.go
  • pkg/cmd/get/plan/vms.go
  • pkg/cmd/get/inventory/datastores.go
🧰 Additional context used
🧬 Code graph analysis (5)
pkg/cmd/get/inventory/providers.go (1)
pkg/util/watch/watch.go (1)
  • DefaultInterval (14-14)
pkg/cmd/get/plan/list.go (1)
pkg/util/watch/watch.go (1)
  • DefaultInterval (14-14)
pkg/cmd/get/hook/list.go (1)
pkg/util/watch/watch.go (1)
  • DefaultInterval (14-14)
pkg/cmd/get/inventory/folders.go (1)
pkg/util/watch/watch.go (1)
  • DefaultInterval (14-14)
pkg/cmd/get/inventory/vms.go (1)
pkg/util/watch/watch.go (1)
  • DefaultInterval (14-14)
🔇 Additional comments (3)
pkg/util/watch/watch.go (1)

13-14: LGTM - Centralized interval constant.

The new DefaultInterval constant provides a single source of truth for watch polling intervals across the codebase, improving maintainability.

pkg/cmd/get/plan/list.go (1)

251-251: Note: Polling interval reduced by 3x.

The watch interval for plans has been reduced from 15s to 5s (via watch.DefaultInterval), tripling the polling frequency. This is more aggressive than the 2x increase for inventory operations and may have different performance characteristics given the complexity of plan status computation.

pkg/cmd/get/inventory/folders.go (1)

19-19: The review comment's core premise is incorrect—this file was newly added, not modified.

The git history shows that pkg/cmd/get/inventory/folders.go was created as a new file in commit 4c0e502 with watch.DefaultInterval already in place. There was no prior interval to change from. The review comment incorrectly states the change was from 10*time.Second to watch.DefaultInterval, but the file did not exist before this commit.

While the broader codebase does use watch.DefaultInterval (5 seconds) across 33 watch-mode call sites, and one operation (describe_vm.go) uses a longer 20-second interval, the specific concern about a reduced polling interval impacting the inventory API service is based on a false premise for this file.


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

@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: 0

🧹 Nitpick comments (2)
pkg/cmd/get/hook/list.go (1)

253-257: Watch interval reduced appropriately.

The reduction from 15s to 5s makes watch mode more responsive. However, consider that this increases API polling frequency by 3x, which could impact API server load in environments with many concurrent watch sessions.

If this change was prompted by user feedback about responsiveness, you might consider making the interval configurable via a flag (e.g., --watch-interval) to allow users to balance responsiveness against resource consumption based on their needs.

pkg/cmd/get/inventory/openstack.go (1)

16-21: OpenStack watchers standardized to 5s; consider a shared interval constant

All OpenStack List*WithInsecure watchers now poll every 5s, which is consistent with the rest of the codebase and keeps the underlying list logic untouched. Since this file repeats 5*time.Second many times, you might optionally introduce a const (e.g., defaultWatchInterval = 5 * time.Second) or reuse a shared value from the watch package to avoid magic numbers and ease future tuning.

Also applies to: 95-100, 176-181, 259-264, 336-341, 418-423, 495-500, 576-581

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8693181 and 900676c.

📒 Files selected for processing (23)
  • pkg/cmd/get/hook/list.go (1 hunks)
  • pkg/cmd/get/host/list.go (1 hunks)
  • pkg/cmd/get/inventory/clusters.go (1 hunks)
  • pkg/cmd/get/inventory/datacenters.go (1 hunks)
  • pkg/cmd/get/inventory/datastores.go (1 hunks)
  • pkg/cmd/get/inventory/datavolumes.go (1 hunks)
  • pkg/cmd/get/inventory/disks.go (1 hunks)
  • pkg/cmd/get/inventory/ec2.go (4 hunks)
  • pkg/cmd/get/inventory/folders.go (1 hunks)
  • pkg/cmd/get/inventory/hosts.go (1 hunks)
  • pkg/cmd/get/inventory/namespaces.go (1 hunks)
  • pkg/cmd/get/inventory/networks.go (1 hunks)
  • pkg/cmd/get/inventory/openstack.go (8 hunks)
  • pkg/cmd/get/inventory/profiles.go (2 hunks)
  • pkg/cmd/get/inventory/providers.go (1 hunks)
  • pkg/cmd/get/inventory/pvcs.go (1 hunks)
  • pkg/cmd/get/inventory/resource_pools.go (1 hunks)
  • pkg/cmd/get/inventory/storage.go (1 hunks)
  • pkg/cmd/get/inventory/vms.go (1 hunks)
  • pkg/cmd/get/mapping/list.go (1 hunks)
  • pkg/cmd/get/plan/list.go (1 hunks)
  • pkg/cmd/get/plan/vms.go (1 hunks)
  • pkg/cmd/get/provider/list.go (1 hunks)
⏰ 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). (1)
  • GitHub Check: Test kubectl-mtv
🔇 Additional comments (21)
pkg/cmd/get/host/list.go (1)

227-227: LGTM - Consistent polling interval.

The watch interval reduction from 15s to 5s aligns with the PR's objective to standardize polling across all watch-enabled list commands.

pkg/cmd/get/inventory/networks.go (1)

51-51: LGTM - Consistent polling interval.

pkg/cmd/get/provider/list.go (1)

395-395: Verify the performance impact of increased polling frequency.

The interval reduction from 15s to 5s improves responsiveness but triples the API call rate. Ensure that the Kubernetes API server and inventory services can handle the increased load, especially with multiple concurrent watchers.

Consider monitoring backend API call volumes and response times after deployment to validate that the increased frequency doesn't cause performance degradation or rate limiting issues.

pkg/cmd/get/inventory/pvcs.go (1)

20-20: LGTM - Consistent polling interval.

pkg/cmd/get/inventory/vms.go (1)

297-297: LGTM - Consistent polling interval.

pkg/cmd/get/plan/list.go (1)

251-251: LGTM - Consistent polling interval.

pkg/cmd/get/plan/vms.go (1)

56-56: LGTM - Significant polling interval reduction.

The reduction from 20s to 5s (4x increase in frequency) is the largest change in this PR. This is beneficial for tracking active migrations where VM states change rapidly.

pkg/cmd/get/inventory/folders.go (1)

20-20: LGTM - Consistent polling interval.

pkg/cmd/get/inventory/storage.go (1)

17-25: LGTM!

The watch interval reduction is consistent with the broader PR changes and makes the listing more responsive.

pkg/cmd/get/inventory/disks.go (1)

16-24: LGTM!

The watch interval change is consistent and correct.

pkg/cmd/get/inventory/resource_pools.go (1)

16-24: LGTM!

The watch interval reduction aligns with the PR objectives.

pkg/cmd/get/inventory/providers.go (1)

18-26: LGTM!

Consistent watch interval reduction.

pkg/cmd/get/inventory/namespaces.go (1)

17-25: LGTM!

The change is correct and consistent.

pkg/cmd/get/inventory/clusters.go (1)

16-24: LGTM!

The watch interval change aligns with the PR pattern.

pkg/cmd/get/mapping/list.go (1)

316-320: LGTM!

The watch interval reduction from 15s to 5s improves responsiveness and is consistent with similar changes across the codebase.

pkg/cmd/get/inventory/datacenters.go (1)

16-21: Datacenters watch interval now 5s — looks good

The reduced watch interval is consistent with the PR goal and keeps the control flow unchanged.

pkg/cmd/get/inventory/datastores.go (1)

16-21: Datastores watch interval reduced to 5s — consistent with other commands

Only the cadence changed; the single-shot and error paths are untouched.

pkg/cmd/get/inventory/datavolumes.go (1)

16-21: DataVolumes watch now polls every 5s — OK

The new interval is consistent with the rest of the inventory watchers; logic remains identical.

pkg/cmd/get/inventory/ec2.go (1)

16-21: EC2 watchers unified to 5s interval

All EC2 list/watch wrappers now use a 5s polling interval, which is consistent within this file and with the rest of the PR; the underlying listing logic and error handling are unchanged.

Also applies to: 99-104, 185-190, 263-268

pkg/cmd/get/inventory/hosts.go (1)

17-22: Hosts watch interval lowered to 5s — no issues

The change is limited to the watch cadence; listHostsOnce behavior and validation remain intact.

pkg/cmd/get/inventory/profiles.go (1)

16-21: Disk/NIC profile watchers now 5s — aligned with rest of inventory

Both ListDiskProfilesWithInsecure and ListNICProfilesWithInsecure now poll every 5s in watch mode, matching the rest of the watch-enabled commands without altering their core logic.

Also applies to: 93-98

Signed-off-by: yaacov <[email protected]>
@yaacov yaacov merged commit 8eab290 into main Nov 28, 2025
2 checks passed
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