Skip to content

Commit

Permalink
fix(virtbmc): support both running and runStrategy
Browse files Browse the repository at this point in the history
Signed-off-by: Zespre Schmidt <[email protected]>
  • Loading branch information
starbops committed Oct 22, 2024
1 parent 5459392 commit 25e2e78
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pkg/virtbmc/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ func (b *VirtBMC) stopVirtualMachine() error {
if err != nil {
return err
}
runStrategy := kubevirtv1.RunStrategyHalted
vm.Spec.RunStrategy = &runStrategy
if vm.Spec.RunStrategy == nil {
running := func(b bool) *bool { return &b }(false)
vm.Spec.Running = running
} else {
runStrategy := func(rs kubevirtv1.VirtualMachineRunStrategy) *kubevirtv1.VirtualMachineRunStrategy {
return &rs
}(kubevirtv1.RunStrategyHalted)
vm.Spec.RunStrategy = runStrategy
}
if _, err := b.kvClient.VirtualMachines(b.vmNamespace).Update(b.context, vm, v1.UpdateOptions{}); err != nil {
return err
}
Expand All @@ -79,8 +86,15 @@ func (b *VirtBMC) startVirtualMachine() error {
if err != nil {
return err
}
runStrategy := kubevirtv1.RunStrategyRerunOnFailure
vm.Spec.RunStrategy = &runStrategy
if vm.Spec.RunStrategy == nil {
running := func(b bool) *bool { return &b }(true)
vm.Spec.Running = running
} else {
runStrategy := func(rs kubevirtv1.VirtualMachineRunStrategy) *kubevirtv1.VirtualMachineRunStrategy {
return &rs
}(kubevirtv1.RunStrategyRerunOnFailure)
vm.Spec.RunStrategy = runStrategy
}
if _, err := b.kvClient.VirtualMachines(b.vmNamespace).Update(b.context, vm, v1.UpdateOptions{}); err != nil {
return err
}
Expand Down

0 comments on commit 25e2e78

Please sign in to comment.