Skip to content

Better handling of missing folders when creating VMs #3651

@FutureMatt

Description

@FutureMatt

/kind feature

Describe the solution you'd like
When a VSphereVM resource specifies a spec.folder that does not exist in vSphere, the CAPV controller should automatically create the necessary folder structure.

Currently, the reconciliation fails with a folder ... not found error, but this error is only visible in the capv-controller-manager logs. This makes troubleshooting difficult as the VSphereVM and Machine objects remain in a Provisioning state without any status conditions or events indicating the root cause of the failure.

The ideal solution would be for CAPV to attempt to create the folder path. If it succeeds, provisioning continues. If it fails (e.g., due to permissions), it should fail gracefully.

Anything else you would like to add:
The current behavior creates a confusing and frustrating user experience. Without inspecting controller logs, it's not obvious why a machine is stuck.

If automatic folder creation isn't possible, a significant improvement would be to surface the error in the VSphereVM resource's status.

For example, the reconciliation loop could update the VSphereVM with a Condition like:

Type: Ready
Status: False
Severity: Error
Reason: FolderNotFound
Message: Failed to reconcile VM: folder '/path/to/vm/folder' not found. Please ensure the folder exists in vCenter.

This would make the problem immediately apparent to users by running kubectl describe vspherevm <vm-name> and would be a major improvement in usability.

Environment:

  • Cluster-api-provider-vsphere version: All versions
  • Kubernetes version: (use kubectl version): N/A
  • OS (e.g. from /etc/os-release): N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions