-
Notifications
You must be signed in to change notification settings - Fork 129
store: Add accessors for the ostree repo #1509
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ pub(crate) struct Storage { | |
pub physical_root: Dir, | ||
|
||
/// The OSTree storage | ||
pub sysroot: SysrootLock, | ||
ostree: SysrootLock, | ||
/// The composefs storage | ||
pub composefs: OnceCell<Arc<ComposefsRepository>>, | ||
/// The containers-image storage used foR LBIs | ||
|
@@ -81,7 +81,7 @@ impl Deref for Storage { | |
type Target = SysrootLock; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.sysroot | ||
&self.ostree | ||
} | ||
} | ||
|
||
|
@@ -116,22 +116,33 @@ impl Storage { | |
|
||
Ok(Self { | ||
physical_root, | ||
sysroot, | ||
ostree: sysroot, | ||
run, | ||
composefs: Default::default(), | ||
store, | ||
imgstore: Default::default(), | ||
}) | ||
} | ||
|
||
/// Access the underlying ostree repository | ||
pub(crate) fn get_ostree(&self) -> Result<&SysrootLock> { | ||
Ok(&self.ostree) | ||
} | ||
|
||
/// Access the underlying ostree repository | ||
pub(crate) fn get_ostree_cloned(&self) -> Result<ostree::Sysroot> { | ||
let r = self.get_ostree()?; | ||
Ok((*r).clone()) | ||
} | ||
Comment on lines
+127
to
+136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These accessor functions can be simplified. Since neither Additionally, This change would make the API cleaner and more idiomatic, and simplify call sites by removing unnecessary /// Access the underlying ostree repository
pub(crate) fn get_ostree(&self) -> &SysrootLock {
&self.ostree
}
/// Access the underlying ostree repository
pub(crate) fn get_ostree_cloned(&self) -> ostree::Sysroot {
self.get_ostree().clone()
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes the use of Result is intentional here because I want to change it to be a fallible operation in the future. |
||
|
||
/// Access the image storage; will automatically initialize it if necessary. | ||
pub(crate) fn get_ensure_imgstore(&self) -> Result<&crate::imgstorage::Storage> { | ||
if let Some(imgstore) = self.imgstore.get() { | ||
return Ok(imgstore); | ||
} | ||
let sysroot_dir = crate::utils::sysroot_dir(&self.sysroot)?; | ||
let sysroot_dir = crate::utils::sysroot_dir(&self.ostree)?; | ||
|
||
let sepolicy = if self.sysroot.booted_deployment().is_none() { | ||
let sepolicy = if self.ostree.booted_deployment().is_none() { | ||
// fallback to policy from container root | ||
// this should only happen during cleanup of a broken install | ||
tracing::trace!("falling back to container root's selinux policy"); | ||
|
@@ -141,8 +152,8 @@ impl Storage { | |
// load the sepolicy from the booted ostree deployment so the imgstorage can be | ||
// properly labeled with /var/lib/container/storage labels | ||
tracing::trace!("loading sepolicy from booted ostree deployment"); | ||
let dep = self.sysroot.booted_deployment().unwrap(); | ||
let dep_fs = deployment_fd(&self.sysroot, &dep)?; | ||
let dep = self.ostree.booted_deployment().unwrap(); | ||
let dep_fs = deployment_fd(&self.ostree, &dep)?; | ||
lsm::new_sepolicy_at(&dep_fs)? | ||
}; | ||
|
||
|
@@ -167,7 +178,7 @@ impl Storage { | |
|
||
// Bootstrap verity off of the ostree state. In practice this means disabled by | ||
// default right now. | ||
let ostree_repo = &self.sysroot.repo(); | ||
let ostree_repo = &self.ostree.repo(); | ||
let ostree_verity = ostree_ext::fsverity::is_verity_enabled(ostree_repo)?; | ||
if !ostree_verity.enabled { | ||
tracing::debug!("Setting insecure mode for composefs repo"); | ||
|
@@ -182,7 +193,7 @@ impl Storage { | |
#[context("Updating storage root mtime")] | ||
pub(crate) fn update_mtime(&self) -> Result<()> { | ||
let sysroot_dir = | ||
crate::utils::sysroot_dir(&self.sysroot).context("Reopen sysroot directory")?; | ||
crate::utils::sysroot_dir(&self.ostree).context("Reopen sysroot directory")?; | ||
|
||
sysroot_dir | ||
.update_timestamps(std::path::Path::new(BOOTC_ROOT)) | ||
|
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.
Right, the change in scope here was indeed intentional because your helper functions here are now doing the cloning, rather than having them cloned in
deploy.rs
, I see.