Skip to content

Commit

Permalink
Fix NPE in virtualmachine.Status.RestartCount (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
petuhovskiy authored Feb 21, 2024
1 parent b7243b0 commit 054eb6e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion neonvm/controllers/virtualmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,11 @@ func (r *VirtualMachineReconciler) doReconcile(ctx context.Context, virtualmachi
if shouldRestart {
log.Info("Restarting VM runner pod", "VM.Phase", virtualmachine.Status.Phase, "RestartPolicy", virtualmachine.Spec.RestartPolicy)
virtualmachine.Status.Phase = vmv1.VmPending // reset to trigger restart
*virtualmachine.Status.RestartCount += 1 // increment restart count
if virtualmachine.Status.RestartCount == nil {
var zero int32 = 0
virtualmachine.Status.RestartCount = &zero
}
*virtualmachine.Status.RestartCount += 1 // increment restart count
r.Metrics.vmRestartCounts.Inc()
}

Expand Down

0 comments on commit 054eb6e

Please sign in to comment.