vaguerent/lib/vagrant/action/primary_runner.rb
Paul Hinze 2707d09181
Fix prepend/append action hooks firing multiple times
This addresses the surprising behavior that the StoreBoxMetadata hook
was running many times during a machine up, including during failed
operations where a destroy_on_error deleted the machine. This was
resulting in an error that looked like:

> No such file or directory @ rb_sysopen [...] /[...]/box_meta

Plugin action hooks using prepend/append were attaching every time a
Builder was run, including sub-Builders that show up for things like
Call actions.

To fix this, we tell Builders if they are "primary" and only run
prepend/append on those. See inline comments for more explanation.
2022-04-25 12:26:55 -05:00

16 lines
467 B
Ruby

module Vagrant
module Action
# A PrimaryRunner is a special kind of "top-level" Action::Runner - it
# informs any Action::Builders it interacts with that they are also
# primary. This allows Builders to distinguish whether or not they are
# nested, which they need to know for proper action_hook handling.
#
# @see Vagrant::Action::Builder#primary
class PrimaryRunner < Runner
def primary?
true
end
end
end
end