Skip to content

fix: create_vm() detects ERROR status, fails fast with fault detail - #24

Draft
Koan-Bot wants to merge 1 commit into
atoomic:masterfrom
Koan-Bot:koan.atoomic/create-vm-detect-error-status
Draft

fix: create_vm() detects ERROR status, fails fast with fault detail#24
Koan-Bot wants to merge 1 commit into
atoomic:masterfrom
Koan-Bot:koan.atoomic/create-vm-detect-error-status

Conversation

@Koan-Bot

Copy link
Copy Markdown
Contributor

What

Detect ERROR status while polling a newly created VM and die immediately with the fault code/message from the server response, instead of waiting out the full timeout.

Why

When OpenStack fails to provision (no scheduling host, image/quota issue, network problem) the server transitions to ERROR and the response includes a fault object explaining what went wrong. The current loop keeps polling for ACTIVE regardless — burning the full create_max_timeout (default 5 min) — then dies with a generic never came back as active message that throws away the fault info OpenStack already gave us.

This is the kind of bug that quietly costs operators hours during outages.

How

  • Inside the polling loop in MetaAPI.pm::create_vm, lowercase the status once and branch on active/error instead of only active.
  • On error, build a die message that includes $server_uid, fault->{code}, and fault->{message} when present — gracefully degrading when there is no fault hash.
  • Pure additive: the success path and timeout path are unchanged.

Testing

  • New t/create-vm-error-status.t with 4 subtests:
    • ERROR + fault → dies immediately with the fault message, polling stops within the first few iterations (not at timeout).
    • lower-case error is also caught.
    • ERROR with no fault hash still dies cleanly.
  • Full suite green: prove -l t/ — 27 tests across 7 files.

🤖 Generated with Claude Code

When a VM transitions to ERROR (scheduler failure, image issue, quota
exhaustion, etc.) create_vm() would keep polling for ACTIVE until the
configured timeout — typically 5 minutes — then die with a generic
"never came back as active" message. The fault data already attached
to the server response was discarded.

Detect ERROR (case-insensitive) inside the loop and die immediately
with the fault code/message when present, so callers learn about
provisioning failures fast and with diagnostic detail.

Adds t/create-vm-error-status.t covering: fast-fail behaviour, lower-case
status, and the no-fault-structure edge case.
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