ggiamarchi / vagrant-openstack-provider

Use Vagrant to manage OpenStack Cloud instances.
MIT License
245 stars 102 forks source link

Non-standard machines state causes problems for triggers #387

Open bstillwell opened 5 years ago

bstillwell commented 5 years ago

When using the run_remote on a destroy trigger like the following, it fails to work since the state isn't running:

 node.trigger.before :destroy do |trigger|
    trigger.name = "Removing salt key"
    trigger.run_remote = { inline: "salt-call saltutil.revoke_auth" }
  end

The error message is:

Could not run remote script on cephosd002 because its state is active

It appears like the code is only checking for the state to be running:

      elsif @machine.state.id != :running
        if on_error == :halt
          raise Errors::TriggersGuestNotRunning,
            machine_name: @machine.name,
            state: @machine.state.id
        else
          @machine.ui.error(I18n.t("vagrant.errors.triggers_guest_not_running",
                                    machine_name: @machine.name,
                                    state: @machine.state.id))
          @machine.ui.warn(I18n.t("vagrant.trigger.on_error_continue"))
          return
        end
      end

I created an issue upsteam for this (https://github.com/hashicorp/vagrant/issues/10956), but they're thinking that the openstack provider should use the standard states instead (at least that's how I took it).