Giter Site home page Giter Site logo

Comments (2)

ddelnano avatar ddelnano commented on July 17, 2024

I applied this change and created a build. It doesn't appear gracefully runs the shutdown command. Instead it seems to swallow the error that is currently produced.

Here is the output when run with this code change

==> xenserver-iso: Connected to SSH!
2021/03/29 23:07:43 packer-plugin-xenserver plugin: 2021/03/29 23:07:43 Running the provision hook
==> xenserver-iso: Step: Shutting down VM
    xenserver-iso: Executing shutdown command...
2021/03/29 23:07:43 packer-plugin-xenserver plugin: 2021/03/29 23:07:43 [DEBUG] Opening new ssh session
2021/03/29 23:07:43 packer-plugin-xenserver plugin: 2021/03/29 23:07:43 [DEBUG] starting remote command: /sbin/shutdown
==> xenserver-iso: Failed to set wall message, ignoring: Interactive authentication required.
2021/03/29 23:07:46 packer-plugin-xenserver plugin: 2021/03/29 23:07:46 [ERROR] Remote command exited with '1': /sbin/shutdown
==> xenserver-iso: Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: Interactive authentication required.
    xenserver-iso: Waiting for VM to enter Halted state...
==> xenserver-iso: Error waiting for VM to halt: Timed out
==> xenserver-iso: WARNING: Forcing hard shutdown of the VM...
    xenserver-iso: Successfully shut down VM
    xenserver-iso: Successfully set VM as a template

Here is the output when run from the latest release (v0.3.2)

==> xenserver-iso: Connected to SSH!
==> xenserver-iso: Step: Shutting down VM
    xenserver-iso: Executing shutdown command...
==> xenserver-iso: Shutdown command failed: Process exited with status 1
==> xenserver-iso: WARNING: Forcing hard shutdown of the VM...
    xenserver-iso: Successfully shut down VM
    xenserver-iso: Successfully set VM as a template

So the RemoteCmd.RunWithUi seems to not return an error even though the command itself did fail. It seems the underlying issue is actually the following lines from the output above

==> xenserver-iso: Failed to set wall message, ignoring: Interactive authentication required.
2021/03/29 23:07:46 packer-plugin-xenserver plugin: 2021/03/29 23:07:46 [ERROR] Remote command exited with '1': /sbin/shutdown
==> xenserver-iso: Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: Interactive authentication required.

from packer-plugin-xenserver.

ddelnano avatar ddelnano commented on July 17, 2024

It seems that the better solution would be to use the XAPI's graceful vm shutdown rather than expecting user's of this plugin to supply their own shutdown command. In fact the plugin already has the code for this 😄 (here).

This is used when the shutdown command is omitted from the packer config. I removed it from the centos example and re-ran the build and see that it is working as expected.

==> xenserver-iso: Connected to SSH!
2021/03/29 23:41:27 packer-plugin-xenserver plugin: 2021/03/29 23:41:27 Running the provision hook
==> xenserver-iso: Step: Shutting down VM
    xenserver-iso: Attempting to cleanly shutdown the VM...
    xenserver-iso: Successfully shut down VM
    xenserver-iso: Successfully set VM as a template
2021/03/29 23:41:37 packer-plugin-xenserver plugin: 2021/03/29 23:41:37 Skipping detach of 'iso_vdi_uuid'
2021/03/29 23:41:37 packer-plugin-xenserver plugin: 2021/03/29 23:41:37 Could not find VDI record in VBD 'OpaqueRef:ad300ce7-00c5-453c-91f5-4fb453dc43b9'
2021/03/29 23:41:37 packer-plugin-xenserver plugin: 2021/03/29 23:41:37 Detached VDI '696250ff-7d32-4993-a141-5823d6af859a'
2021/03/29 23:41:37 packer-plugin-xenserver plugin: 2021/03/29 23:41:37 Detached VDI 'feea5dbe-55d8-429f-a978-92cf4e3725e1'
2021/03/29 23:41:37 packer-plugin-xenserver plugin: 2021/03/29 23:41:37 Skipping detach of 'floppy_vdi_uuid'
==> xenserver-iso: Step: export artifact
==> xenserver-iso: Getting XVA https://xen.internal.ddelnano.com/export?uuid=e84eea49-60c4-9ec4-8570-7aa13474950d&session_id=OpaqueRef:b8e115c2-e8c4-4c78-8570-0bb73ce7c547
==> xenserver-iso: Download completed: packer-centos-8.3-x86_64-xenserver
2021/03/29 23:43:39 [INFO] (telemetry) ending xenserver-iso
Build 'xenserver-iso' finished after 23 minutes 2 seconds.

In order to resolve this issue, I think the documentation should be updated to reflect that without a shutdown command it is still a graceful shutdown, however, if your VM requires special shutdown handling then you can customize it if you need to.

from packer-plugin-xenserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.