Skip to content

Commit

Permalink
daemon: Query container image commit
Browse files Browse the repository at this point in the history
If a container image reference is pruned, we must not error
out when computing the status.  The deployment roots will hold
a strong reference to the deployed commit, so query via the commit
digest to find metadata about the pulled container image.
  • Loading branch information
cgwalters committed Nov 13, 2022
1 parent 50c5784 commit e2aee76
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
8 changes: 4 additions & 4 deletions rpmostree-cxxrs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2056,8 +2056,8 @@ extern "C"
const ::rpmostreecxx::OstreeRepo &repo, const ::rpmostreecxx::GCancellable &cancellable,
::rust::Str imgref, ::rust::Box< ::rpmostreecxx::ContainerImageState> *return$) noexcept;

::rust::repr::PtrLen rpmostreecxx$cxxbridge1$query_container_image (
const ::rpmostreecxx::OstreeRepo &repo, ::rust::Str imgref,
::rust::repr::PtrLen rpmostreecxx$cxxbridge1$query_container_image_commit (
const ::rpmostreecxx::OstreeRepo &repo, ::rust::Str c,
::rust::Box< ::rpmostreecxx::ContainerImageState> *return$) noexcept;
::std::size_t rpmostreecxx$cxxbridge1$TempEtcGuard$operator$sizeof () noexcept;
::std::size_t rpmostreecxx$cxxbridge1$TempEtcGuard$operator$alignof () noexcept;
Expand Down Expand Up @@ -3606,11 +3606,11 @@ pull_container (const ::rpmostreecxx::OstreeRepo &repo,
}

::rust::Box< ::rpmostreecxx::ContainerImageState>
query_container_image (const ::rpmostreecxx::OstreeRepo &repo, ::rust::Str imgref)
query_container_image_commit (const ::rpmostreecxx::OstreeRepo &repo, ::rust::Str c)
{
::rust::MaybeUninit< ::rust::Box< ::rpmostreecxx::ContainerImageState> > return$;
::rust::repr::PtrLen error$
= rpmostreecxx$cxxbridge1$query_container_image (repo, imgref, &return$.value);
= rpmostreecxx$cxxbridge1$query_container_image_commit (repo, c, &return$.value);
if (error$.ptr)
{
throw ::rust::impl< ::rust::Error>::error (error$);
Expand Down
2 changes: 1 addition & 1 deletion rpmostree-cxxrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ pull_container (const ::rpmostreecxx::OstreeRepo &repo,
const ::rpmostreecxx::GCancellable &cancellable, ::rust::Str imgref);

::rust::Box< ::rpmostreecxx::ContainerImageState>
query_container_image (const ::rpmostreecxx::OstreeRepo &repo, ::rust::Str imgref);
query_container_image_commit (const ::rpmostreecxx::OstreeRepo &repo, ::rust::Str c);

::rust::Box< ::rpmostreecxx::TempEtcGuard> prepare_tempetc_guard (::std::int32_t rootfs);

Expand Down
4 changes: 2 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ pub mod ffi {
cancellable: &GCancellable,
imgref: &str,
) -> Result<Box<ContainerImageState>>;
fn query_container_image(
fn query_container_image_commit(
repo: &OstreeRepo,
imgref: &str,
c: &str,
) -> Result<Box<ContainerImageState>>;
}

Expand Down
8 changes: 3 additions & 5 deletions rust/src/sysroot_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,11 @@ pub(crate) fn pull_container(
}

/// C++ wrapper for querying image state; requires a pulled image
pub(crate) fn query_container_image(
pub(crate) fn query_container_image_commit(
repo: &crate::FFIOstreeRepo,
imgref: &str,
imgcommit: &str,
) -> CxxResult<Box<crate::ffi::ContainerImageState>> {
let repo = &repo.glib_reborrow();
let imgref = &OstreeImageReference::try_from(imgref)?;
let state = ostree_container::store::query_image(repo, imgref)?
.ok_or_else(|| anyhow::anyhow!("Failed to find image {}", imgref))?;
let state = ostree_container::store::query_image_commit(repo, imgcommit)?;
Ok(Box::new(state.into()))
}
2 changes: 1 addition & 1 deletion src/daemon/rpmostreed-deployment-utils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot, OstreeDeployment
case rpmostreecxx::RefspecType::Container:
{
g_variant_dict_insert (dict, "container-image-reference", "s", refspec);
CXX_TRY_VAR (state, rpmostreecxx::query_container_image (*repo, refspec), error);
CXX_TRY_VAR (state, rpmostreecxx::query_container_image_commit (*repo, base_checksum), error);
g_variant_dict_insert (dict, "container-image-reference-digest", "s",
state->image_digest.c_str ());
if (state->version.size () > 0)
Expand Down

0 comments on commit e2aee76

Please sign in to comment.