From 305fddb49a2291483ebcf518a7f0b4aaf83607fb Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Thu, 7 Apr 2022 09:17:27 -0700 Subject: [PATCH] Retry cached path executions with full graph --- .../serve/mappers/internal/graph/mappers.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugins/commands/serve/mappers/internal/graph/mappers.rb b/plugins/commands/serve/mappers/internal/graph/mappers.rb index 0b052d03c..01fd2de27 100644 --- a/plugins/commands/serve/mappers/internal/graph/mappers.rb +++ b/plugins/commands/serve/mappers/internal/graph/mappers.rb @@ -58,6 +58,16 @@ module VagrantPlugins end end + # Remove an existing path registration + # + # @param src [Class] source type + # @param dst [Class] destination type + # @return [NilClass] + def unregister(src, dst) + @previous.delete(generate_key(src, dst)) + nil + end + # Fetch a path for a given source and destination # if it has been registered # @@ -170,6 +180,22 @@ module VagrantPlugins # The resultant value will be stored within the # destination vertex @dst.value + rescue => err + # If a failure was encountered and the graph was fresh + # allow the error to continue bubbling up + raise if fresh + + # If the graph is not fresh, unregister the cached path + # and retry the mapping with the full graph + logger.trace("search execution using cached path failed, retrying with full graph (#{err})") + self.class.unregister(source, final) + self.class.new( + output_type: final, + input_values: inputs, + mappers: mappers, + named: named, + source: source + ).execute end def to_s