ifvmiExists&&d.isPreMigrationTarget(vmi){// 1. PRE-MIGRATION TARGET PREPARATION PATH//// If this node is the target of the vmi's migration, take// a different execute path. The target execute path prepares// the local environment for the migration, but does not// start the VMIreturnd.migrationTargetExecute(vmi,vmiExists,domainExists)}elseifvmiExists&&d.isOrphanedMigrationSource(vmi){// 3. POST-MIGRATION SOURCE CLEANUP//// After a migration, the migrated domain still exists in the old// source's domain cache. Ensure that any node that isn't currently// the target or owner of the VMI handles deleting the domain locally.returnd.migrationOrphanedSourceNodeExecute(vmi,domainExists)}returnd.defaultExecute(key,vmi,vmiExists,domain,domainExists)
// Determine if an active (or about to be active) VirtualMachineInstance should be updated.ifvmiExists&&!vmi.IsFinal(){// requiring the phase of the domain and VirtualMachineInstance to be in sync is an// optimization that prevents unnecessary re-processing VMIs during the start flow.phase,err:=d.calculateVmPhaseForStatusReason(domain,vmi)iferr!=nil{returnerr}ifvmi.Status.Phase==phase{shouldUpdate=true}}switch{caseforceIgnoreSync:log.Log.Object(vmi).V(3).Info("No update processing required: forced ignore")caseshouldShutdown:log.Log.Object(vmi).V(3).Info("Processing shutdown.")syncErr=d.processVmShutdown(vmi,domain)caseshouldDelete:log.Log.Object(vmi).V(3).Info("Processing deletion.")syncErr=d.processVmDelete(vmi)caseshouldCleanUp:log.Log.Object(vmi).V(3).Info("Processing local ephemeral data cleanup for shutdown domain.")syncErr=d.processVmCleanup(vmi)caseshouldUpdate:log.Log.Object(vmi).V(3).Info("Processing vmi update")syncErr=d.processVmUpdate(vmi)default:log.Log.Object(vmi).V(3).Info("No update processing required")}