-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix export_sources for non-existent recipes in a local index #16776
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9473e21
Fix export_sources for non-existent recipes in a local index.
cynix da67372
Fix formatting
cynix 3f079ea
refactored test
memsharded 07da098
Merge branch 'develop2' into fix_export_sources
memsharded 9c8faec
use try-except
memsharded File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not necessary in
get_recipe()
above?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cynix
I am trying to understand the root cause and the necessary changes to fix it.
So far, I have only been able to make it fail for the
get_recipe_sources()
case, when Conan iterates the remotes looking for the sources of a given (already existing) recipe. The aboveget_recipe()
seems to be sufficiently protected by previous checks, but the sources one wasn't. As you can see, the test keeps working (we do quite test-focused development, if there is something else that could be failing in theget_recipe()
it would be necessary another test that makes it fail).According to the above, I have removed the extra calls (to avoid extra cost, those will do extra queries to the DB) and just converted the exception to make it work.
Have you been able to test the changes against your full code? Does it work? If not, maybe you can try to provide a new test that makes it fail again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I tested this in my full setup and it does address the issue just fine, as far as I can tell.
But if you have some time, I'd appreciate if you could help me understand why
get_recipe
was already "protected" butget_recipe_sources
was not, and whether this is a symptom of a bigger issue. It seems the calling code should have an idea of which remote a recipe comes from (after all, only one remote can possibly have what we consider to be the "latest" revision, right?). Once we've determined which remote a recipe comes from, should we then only ask that remote for sources? Does it make sense to still ask all remotes? When I was originally looking into this issue, an alternative I considered was to change the caller to pass in a single remote (e.g.node.remote
) instead of the full list of enabled remotes, but I wasn't sure if that's intended or not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. In the
DepsGraphBuilder
andConanProxy
class, the logic is more or less:ref = self._remote_manager.get_latest_recipe_reference(reference, remote)
to query about the existingreference
in the remote.reference
, then do aremote_manager.get_recipe()
to get itWhile the
remote_manager.get_recipe_sources()
is called in a different place (only when something needs to build); protected with:And this
_try_get_sources
is iterated for every remote, without checking first if theref
exists in the remote. This is the operation that was not raising aNotFoundException
and breaking that case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To further clarify, the first resolution of the
ref
in the graph resolution is often giving areference
without recipe-revision, and returning the full reference with recipe revision inref = self._remote_manager.get_latest_recipe_reference(reference, remote)
. Theget_recipe_sources()
already works with a fully defined reference with recipe-revision, so no need to query for the latest one, just ask the server "give me the sources of this specific recipe revision, because I need them", and it can directly manage theNotFoundException
, as it is more efficient than doing 2 calls, one to check the existence, then another to retrieve the sources.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let me know if this clarifies a bit, and we can proceed to merge it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so once you have a full reference, you're happy to get the sources from any remote that contains that exact ref, because in theory they're all fungible? That makes sense, but since resolving the full ref means you now know which remote it came from, isn't it still more efficient to just go directly to that remote for the sources rather than iterating through the full list again? Is there ever a case where a remote may provide the full ref but is unable to provide the sources?
But based on the assumption that the sources are all fungible, it seems your latest change would indeed work as intended, and looks nicer than what I did before, so I'm of course happy for it to be merged :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, the recipe-revision guarantees that you are getting the same sources irrespective of the remote, so the first one containing it will be good.
Yes, but Conan doesn't keep that memory/state. It did in Conan 1, but we removed it as messy (issues when remotes are removed, disabled, etc). So this is a simple enough, and retrieving the sources is almost always for building, which is very expensive, so a couple of extra api calls is neglegible.
No, that would be a corrupted package recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the contribution and the feedback!