Skip to content

Commit 9e7ea64

Browse files
committed
vmid should be patched only after vm creation is successful
1 parent 3769c3e commit 9e7ea64

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cloud/services/compute/instance/qemu.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const (
1717
bootDvice = "scsi0"
1818
)
1919

20+
// reconciles QEMU instance
2021
func (s *Service) reconcileQEMU(ctx context.Context) (*proxmox.VirtualMachine, error) {
2122
log := log.FromContext(ctx)
2223
log.Info("Reconciling QEMU")
@@ -67,10 +68,6 @@ func (s *Service) createQEMU(ctx context.Context, nodeName string, vmid *int) (*
6768
return nil, err
6869
}
6970
vmid = &nextid
70-
s.scope.SetVMID(*vmid)
71-
if err := s.scope.PatchObject(); err != nil {
72-
return nil, err
73-
}
7471
}
7572

7673
vmoption := s.generateVMOptions()
@@ -79,6 +76,10 @@ func (s *Service) createQEMU(ctx context.Context, nodeName string, vmid *int) (*
7976
log.Error(err, fmt.Sprintf("failed to create qemu instance %s", vm.VM.Name))
8077
return nil, err
8178
}
79+
s.scope.SetVMID(*vmid)
80+
if err := s.scope.PatchObject(); err != nil {
81+
return nil, err
82+
}
8283
return vm, nil
8384
}
8485

cloud/services/compute/instance/reconcile.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func getBiosUUIDFromVM(ctx context.Context, vm *proxmox.VirtualMachine) (*string
133133
return pointer.String(uuid), nil
134134
}
135135

136+
// reconciles qemu, cloud-config, os image and storage
136137
func (s *Service) createInstance(ctx context.Context) (*proxmox.VirtualMachine, error) {
137138
log := log.FromContext(ctx)
138139

0 commit comments

Comments
 (0)