Skip to content

fix(azure/aks): VMs in transitional states skipped - ComputerName unavailable before OS is running #868

@rooneyshuman

Description

@rooneyshuman

Summary

getMachineName fails with an error and skips VMs that are in a transitional state (provisioning, failed, deallocating).
These VMs have InstanceView set but ComputerName empty — the OS hasn't started yet so Azure hasn't populated it. No metrics are emitted for them until the next machine store refresh picks them up in a ready state.

Symptoms

2026-03-31 22:29:22.946 ERROR time=2026-03-31T22:29:22.946Z 
level=ERROR 
msg="unable to determine machine name: ..."
provider=azure collector=aks subsystem=machineStore 
  • Logged at ERROR on every machine store refresh cycle (every 5 minutes) for any VM not yet fully running
  • The full struct dump with memory addresses makes the log noisy and hard to action
  • The VM is skipped — no CPU, memory, or total cost metrics emitted for it

Root cause

getMachineName in pkg/azure/aks/machine_store.go returns only InstanceView.ComputerName. Azure sets this field only once the VM's OS is running. VMs in transitional states have a perfectly usable ARM resource name (vm.Name, e.g. aks-nodepool1-xxxxx-vmss_0) that is always present, but the code doesn't fall back to it.

computerName := to.String(vm.Properties.InstanceView.ComputerName)
if len(computerName) == 0 {
    m.logger.Error(fmt.Sprintf("unable to determine machine name: %+v", vm)) // full struct dump
    return "", fmt.Errorf("unable to determine machine name: %+v", vm)
}

Proposed fix

Fall back to vm.Name when ComputerName is unavailable. Log a warn with the name instead of erroring with the full struct. Only hard-error if both are absent.

Affected files

  • pkg/azure/aks/machine_store.go — getMachineName() (~line 402)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions