Skip to content

ngclient: top-level targets is unnecessarily updated twice #1578

Closed

Description

@jku

ngclient updates top-level targets during refresh(). Then on get_one_valid_targetinfo() the top-level targets is updated again:

  • this is not dangerous and does not break any TrustedMetadataSet constraints
  • nothing is downloaded but the local metadata file is re-read and re-parsed

Mostly this is just annoying in the logs because it looks like a bug, with two updates usually one right after the other.

This could be fixed as a special case for top-level targets in the delegation loop but I think a similar issue comes up if other targets are already loaded, but then are needed in _preorder_depth_first_walk(). Maybe _load_targets() should check if a targets metadata is loaded and avoid re-loading in that case (if a targets is loaded it should be completely final and valid)?

Activity

  1. added
    backlog
    on Sep 15, 2021
  2. self-assigned this
    on Sep 15, 2021
  3. added this to the Sprint 8 milestone on Sep 15, 2021
  4. sechkova commented on Sep 24, 2021

    @sechkova
    Contributor

    Maybe _load_targets() should check if a targets metadata is loaded and avoid re-loading in that case (if a targets is loaded it should be completely final and valid)?

    The only scenario where we might be skipping a newer delegated role metadata file is the unlikely case where the file is updated between two get_one_valid_targetinfo calls but this should be a very short period of time:

    updater = Updater()
    updater.refresh()
    updater.get_one_valid_targetinfo("file1") # "some_role" is loaded and checked for file1
    ...
    updater.refresh() # newer snapshot is downloaded with newer version of "some_role"
    updater.get_one_valid_targetinfo("file2") # "some_role" is not reloaded and the older version is used to check for file2

    But is this the correct sequence? I don't think we should be calling refresh() before each get_one_valid_targetinfo?

  5. jku commented on Sep 27, 2021

    @jku
    MemberAuthor

    But is this the correct sequence? I don't think we should be calling refresh() before each get_one_valid_targetinfo?

    No we should not. It's also currently impossible: calling refresh() twice is an error as it tries to break TrustedMetadataSet rules (of course we could change how refresh works but in practice it would mean calling refresh() again is the same thing as creating a new Updater and then calling refresh() -- the only optimization would be that we don't have to load the local root from disk so not really worth it)

  6. sechkova commented on Sep 29, 2021

    @sechkova
    Contributor

    Sync with #1507

  7. modified the milestones: Sprint 8, Sprint 12 on Nov 10, 2021
  8. modified the milestones: Sprint 12, Sprint 13 on Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backlogbugngclient

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions