Add vmi's pending phase transition timestamp in mutation webhook during create, otherwise it never get's set
@@ -25,6 +25,7 @@ import (
"net/http"
"reflect"
"strings"
+ "time"
admissionv1 "k8s.io/api/admission/v1"
k8sv1 "k8s.io/api/core/v1"
@@ -120,6 +121,12 @@ func (mutator *VMIsMutator) Mutate(ar *admissionv1.AdmissionReview) *admissionv1
// Set the phase to pending to avoid blank status
newVMI.Status.Phase = v1.Pending
+ now := metav1.NewTime(time.Now())
+ newVMI.Status.PhaseTransitionTimestamps = append(newVMI.Status.PhaseTransitionTimestamps, v1.VirtualMachineInstancePhaseTransitionTimestamp{
+ Phase: newVMI.Status.Phase,
+ PhaseTransitionTimestamp: now,
+ })
+
if mutator.ClusterConfig.NonRootEnabled() {
if err := canBeNonRoot(newVMI); err != nil {
return &admissionv1.AdmissionResponse{
