vmware / vic

vSphere Integrated Containers Engine is a container runtime for vSphere.
http://vmware.github.io/vic
Other
639 stars 173 forks source link

Tether: add support for guest reboot operation #5423

Open hickeng opened 7 years ago

hickeng commented 7 years ago

Story As a viadmin I expect the Guest Shutdown and Guest Reboot UI controls to take effect

Detail The tether implements a toolbox power Halt handler, but does not implement a power Reboot handler.

Acceptance

Note that Group8-vSphere-Integration/8-01-GuestTools.robot has the guest shutdown operation test.

lgayatri commented 7 years ago

Thanks @hickeng for reporting this on my behalf. I have all the required logs but not able to attach to github due to size limitation. I can provide access to log bundles.

dougm commented 7 years ago

Toolbox has support for guest shutdown and reboot hooks, see https://github.com/vmware/vic/blob/master/pkg/vsphere/toolbox/power.go#L47-L48

We test GuestShutdown here: https://github.com/vmware/vic/blob/master/tests/test-cases/Group8-vSphere-Integration/8-01-GuestTools.robot#L53

However, the container STOPSIGNAL is not applied, tether currently uses toolbox's default handlers of /sbin/shutdown -[rh]

hickeng commented 7 years ago

@lgayatri vmware/photon image does not have /sbin/shutdown so we fail - I don't know whether we should be returning a different VIX response to indicate failure of polite shutdown?

lgayatri commented 7 years ago

@hickeng , we should include /sbin/shutdown in the vmware/photon image. Else despite having hooks, we wont be able to invoke shutdown. Else, we should not show the tools status as Running due to which VCSA thinks that it can perform guest shutdown.

dougm commented 7 years ago

Sorry for the confusion, but container VMs do not use the default /sbin/shutdown for guest shutdown.

The tether overrides the default toolbox handler with its own, which does actually use the container stop signal: https://github.com/vmware/vic/blob/master/lib/tether/toolbox.go#L194

We'll need to reproduce to see what's going on here.

lgayatri commented 7 years ago

@dougm, I can reproduce this issue. Please let me know if you want to have additional logging enabled.

hickeng commented 7 years ago

@lgayatri please capture a container log bundle from the vic-admin of VCH. @dougm could be related to #5479 or #5501 which were also causing toolbox unresponsiveness on the stop path.

lgayatri commented 7 years ago

@hickeng I reproduced the issue again today and attached the required logs. container-logs.zip

dougm commented 7 years ago

In my testing, guest shutdown works fine. However, guest reboot does not. And, after attempting guest reboot, VC/ESX will not allow a guest shutdown.

The issue is that tether needs to set a Reboot handler. Example below, not certain that's how we want to handle guest reboot.

modified   lib/tether/toolbox.go
@@ -107,6 +107,7 @@ func (t *Toolbox) Reload(config *ExecutorConfig) error {
 // InContainer configures the toolbox to run within a container VM
 func (t *Toolbox) InContainer() *Toolbox {
    t.PowerCommand.Halt.Handler = t.halt
+   t.PowerCommand.Reboot.Handler = t.reboot

    vix := t.Service.VixCommand
    vix.Authenticate = t.containerAuthenticate
@@ -223,3 +224,16 @@ func (t *Toolbox) halt() error {

    return session.Cmd.Process.Kill()
 }
+
+func (t *Toolbox) reboot() error {
+   _ = t.halt()
+
+   syscall.Sync()
+
+   err := syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART2)
+   if err != nil {
+       log.Printf("Reboot: %s", err)
+   }
+
+   return nil
+}
dougm commented 7 years ago

Note that I changed the original summary + description of the issue to reflect the current findings.