Skip to content

Commit

Permalink
Merge pull request coreos#4936 from travier/main-container-update-ver…
Browse files Browse the repository at this point in the history
…sion

deployment_utils: Fix version for cached container update
  • Loading branch information
cgwalters authored Apr 24, 2024
2 parents eb3c690 + 5fbb651 commit e0cf3f7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions rpmostree-cxxrs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,8 @@ struct ExportedManifestDiff final
::std::uint64_t n_added;
// The size of total number of added packages in the next upgrade
::std::uint64_t added_size;
// The version of the next upgrade
::rust::String version;

using IsRelocatable = ::std::true_type;
};
Expand Down
2 changes: 2 additions & 0 deletions rpmostree-cxxrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,8 @@ struct ExportedManifestDiff final
::std::uint64_t n_added;
// The size of total number of added packages in the next upgrade
::std::uint64_t added_size;
// The version of the next upgrade
::rust::String version;

using IsRelocatable = ::std::true_type;
};
Expand Down
2 changes: 2 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ pub mod ffi {
pub n_added: u64,
/// The size of total number of added packages in the next upgrade
pub added_size: u64,
/// The version of the next upgrade
pub version: String,
}

#[derive(Debug, PartialEq, Eq)]
Expand Down
8 changes: 6 additions & 2 deletions rust/src/sysroot_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ impl From<Box<ostree_container::store::LayeredImageState>> for crate::ffi::Conta
.cached_update
.map(|c| {
let diff = ManifestDiff::new(&s.manifest, &c.manifest);
export_diff(&diff)
let version = ostree_container::version_for_config(&c.config)
.map(ToOwned::to_owned)
.unwrap_or_default();
export_diff(&diff, version)
})
.unwrap_or_default();
crate::ffi::ContainerImageState {
Expand Down Expand Up @@ -226,7 +229,7 @@ pub(crate) fn check_container_update(

/// Unfortunately we can't export external types into our C++ bridge, so manually copy things
/// to another copy of the struct.
fn export_diff(diff: &ManifestDiff) -> ExportedManifestDiff {
fn export_diff(diff: &ManifestDiff, version: String) -> ExportedManifestDiff {
ExportedManifestDiff {
initialized: true,
total: diff.total,
Expand All @@ -235,6 +238,7 @@ fn export_diff(diff: &ManifestDiff) -> ExportedManifestDiff {
removed_size: diff.removed_size,
n_added: diff.n_added,
added_size: diff.added_size,
version,
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/daemon/rpmostreed-deployment-utils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,9 @@ rpmostreed_update_generate_variant (OstreeDeployment *booted_deployment,
auto state = rpmostreecxx::query_container_image_commit (*repo, current_checksum);
container_changed
= rpmostreecxx::deployment_add_manifest_diff (*dict, state->cached_update_diff);
g_variant_dict_insert (dict, "version", "s", state->version.c_str ());
if (state->cached_update_diff.version.size () > 0)
g_variant_dict_insert (dict, "version", "s",
state->cached_update_diff.version.c_str ());
g_debug ("container changed: %d", container_changed);
}
catch (std::exception &e)
Expand Down
7 changes: 4 additions & 3 deletions tests/kolainst/destructive/container-update-check
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
cd ${td}
cat > Containerfile << EOF
FROM localhost/fcos
# RUN rpm-ostree install man
LABEL org.opencontainers.image.version 1
EOF

touched_resolv_conf=0
Expand Down Expand Up @@ -91,6 +91,7 @@ EOF
cat > Containerfile << EOF
FROM localhost/fcos
RUN rpm-ostree install man
LABEL org.opencontainers.image.version 2
EOF

touched_resolv_conf=0
Expand Down Expand Up @@ -119,7 +120,7 @@ EOF
assert_file_has_content_literal out.txt '"total-size":'
assert_file_has_content_literal out.txt '"total":'
assert_file_has_content_literal out.txt '"added-size":'
assert_file_has_content_literal out.txt '"version":'
assert_file_has_content_literal out.txt '"origin":'
assert_file_has_content_literal out.txt '"version": "2"'
assert_file_has_content_literal out.txt '"origin": "ostree-unverified-image:containers-storage:localhost/fcos-derived"'

esac

0 comments on commit e0cf3f7

Please sign in to comment.