From 942bc1bf8af734b18e05b4ada7e31e6f46adb426 Mon Sep 17 00:00:00 2001 From: Marvin Drees Date: Fri, 17 Jan 2025 20:25:27 +0100 Subject: [PATCH] fix: create subgraph when multiple roots present If there is more then one root present in the config we need to create a subgraph that only includes the Descendants of the desired root and omits the rest. If we try to step through the initial dag instead it will create a locking situation that will break execution. Signed-off-by: Marvin Drees --- cmd/firmware-action/recipes/recipes.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/firmware-action/recipes/recipes.go b/cmd/firmware-action/recipes/recipes.go index c61599cc..6a90d22e 100644 --- a/cmd/firmware-action/recipes/recipes.go +++ b/cmd/firmware-action/recipes/recipes.go @@ -106,7 +106,15 @@ func Build( queueMutex.Unlock() return nil, nil } - _, err = dependencyForest.DescendantsFlow(target, nil, flowCallback) + + // Create a subgraph with target as the only root + // Having multiple roots will result in miscalculation inside DescendantsFlow channel size calculation + pruned, rootID, err := dependencyForest.GetDescendantsGraph(target) + if err != nil { + return nil, err + } + + _, err = pruned.DescendantsFlow(rootID, nil, flowCallback) if err != nil { return nil, err }