Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmid should be patched only after vm creation is successful #97

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cloud/services/compute/instance/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
bootDvice = "scsi0"
)

// reconciles QEMU instance
func (s *Service) reconcileQEMU(ctx context.Context) (*proxmox.VirtualMachine, error) {
log := log.FromContext(ctx)
log.Info("Reconciling QEMU")
Expand Down Expand Up @@ -67,10 +68,6 @@ func (s *Service) createQEMU(ctx context.Context, nodeName string, vmid *int) (*
return nil, err
}
vmid = &nextid
s.scope.SetVMID(*vmid)
if err := s.scope.PatchObject(); err != nil {
return nil, err
}
}

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

Expand Down
1 change: 1 addition & 0 deletions cloud/services/compute/instance/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func getBiosUUIDFromVM(ctx context.Context, vm *proxmox.VirtualMachine) (*string
return pointer.String(uuid), nil
}

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

Expand Down