Skip to content

vsphere-iso: resource pool path handling can panic or fail with malformed lookup path #657

@bertfranken420

Description

@bertfranken420

Upstream Issue Draft: packer-plugin-vsphere Resource Pool Path/Panic

Title

vsphere-iso: resource pool path handling can panic or fail with malformed lookup path

Repository

hashicorp/packer-plugin-vsphere

Version/Environment

  • Packer: 1.15.0
  • Plugin: github.com/hashicorp/vsphere 2.1.1
  • vCenter: 7.0.3
  • Builder: vsphere-iso

Problem Summary

When resource_pool is provided as a full inventory path (or contains slashes), pool lookup can be malformed and later fail/panic at VM create.

Observed symptoms:

  • malformed path shape in logs like:
    • vSAN Cluster 1/Resources//Datacenter /host/vSAN 1/vSAN Cluster 1/Resources
  • failure around Creating virtual machine...
  • in some runs: plugin crash / unexpected EOF

Repro (high level)

  1. Configure vsphere-iso with resource_pool set to absolute inventory path:
    • /Datacenter/host/vSAN 1/vSAN Cluster 1/Resources
  2. Run packer build.
  3. Observe failure in resource pool resolution / VM create phase.

Expected

resource_pool handling should:

  • accept absolute inventory paths as-is
  • accept slash-containing paths as-is
  • only prefix relative pool names with <cluster>/Resources/...
  • fail with explicit error if default pool cannot be resolved
  • avoid nil pool flow that can cascade into panic

Suggested Fix Area

  • builder/vsphere/driver/resource_pool.go
  • function FindResourcePool(...)

Suggested Logic

  • TrimSpace on input.
  • If empty:
    • try <cluster>/Resources
    • fallback DefaultResourcePool
    • return explicit error if unresolved.
  • If starts with /: resolve as absolute path (with trimmed fallback).
  • If contains /: resolve directly as provided path.
  • Else: treat as relative name under <cluster>/Resources/<name>.
  • Guard against nil pool before returning.

Patch Validation

After patch:

  • no malformed doubled-path behavior
  • no panic at create phase from nil/invalid pool resolution
  • run advances to:
    • Creating virtual machine...
    • Powering on virtual machine...
    • Typing boot command...

Additional Note

If build later fails at timeout waiting for IP, that is guest installer/network/tools path, not this resource-pool resolution bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions