Skip to content

Conversation

@stevebillings
Copy link
Contributor

A solution for IDETECT-2925. The problem seems to have been caused by deriving the layer value for each dependency by picking the first layer listed the show-recipes command output (even when multiple layers are listed). Based on this customer's log, it looks more reliable to use the dependency layer from task-depends.dot dependency details.

The slight challenge to getting the layer from task-depends.dot dependency information is that the layer name is part of the path to the recipe. With this change, we first determine the list of layers, then for each dependency, for each layer: do a path.contains("/layername/").

A side effect of this change: the detector now only executes the show-recipes command once (early), rather than once per target image. Among other things, show-recipes provides the list of layers in the target image.

This PR does not address the audit feedback... that is next.

…ely needed (avoiding a conversion to it later)
# Conflicts:
#	detectable/src/main/java/com/synopsys/integration/detectable/detectables/bitbake/BitbakeExtractor.java
#	detectable/src/main/java/com/synopsys/integration/detectable/detectables/bitbake/parse/BitbakeGraphTransformer.java
#	detectable/src/main/java/com/synopsys/integration/detectable/factory/DetectableFactory.java
# Conflicts:
#	detectable/src/main/java/com/synopsys/integration/detectable/detectables/bitbake/BitbakeExtractor.java
}
return dependencyLayer;
}
}
Copy link
Contributor Author

@stevebillings stevebillings Jan 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm half tempted to remove this fallback-to-first-in-list. I'm hoping it's never used. If we did remove it, we could execute bitbake-layers show-layers instead of bitbake-layers show-recipes, and do a whole lot less parsing. I'm hoping that after reading a few customer logs it'll become more clear that we don't need the fallback.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm perfectly fine with defaulting to the easier approach and waiting for real customer examples to come through via support. For example, assuming something doesn't happen, but throw exception if we detect it and wait for a diagnostic zip with real world example.

Copy link
Contributor Author

@stevebillings stevebillings Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JakeMathews I'd love your opinion on this. The bitbake code does not assume it'll find the recipe version in the task-depends.dot label (GraphParseTransformer.getVersionFromNode() has returned an Optional even before I started mucking with things). Given the vast experience you have now, do you believe that caution makes sense? And should it apply to finding the layer there as well? (I realize this is largely guesswork, but I trust your guesses more than mine.)

Looking more closely: the detector does not assume that the label attribute is present, but if the label attribute is present, it assumes it will contain the version. My current plan is to do the same for layer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if the label is present its pretty safe to assume the layer is in the path. I always prefer to air on the side of caution especially when understanding is murky at best.
It would be great if we could phone home suspected discrepancies rather than failing or silently use a default.

i think what you have now will likely be the safest approach, but we won’t know if its right until we can collect more data.

try {
showRecipesResults = bitbakeSession.executeBitbakeForRecipeLayerCatalog();
} catch (IOException | ExecutableFailedException e) {
String msg = String.format("Error collecting recipe layer information from show-recipes command: %s", e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just bubble these up - if this message helpful for debugging though, looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

codeLocations.add(generateCodeLocationForTargetImage(followSymLinks, searchDepth, dependencyTypeFilter, bitbakeSession, buildDir, bitbakeEnvironment, showRecipesResults, targetImage));
} catch (IOException | IntegrationException | NotImplementedException | ExecutableFailedException e) {
logger.error(String.format("Failed to extract a Code Location while running Bitbake against package '%s': %s", packageName, e.getMessage()));
logger.error(String.format("Failed to extract a Code Location while running Bitbake against package '%s': %s", targetImage, e.getMessage()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing, you could just bubble these up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we want to just log and continue on to the next target image / codelocation

}
return dependencyLayer;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm perfectly fine with defaulting to the easier approach and waiting for real customer examples to come through via support. For example, assuming something doesn't happen, but throw exception if we detect it and wait for a diagnostic zip with real world example.


@NotNull
private String[] getLabelParts(final String label) {
return label.split("\\\\n:|\\\\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems inappropriate in a transformer. What you could do is split out this, make a LabelParser.parseLayerLabel that returns LayerDetails(path) with Optional getPath() . This would let you get away from handling the String[] in other methods and let you unit test label parsing. I'd suggets both getLayerFromLabel and getLabelParts become LabelParser.parseLayer -> LayerDetails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

BitbakeGraph bitbakeGraph = buildGraph(nodes, edges);
addNode("name", "name\\n:version\\n/some/meta/path/to.bb", nodes, edges);
Set<String> knownLayers = new HashSet<>(Arrays.asList("aaa", "meta", "bbb"));
BitbakeGraph bitbakeGraph = buildGraph(nodes, edges, knownLayers);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a bit odd BitBakeGraph needs to be tested? It looks like a model object. Perhaps the logic this is testing is better suited in a transformer or a parser. (Not necessarily related to your PR I know, but I wanted to mention it).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the main objective of this test is to test is to test the transformer, but BitbakeGraph is a mix of code and data, and I think you might be pointing out that that should be separated. I'm adding a note to the bitbake audit ticket to address that.

// Parse beginning of new component
if (currentRecipe != null) {
bitbakeRecipes.add(currentRecipe);
bitbakeRecipes.put(currentRecipe.getName(), currentRecipe.getLayerNames());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we not want to add the currentRecipe to the bitbakeRecipes map in the other else-if statements in this method?

Copy link
Contributor Author

@stevebillings stevebillings Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know... all I did in that method was change that list to a map (so I could delete BitbakeRecipesToLayerMapConverter). It's been that way for a while and I was unaware of a reason to question it.

@stevebillings stevebillings merged commit 7c6653e into master Jan 28, 2022
@dmamidibd dmamidibd deleted the sb_bitbakeMultiLayerRecipes branch June 7, 2023 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants