Only send vmi defined event when domain is being created the first time
@@ -1612,7 +1612,7 @@ func (d *VirtualMachineController) migrationTargetExecute(vmi *v1.VirtualMachine
log.Log.Object(vmi).Info("Processing vmi migration target update")
// prepare the POD for the migration
- err := d.processVmUpdate(vmi)
+ err := d.processVmUpdate(vmi, domainExists)
if err != nil {
return err
}
@@ -1813,7 +1813,7 @@ func (d *VirtualMachineController) defaultExecute(key string,
syncErr = d.processVmCleanup(vmi)
case shouldUpdate:
log.Log.Object(vmi).V(3).Info("Processing vmi update")
- syncErr = d.processVmUpdate(vmi)
+ syncErr = d.processVmUpdate(vmi, domainExists)
default:
log.Log.Object(vmi).V(3).Info("No update processing required")
}
@@ -2599,7 +2599,7 @@ func (d *VirtualMachineController) vmUpdateHelperMigrationTarget(origVMI *v1.Vir
}
return nil
}
-func (d *VirtualMachineController) vmUpdateHelperDefault(origVMI *v1.VirtualMachineInstance) error {
+func (d *VirtualMachineController) vmUpdateHelperDefault(origVMI *v1.VirtualMachineInstance, domainExists bool) error {
client, err := d.getLauncherClient(origVMI)
if err != nil {
return fmt.Errorf("unable to create virt-launcher client connection: %v", err)
@@ -2705,7 +2705,11 @@ func (d *VirtualMachineController) vmUpdateHelperDefault(origVMI *v1.VirtualMach
}
return err
}
- d.recorder.Event(vmi, k8sv1.EventTypeNormal, v1.Created.String(), "VirtualMachineInstance defined.")
+
+ if !domainExists {
+ d.recorder.Event(vmi, k8sv1.EventTypeNormal, v1.Created.String(), VMIDefined)
+ }
+
if vmi.IsRunning() {
// Umount any disks no longer mounted
if err := d.hotplugVolumeMounter.Unmount(vmi); err != nil {
@@ -2715,7 +2719,7 @@ func (d *VirtualMachineController) vmUpdateHelperDefault(origVMI *v1.VirtualMach
return nil
}
-func (d *VirtualMachineController) processVmUpdate(vmi *v1.VirtualMachineInstance) error {
+func (d *VirtualMachineController) processVmUpdate(vmi *v1.VirtualMachineInstance, domainExists bool) error {
isUnresponsive, isInitialized, err := d.isLauncherClientUnresponsive(vmi)
if err != nil {
@@ -2735,7 +2739,7 @@ func (d *VirtualMachineController) processVmUpdate(vmi *v1.VirtualMachineInstanc
} else if d.isMigrationSource(vmi) {
return d.vmUpdateHelperMigrationSource(vmi)
} else {
- return d.vmUpdateHelperDefault(vmi)
+ return d.vmUpdateHelperDefault(vmi, domainExists)
}
}
