-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Describe the bug
Description
When using multiple remotes in Conan 2 with --update enabled, the resolution mechanism for recipe revisions (rrevs) appears to deviate from the behavior in Conan 1. Specifically, it does not respect the order of remotes as defined in remotes.json. Instead, recipe revisions are sorted by their timestamps across all remotes, which can lead to unexpected behavior and Conan1-incompatible package resolution.
Steps to Reproduce
- Configure two remotes:
- Remote 1: Contains recipe revisions with older timestamps.
- Remote 2: Contains the same recipe revisions re-uploaded, resulting in newer timestamps.
- Require a package with the same revision distributed across these two remotes but with different timestamps.
- Enable the
--updateflag while resolving the package.
Expected Behavior
Conan should prioritize recipe revisions from the first remote in remotes.json, regardless of timestamp differences. For example:
- If
pkg@1.0.0#bcdexists in both remotes with different timestamps, it should be resolved from Remote 1 if it appears first inremotes.json.
Actual Behavior
With --update enabled, Conan 2 queries recipe revisions from all remotes and sorts them by timestamp. This results in the recipe from Remote 2 being chosen, even when it has the same content as the revision in Remote 1 but a newer timestamp.
Code Reference
The issue seems related to the _find_newest_recipe_in_remotes function in proxy.py.
Example
Given the following remote distribution:
- Remote 1:
- pkg@1.0.0#abc @ 2025/01/01
- pkg@1.0.0#bcd @ 2025/01/02
- Remote 2:
- pkg@1.0.0#abc @ 2025/01/05
With the current behavior:
pkg@1.0.0#abcfrom Remote 2 is resolved as the latest revision due to the newer timestamp.
Expected behavior:pkg@1.0.0#bcdfrom Remote 1 should be resolved as the latest revision since it is the most recent recipe that appears first in remotes.json.
Use case
We have a cache remote which is used to upload binary packages for recipes that were built by CI. It is different from the remote where the recipes are stored, and this is intentional (because the release repository does not enable delete permissions for immutability, but cache remote needs delete permissions for periodic cleanup tasks). When uploading a binary package the recipe entry is automatically created in the cache remote and gets the timestamp of creation instead of the original recipe timestamp. Both remotes are used when building consumers, with the recipe remote having higher priority.
Proposed solution
This is a tough one. I don't really have an idea how to solve this properly. Maybe the Conan 1 way of resolving across remotes could be restored, but that would probably break existing Conan 2 solutions. Or maybe it would be possible to store the original timestamp of downloaded recipes in the local cache so that it can be preserved when uploading the recipe again to another remote (this seems to be the only viable solution in my opinion).
Environment
Conan Version: 2.x