refactor: name vm to vmi
@@ -238,7 +238,7 @@ func waitForDomainUUID(timeout time.Duration, events chan watch.Event, stop chan
func waitForFinalNotify(deleteNotificationSent chan watch.Event,
domainManager virtwrap.DomainManager,
- vm *v1.VirtualMachineInstance) {
+ vmi *v1.VirtualMachineInstance) {
log.Log.Info("Waiting on final notifications to be sent to virt-handler.")
@@ -271,7 +271,7 @@ func waitForFinalNotify(deleteNotificationSent chan watch.Event,
// KillVMI is idempotent. Making a call to KillVMI here ensures that the deletion
// occurs regardless if the VirtualMachineInstance crashed unexpectedly or if virt-handler requested
// a graceful shutdown.
- domainManager.KillVMI(vm)
+ domainManager.KillVMI(vmi)
// We don't want to block here forever. If the delete does not occur, that could mean
// something is wrong with libvirt. In this situation, virt-handler will detect that
@@ -356,7 +356,7 @@ func main() {
panic(err)
}
- vm := v1.NewVMIReferenceFromNameWithNS(*namespace, *name)
+ vmi := v1.NewVMIReferenceWithUUID(*namespace, *name, types.UID(*uid))
// Initialize local and shared directories
initializeDirs(*virtShareDir, *ephemeralDiskDir, *containerDiskDir, *hotplugDiskDir, *uid)
@@ -370,7 +370,7 @@ func main() {
}
util.StartLibvirt(stopChan)
// only single domain should be present
- domainName := api.VMINamespaceKeyFunc(vm)
+ domainName := api.VMINamespaceKeyFunc(vmi)
util.StartVirtlog(stopChan, domainName)
domainConn := createLibvirtConnection()
@@ -395,7 +395,7 @@ func main() {
gracefulShutdownCallback := func() {
err := wait.PollImmediate(time.Second, 15*time.Second, func() (bool, error) {
- err := domainManager.MarkGracefulShutdownVMI(vm)
+ err := domainManager.MarkGracefulShutdownVMI(vmi)
if err != nil {
log.Log.Reason(err).Errorf("Unable to signal graceful shutdown")
return false, err
@@ -408,11 +408,11 @@ func main() {
log.Log.Reason(err).Errorf("Gave up attempting to signal graceful shutdown")
}
- log.Log.Object(vm).Info("Successfully signaled graceful shutdown")
+ log.Log.Object(vmi).Info("Successfully signaled graceful shutdown")
}
finalShutdownCallback := func(pid int) {
- err := domainManager.KillVMI(vm)
+ err := domainManager.KillVMI(vmi)
if err != nil {
log.Log.Reason(err).Errorf("Unable to stop qemu with libvirt, falling back to SIGTERM")
syscall.Kill(pid, syscall.SIGTERM)
@@ -421,7 +421,7 @@ func main() {
events := make(chan watch.Event, 2)
// Send domain notifications to virt-handler
- startDomainEventMonitoring(notifier, *virtShareDir, domainConn, events, vm.UID, domainName, &agentStore, *qemuAgentSysInterval, *qemuAgentFileInterval, *qemuAgentUserInterval, *qemuAgentVersionInterval)
+ startDomainEventMonitoring(notifier, *virtShareDir, domainConn, events, vmi.UID, domainName, &agentStore, *qemuAgentSysInterval, *qemuAgentFileInterval, *qemuAgentUserInterval, *qemuAgentVersionInterval)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt,
@@ -457,7 +457,7 @@ func main() {
// Now that the pid has exited, we wait for the final delete notification to be
// sent back to virt-handler. This delete notification contains the reason the
// domain exited.
- waitForFinalNotify(events, domainManager, vm)
+ waitForFinalNotify(events, domainManager, vmi)
}
close(stopChan)
