diff --git a/plugins/commands/serve/mappers/config_data.rb b/plugins/commands/serve/mappers/config_data.rb index 28613f1ee..b9dc3120f 100644 --- a/plugins/commands/serve/mappers/config_data.rb +++ b/plugins/commands/serve/mappers/config_data.rb @@ -127,6 +127,12 @@ module VagrantPlugins end end + # Include a unique identifier for this configuration instance. This + # will allow us to identifier it later when it is decoded. + if !data.key?("_vagrant_config_identifier") + data["_vagrant_config_identifier"] = SecureRandom.uuid + end + entries = data.map do |k, v| begin SDK::Args::HashEntry.new( diff --git a/plugins/commands/serve/service/provisioner_service.rb b/plugins/commands/serve/service/provisioner_service.rb index 37f7bb39e..885f77dc6 100644 --- a/plugins/commands/serve/service/provisioner_service.rb +++ b/plugins/commands/serve/service/provisioner_service.rb @@ -75,10 +75,13 @@ module VagrantPlugins end def load_provisioner(klass, machine, config) - key = cache.key(klass, machine) - return cache.get(key) if cache.registered?(key) + ident = config.instance_variable_get(:@_vagrant_config_identifier) + if ident + key = cache.key(klass, machine, ident) + return cache.get(key) if cache.registered?(key) + end klass.new(machine, config).tap do |i| - cache.register(key, i) + cache.register(key, i) if key end end end diff --git a/plugins/commands/serve/util/direct_conversions.rb b/plugins/commands/serve/util/direct_conversions.rb index 0bdf263bb..89a74c422 100644 --- a/plugins/commands/serve/util/direct_conversions.rb +++ b/plugins/commands/serve/util/direct_conversions.rb @@ -1,5 +1,6 @@ # Patch things to produce proto messages require "pathname" +require "securerandom" require "google/protobuf/wrappers_pb" require "google/protobuf/well_known_types" @@ -147,6 +148,12 @@ class Vagrant::Plugin::V2::Config end end + # Include a unique identifier for this configuration instance. This + # will allow us to identifier it later when it is decoded. + if !data.key?("_vagrant_config_identifier") + data["_vagrant_config_identifier"] = SecureRandom.uuid + end + entries = data.map do |k, v| Hashicorp::Vagrant::Sdk::Args::HashEntry.new( key: k.to_any,