Skip to content

Fix/instance wait live meta v0.0.23#35

Merged
ditahkk merged 4 commits into
mainfrom
fix/instance-wait-live-meta-v0.0.23
Jul 8, 2026
Merged

Fix/instance wait live meta v0.0.23#35
ditahkk merged 4 commits into
mainfrom
fix/instance-wait-live-meta-v0.0.23

Conversation

@ditahkk

@ditahkk ditahkk commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • instance --wait now uses live VM state, so create/start/stop commands complete more reliably when updates take longer to reconcile.
    • instance delete --delete-public-ip messaging now correctly warns that public IPs are not released automatically and must be freed manually after deletion.
    • Updated release notes and examples to match the current version.

ditahkk added 3 commits July 8, 2026 12:39
instance create/start/stop --wait polled the cached list/show endpoint
(svc.Get), which can report Starting for many minutes after a VM is
actually Running because the CMP's background state reconciliation is
unreliable. --wait could hang until timeout on an already-running VM.

Poll GET /virtual-machines/{slug}/meta instead: it performs a live
reconcile against the platform (CloudStack/APC) and returns the
authoritative state. Adds SDK method instance.Service.Meta. Verified
live: create --wait returned Running via /meta while instance list still
showed Starting.
The flag advertised releasing the auto-assigned public IP on delete, but
that never worked against the live API: DELETE ignores it and the
IP-releasing PUT .../destroy endpoint rejects API-token auth (a CMP bug,
under fix). The help, confirmation prompt, and examples now state the IP
is not auto-released and point to 'zcp ip release <ip-slug>' as the
manual workaround. Messaging only; no behavior change.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ditahkk, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 22 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a110319a-23cf-4c94-b58d-590b3088ff68

📥 Commits

Reviewing files that changed from the base of the PR and between fe3d881 and 3ed4876.

📒 Files selected for processing (3)
  • .github/workflows/build.yml
  • .github/workflows/smoke.yml
  • go.mod
📝 Walkthrough

Walkthrough

Adds a VMMeta type and Service.Meta method that polls the live /meta endpoint for authoritative VM state, updates WaitForState to use it, corrects instance delete --delete-public-ip messaging to reflect current no-op behavior, and documents both fixes in CHANGELOG.md and RELEASE_NOTES.md for v0.0.23.

Changes

Instance meta polling and delete UX correction

Layer / File(s) Summary
VMMeta type and Meta polling in WaitForState
pkg/api/instance/instance.go
Adds VMMeta struct and Service.Meta method calling /virtual-machines/{slug}/meta; WaitForState now polls via Meta and overwrites vm.State with the authoritative meta state.
instance delete --delete-public-ip messaging update
internal/commands/instance.go
Updates delete command example, confirmation prompt, and flag help text to state the flag is a no-op requiring manual zcp ip release.
Changelog and release notes for v0.0.23
CHANGELOG.md, RELEASE_NOTES.md
Documents the /meta polling fix and delete-public-ip correction, and bumps the example version output to v0.0.23.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as instance --wait
  participant Service as instance.Service
  participant API as CMP API

  CLI->>Service: WaitForState(ctx, slug, targetStates)
  loop poll ticks
    Service->>API: GET /virtual-machines/{slug}/meta
    API-->>Service: VMMeta{State}
    alt meta.State matches target
      Service->>API: Get(ctx, slug)
      API-->>Service: VirtualMachine
      Service->>Service: vm.State = meta.State
      Service-->>CLI: VirtualMachine
    end
  end
Loading

Possibly related PRs

  • zsoftly/zcp-cli#22: Both PRs modify instance delete's --delete-public-ip CLI help/prompt and backend delete behavior.

Suggested reviewers: ditahm6, ClintonChe, godsonten

🚥 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 is concise and clearly reflects the main change: instance wait now uses live meta state.
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
  • Commit unit tests in branch fix/instance-wait-live-meta-v0.0.23

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.

@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.

🧹 Nitpick comments (2)
pkg/api/instance/instance.go (2)

630-633: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Transient Meta errors abort the entire polling loop.

WaitForState returns immediately on any Meta error. For a function designed to poll for minutes, a single transient failure (network timeout, 502, etc.) will abort the wait and force the caller to retry from scratch. Consider logging the error and continuing to the next tick, only returning on context cancellation.

♻️ Suggested refactor: continue polling on transient errors
 		case <-ticker.C:
 			meta, err := s.Meta(ctx, slug)
 			if err != nil {
-				return nil, err
+				// Log and keep polling; only context cancellation stops the wait.
+				continue
 			}
🤖 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/api/instance/instance.go` around lines 630 - 633, WaitForState currently
exits immediately when s.Meta(ctx, slug) returns an error, which makes transient
failures break the whole poll loop. Update WaitForState so Meta errors are
logged and the loop continues to the next tick instead of returning, and only
exit early on context cancellation or a terminal state condition. Use the
existing WaitForState and Meta calls to locate the polling logic.

584-641: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add tests for Meta and WaitForState. pkg/api/instance/instance_test.go covers List/Get/Start/Stop/Delete, but not the new /meta path or the updated polling/error paths in WaitForState.

🤖 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/api/instance/instance.go` around lines 584 - 641, The new `Meta` and
`WaitForState` behavior in `Service` is untested, so add coverage in
`instance_test.go` for the `/virtual-machines/{slug}/meta` path and the polling
flow. Verify `Meta` returns a decoded `VMMeta` on success and propagates
HTTP/status and unmarshal errors, and that `WaitForState` uses `Meta` to detect
target states, returns the `VirtualMachine` with the authoritative state, and
surfaces context/lookup errors correctly. Use the existing `Service`, `Meta`,
and `WaitForState` helpers in the test suite to keep the new tests aligned with
the current API patterns.
🤖 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.

Nitpick comments:
In `@pkg/api/instance/instance.go`:
- Around line 630-633: WaitForState currently exits immediately when s.Meta(ctx,
slug) returns an error, which makes transient failures break the whole poll
loop. Update WaitForState so Meta errors are logged and the loop continues to
the next tick instead of returning, and only exit early on context cancellation
or a terminal state condition. Use the existing WaitForState and Meta calls to
locate the polling logic.
- Around line 584-641: The new `Meta` and `WaitForState` behavior in `Service`
is untested, so add coverage in `instance_test.go` for the
`/virtual-machines/{slug}/meta` path and the polling flow. Verify `Meta` returns
a decoded `VMMeta` on success and propagates HTTP/status and unmarshal errors,
and that `WaitForState` uses `Meta` to detect target states, returns the
`VirtualMachine` with the authoritative state, and surfaces context/lookup
errors correctly. Use the existing `Service`, `Meta`, and `WaitForState` helpers
in the test suite to keep the new tests aligned with the current API patterns.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 39af3dc1-613b-44f0-91a3-0f028a7cfb25

📥 Commits

Reviewing files that changed from the base of the PR and between 78405f1 and fe3d881.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • RELEASE_NOTES.md
  • internal/commands/instance.go
  • pkg/api/instance/instance.go

govulncheck flagged GO-2026-5856 (Encrypted Client Hello privacy leak in
the stdlib crypto/tls), fixed in go1.26.5. Bump the go.mod toolchain and
the CI go-version pins (build.yml x3, smoke.yml) from 1.26.4 to 1.26.5 so
the security scan builds against the patched standard library. Verified
locally: build + tests pass on go1.26.5 and govulncheck reports 0 called
vulnerabilities.
@ditahkk ditahkk merged commit 30411c2 into main Jul 8, 2026
21 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.

1 participant