Skip to content

fix: send clusterId in inline-create boot disk - #3

Merged
gurinderu merged 1 commit into
mainfrom
fix/vm-inline-boot-disk-cluster-id
May 22, 2026
Merged

gurinderu merged 1 commit into
mainfrom
fix/vm-inline-boot-disk-cluster-id

Conversation

@gurinderu

Copy link
Copy Markdown
Contributor

Problem

terraform apply of a cloudless_vm with an inline boot_disk fails against the real Fluence API:

400 Input validation error: bootDisk: data did not match any variant of untagged enum VmBootDisk

Root cause

The API's VmBootDisk oneOf create variant is a CreateUserStorageRequest, which requires clusterId. The provider built CreateUserStorageInline without clusterId, so the serialized body matched neither oneOf variant (not the string storage-id form, not the create form).

Two reasons this slipped through:

  • The mock server (internal/client/mock/vm.go) treats any non-string bootDisk as an inline create and synthesizes an ID, so unit/mock tests passed.
  • terraform plan only validates against the provider schema and never sends the create request, so the bad body only appears at apply against the real API.

Fix

  • Add ClusterID to CreateUserStorageInline (clusterId JSON tag).
  • Thread the VM's cluster_id into the inline boot disk in bootDiskToAPI.
  • Add a bootDiskToAPI unit test asserting clusterId is populated and survives marshaling.

Testing

  • go test ./... passes.
  • The new test fails without the fix ("clusterId":"") and passes with it.

Possible follow-ups (not in this PR)

  • Make the mock reject an inline boot disk missing clusterId, so this class of mock/real divergence is caught in CI.
  • Validate replicated = false for NVME (local storage cannot be replicated).

The Fluence API's VmBootDisk oneOf create variant is a
CreateUserStorageRequest, which requires clusterId. The inline-create
path built a CreateUserStorageInline without it, so `terraform apply` of
a cloudless_vm with an inline boot_disk failed with:

  400 Input validation error: bootDisk: data did not match any variant
  of untagged enum VmBootDisk

Thread the VM's cluster_id into the inline boot disk so the body matches
the create variant.

The mock server accepted the malformed body (it treats any non-string
bootDisk as an inline create and synthesizes an ID), so this only
surfaced against the real API. Add a bootDiskToAPI unit test asserting
clusterId is populated and marshaled.
@gurinderu
gurinderu merged commit 07d900c into main May 22, 2026
1 check passed
@gurinderu
gurinderu deleted the fix/vm-inline-boot-disk-cluster-id branch May 22, 2026 16:13
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