Avoid unnecessary delegated role downloads #811
Merged
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.
Using deprecated function
Updater.targets_of_role()
to fetch the targets listed by the top-level Targets role previously led to the unneeded download of all delegated targets roles. This PR fixes that specifically for calls totargets_of_role('targets')
(which is the only well-defined and secure use of the deprecated functiontargets_of_role
).All delegated targets continue to be downloaded if
targets_of_role
is called on a delegated targets role. This provides something like what we think users who might do this expect (It's not clear there are any people doing this.), refreshing all delegated targets roles to avoid use of outdated delegation information, and essentially hoping that the most-recently-validated delegation to the role of interest is what the user would expect that role to have been validated by.....targets_of_role
will be removed or replaced, so this is a fix for the sole reasonable use case until then.The PR also adds some explanatory comments and warnings to the code.