Skip to content
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

lib/repo-finder-mount: Change the schema for finding repos on volumes #1179

Closed

Conversation

pwithnall
Copy link
Member

See issue #1174 for the rationale behind this. In summary:
• It required two lists of collection–refs to be maintained: one in the
repository, and one pointing to the repository.
• It didn’t automatically work for live USBs of OSs based on OSTree
(where there’s always a repository at /ostree/repo).
• It was unnecessarily complex.

The new scheme allows a list of repositories to be searched, but without
needing a layer of indirection through their collection–refs. It adds
/ostree/repo and /.ostree/repo as well-known repository locations which
are always checked on a mounted volume (if they exist).

Update the unit tests accordingly.

Signed-off-by: Philip Withnall withnall@endlessm.com


Plus a few other trivial fixes.

#1174

* ostree_repo_open() not being called on them yet), %FALSE will be returned.
*
* Returns: %TRUE if @a and @b are the same repository on disk, %FALSE otherwise
* Since: 2017.11
Copy link
Member

Choose a reason for hiding this comment

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

.12

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, fixup pushed.

GHashTable *repo_refs = repo_and_refs->refs;
g_autofree char *repo_path = g_file_get_path (ostree_repo_get_path (repo));

const gchar *checksum = g_hash_table_lookup (repo_refs, refs[i]);
Copy link
Member

Choose a reason for hiding this comment

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

Now that we have a nested loop, probably best to extract refs[i] to a local variable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sensible. Fixup pushed.

* $mount_root/.ostree/repos.d/$something.
* Add it to the results, keyed by the canonicalised repository URI
* to deduplicate the results. */
g_autofree char *canonical_repo_path = realpath (repo_path, NULL);
Copy link
Member

Choose a reason for hiding this comment

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

Not new in this patch but I don't quite get why we need to canonicalize; feels like a leftover from the previous symlinks schema?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are still symlinks in this schema (although fewer of them); canonicalisation allows us to eliminate the duplicate arising from (for example):

  • $usb_stick/ostree/repo being a repository
  • $usb_stick/.ostree/repos.d/alias$usb_stick/ostree/repo being a symlink
    or the duplicate arising from two symlinks in $usb_stick/.ostree/repos.d pointing to the same repository elsewhere on the stick.

Is there any downside to canonicalising? I guess it’s not dirfd-relative, which is a a bit of a pain, but I don’t think realpathat() exists. I can write a libglnx version of realpathat() if you’re concerned about that.

Copy link
Member

Choose a reason for hiding this comment

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

We could canonicalize by making a hashset - maybe add ostree_repo_hash too since you just added _equals()? Anyways, doesn't have to be done in this patch.

Copy link
Member Author

Choose a reason for hiding this comment

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

I’ve opened issue #1191 as a follow-up.

@rh-atomic-bot
Copy link

☔ The latest upstream changes (presumably d0b0578) made this pull request unmergeable. Please resolve the merge conflicts.

@cgwalters
Copy link
Member

Ah sorry, I hadn't realized #1172 would conflict - can you rebase?

This will compare their root directory inodes to see if they are the
same repository on disk. A convenience method for the users of the
public API who can’t access OstreeRepo.inode.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
See issue ostreedev#1174 for the rationale behind this. In summary:
 • It required two lists of collection–refs to be maintained: one in the
   repository, and one pointing to the repository.
 • It didn’t automatically work for live USBs of OSs based on OSTree
   (where there’s always a repository at /ostree/repo).
 • It was unnecessarily complex.

The new scheme allows a list of repositories to be searched, but without
needing a layer of indirection through their collection–refs. It adds
/ostree/repo and /.ostree/repo as well-known repository locations which
are always checked on a mounted volume (if they exist).

Update the unit tests accordingly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

ostreedev#1174
This was some incomplete planning from while the find_remotes() API was
being designed; now totally outdated.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
@pwithnall
Copy link
Member Author

Ah sorry, I hadn't realized #1172 would conflict - can you rebase?

Rebased.

@cgwalters
Copy link
Member

@rh-atomic-bot r+ 4842bec

@rh-atomic-bot
Copy link

⌛ Testing commit 4842bec with merge 9e0100c...

rh-atomic-bot pushed a commit that referenced this pull request Sep 19, 2017
This will compare their root directory inodes to see if they are the
same repository on disk. A convenience method for the users of the
public API who can’t access OstreeRepo.inode.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1179
Approved by: cgwalters
rh-atomic-bot pushed a commit that referenced this pull request Sep 19, 2017
See issue #1174 for the rationale behind this. In summary:
 • It required two lists of collection–refs to be maintained: one in the
   repository, and one pointing to the repository.
 • It didn’t automatically work for live USBs of OSs based on OSTree
   (where there’s always a repository at /ostree/repo).
 • It was unnecessarily complex.

The new scheme allows a list of repositories to be searched, but without
needing a layer of indirection through their collection–refs. It adds
/ostree/repo and /.ostree/repo as well-known repository locations which
are always checked on a mounted volume (if they exist).

Update the unit tests accordingly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

#1174

Closes: #1179
Approved by: cgwalters
rh-atomic-bot pushed a commit that referenced this pull request Sep 19, 2017
This was some incomplete planning from while the find_remotes() API was
being designed; now totally outdated.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1179
Approved by: cgwalters
@cgwalters
Copy link
Member

(PR context failure is due to mirror desync with the base image, glibc gets downgraded since we found an older glibc-devel)

@rh-atomic-bot
Copy link

💔 Test failed - status-atomicjenkins

@cgwalters
Copy link
Member

@rh-atomic-bot retry

@rh-atomic-bot
Copy link

⌛ Testing commit 4842bec with merge c62b360...

rh-atomic-bot pushed a commit that referenced this pull request Sep 19, 2017
See issue #1174 for the rationale behind this. In summary:
 • It required two lists of collection–refs to be maintained: one in the
   repository, and one pointing to the repository.
 • It didn’t automatically work for live USBs of OSs based on OSTree
   (where there’s always a repository at /ostree/repo).
 • It was unnecessarily complex.

The new scheme allows a list of repositories to be searched, but without
needing a layer of indirection through their collection–refs. It adds
/ostree/repo and /.ostree/repo as well-known repository locations which
are always checked on a mounted volume (if they exist).

Update the unit tests accordingly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

#1174

Closes: #1179
Approved by: cgwalters
rh-atomic-bot pushed a commit that referenced this pull request Sep 19, 2017
This was some incomplete planning from while the find_remotes() API was
being designed; now totally outdated.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1179
Approved by: cgwalters
@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: cgwalters
Pushing c62b360 to master...

@pwithnall
Copy link
Member Author

pwithnall commented Sep 22, 2017

@cgwalters and I talked about this today and decided that it probably also makes sense to hard-code searches for /var/lib/flatpak and /var/lib/containers/atomic in OstreeRepoFinderMount. I’ll do that on Monday; I’ve filed #1210 for it.

The use case for this is for finding remotes from a live USB which contains an OS which uses separate repos for the OS and system flatpaks; or which contains a non-OSTree OS and a system flatpak repo.

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.

None yet

3 participants