Open hickeng opened 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.
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]
@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?
@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.
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.
@dougm, I can reproduce this issue. Please let me know if you want to have additional logging enabled.
@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.
@hickeng I reproduced the issue again today and attached the required logs. container-logs.zip
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
+}
Note that I changed the original summary + description of the issue to reflect the current findings.
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
govc vm.power -r
Note that Group8-vSphere-Integration/8-01-GuestTools.robot has the guest shutdown operation test.