Skip to content

fix(cluster): report leased ip inventory status#399

Open
chalabi2 wants to merge 3 commits into
mainfrom
akt-366-report-ip-leases-grpc-status
Open

fix(cluster): report leased ip inventory status#399
chalabi2 wants to merge 3 commits into
mainfrom
akt-366-report-ip-leases-grpc-status

Conversation

@chalabi2
Copy link
Copy Markdown

@chalabi2 chalabi2 commented May 28, 2026

Description

Reports leased IP capacity in provider gRPC status through cluster.inventory.leased_ip, using the chain-sdk akash.inventory.v1.ResourcePair added in akash-network/chain-sdk#313.

The provider maps the IP operator total pool to capacity and allocatable, and maps confirmed in-use IPs plus unconfirmed reserved IPs to allocated. Consumers can use allocatable - allocated as the remaining leased IP capacity for bid screening.

Purpose of the Change

  • New feature implementation
  • Bug fix
  • Documentation update
  • Code refactoring
  • Dependency upgrade

Related Issues

Notes for Reviewers

  • pkg.akt.dev/go is bumped to v0.2.12.
  • Leased IP requests are matched by counting unique LEASED_IP endpoint sequence numbers in the group spec via GetEndpointQuantityOfResourceGroup.
  • Remaining leased IP capacity is represented by leased_ip.allocatable - leased_ip.allocated.

Signed-off-by: Joseph Chalabi <chalabi.joseph@gmail.com>
@chalabi2 chalabi2 requested a review from a team as a code owner May 28, 2026 21:19
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 568c2faf-1f06-4d73-80a0-80ee22c62fbe

📥 Commits

Reviewing files that changed from the base of the PR and between 938e554 and ea7c3cf.

⛔ 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

This PR enhances the inventory service with leased-IP reserved/available accounting and reporting, integrates those checks into reservation handling, exposes leased-IP status in snapshots with unit tests, and adds an optional reclamation-window configuration wired through CLI, service, order messages, event logging, and dependency updates.

Changes

Leased-IP Accounting and Reclamation Window

Layer / File(s) Summary
Leased-IP accounting helpers and status computation
cluster/inventory.go
Adds Kubernetes resource import; defines helpers to compute reserved leased IPs from unconfirmed reservations and available capacity by subtracting in-use and reserved from total; updates leasedIPStatus to report allocated and available counts using resource.DecimalSI scaling.
Reservation validation with leased-IP availability checks
cluster/inventory.go
Updates reservation handling to compute reserved and available leased IPs via new helpers, rejects reservations when endpointQuantity exceeds available leased-IP capacity, and changes logs from pending-based to reserved/remaining-based messaging.
Leased-IP status reporting in getStatusV1
cluster/inventory.go
Extends getStatusV1 to set the LeasedIP field from leasedIPStatus in the returned inventory snapshot.
Unit tests for leased-IP resource pairing
cluster/inventory_test.go
Adds TestInventory_StatusV1ReportsLeasedIPResourcePair and TestInventory_StatusV1SaturatesLeasedIPResourcePairAvailable to validate leased-IP capacity, allocatable, allocated, and available reporting and saturation behavior.
Config and service wiring for reclamation window
config.go, service.go, bidengine/config.go
Adds ReclamationWindow *time.Duration to global Config, passes it into bidengine.Config in NewService.
CLI flag and run wiring
cmd/provider-services/cmd/flags.go, cmd/provider-services/cmd/run.go
Adds FlagReclamationWindow, registers the duration flag, reads it in doRunCmd, and sets config.ReclamationWindow when the provided duration is >0.
Attach reclamation window to bid messages
bidengine/order.go
Sets MsgCreateBid.ReclamationWindow from o.cfg.ReclamationWindow before broadcasting bids.
Lease state and reclamation events
cluster/manager.go, cluster/service.go
Allows mv1.LeaseReclaiming in checkLeaseActive and adds handling/logging for EventLeaseReclaimStarted.
Dependency updates
go.mod
Bumps Go toolchain and multiple direct/indirect dependencies (e.g., cosmos-sdk, zerolog, pkg.akt.dev modules, sonic replace, opentelemetry, golang.org/x/*).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I count the leased IPs by moonlit code,
Reserved, used, and waiting on the node.
A flag for reclaim, a window to keep,
My burrow hums while workloads sleep.
Hooray for tidy nets and carrots deep!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(cluster): report leased ip inventory status' directly matches the main change—adding leased IP inventory status reporting to the cluster service.
Description check ✅ Passed The description is well-detailed and clearly related to the changeset, explaining the leased IP inventory status reporting feature, its purpose, and implementation notes.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch akt-366-report-ip-leases-grpc-status

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

Signed-off-by: Artur Troian <troian@users.noreply.github.com>
Signed-off-by: Joseph Chalabi <chalabi.joseph@gmail.com>
Copy link
Copy Markdown

@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)
go.mod (1)

351-355: ⚡ Quick win

Remove OpenTelemetry version skew in go.mod
go.opentelemetry.io/otel / otel/metric / otel/trace are pinned to v1.41.0 while go.opentelemetry.io/otel/sdk / otel/sdk/metric are pinned to v1.37.0, creating an avoidable mismatch.

	go.opentelemetry.io/otel v1.41.0 // indirect
	go.opentelemetry.io/otel/metric v1.41.0 // indirect
	go.opentelemetry.io/otel/sdk v1.37.0 // indirect
	go.opentelemetry.io/otel/sdk/metric v1.37.0 // indirect
	go.opentelemetry.io/otel/trace v1.41.0 // indirect

Bump otel/sdk (and otel/sdk/metric) to match the otel* versions (or pin otel* to match the SDK).

🤖 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 `@go.mod` around lines 351 - 355, The go.mod has version skew between modules:
go.opentelemetry.io/otel and otel/metric/trace are v1.41.0 while
go.opentelemetry.io/otel/sdk and otel/sdk/metric are v1.37.0; update the sdk
module lines (go.opentelemetry.io/otel/sdk and
go.opentelemetry.io/otel/sdk/metric) to the matching v1.41.0 (or alternatively
pin the other otel/* entries to v1.37.0) and then run go get or go mod tidy to
reconcile dependencies so all otel packages use the same version.
🤖 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 13: The go.mod shows require github.com/cosmos/cosmos-sdk v0.53.6 but a
replace currently pins it to github.com/akash-network/cosmos-sdk
v0.53.5-akash.1, so the bump is being shadowed; update or remove the replace
entry that maps github.com/cosmos/cosmos-sdk =>
github.com/akash-network/cosmos-sdk v0.53.5-akash.1 (or change it to point to a
compatible v0.53.6 akash fork) so the require for v0.53.6 takes effect, then run
`go mod tidy` to verify effective version resolution.

---

Nitpick comments:
In `@go.mod`:
- Around line 351-355: The go.mod has version skew between modules:
go.opentelemetry.io/otel and otel/metric/trace are v1.41.0 while
go.opentelemetry.io/otel/sdk and otel/sdk/metric are v1.37.0; update the sdk
module lines (go.opentelemetry.io/otel/sdk and
go.opentelemetry.io/otel/sdk/metric) to the matching v1.41.0 (or alternatively
pin the other otel/* entries to v1.37.0) and then run go get or go mod tidy to
reconcile dependencies so all otel packages use the same version.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2446aa22-79e9-49c1-8577-5502fac27638

📥 Commits

Reviewing files that changed from the base of the PR and between 9ecdd8e and 938e554.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • bidengine/config.go
  • bidengine/order.go
  • cluster/manager.go
  • cluster/service.go
  • cmd/provider-services/cmd/flags.go
  • cmd/provider-services/cmd/run.go
  • config.go
  • go.mod
  • service.go

Comment thread go.mod
Signed-off-by: Joseph Chalabi <chalabi.joseph@gmail.com>
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