Skip to content

Commit

Permalink
Merge pull request containers#170 from cgwalters/noop-stage
Browse files Browse the repository at this point in the history
cli: Correctly no-op unchanged updates
  • Loading branch information
cgwalters authored Nov 2, 2023
2 parents d5990b3 + ddba806 commit 6849620
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,14 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
let staged_unchanged = staged_digest
.map(|d| d == fetched_digest)
.unwrap_or_default();
let booted_unchanged = booted_image
.as_ref()
.map(|img| img.manifest_digest.as_str() == fetched_digest)
.unwrap_or_default();
if staged_unchanged {
println!("Staged update present, not changed.");
} else if booted_unchanged {
println!("No update available.")
} else {
let osname = booted_deployment.osname();
crate::deploy::stage(sysroot, &osname, &fetched, &spec).await?;
Expand Down
5 changes: 5 additions & 0 deletions tests/kolainst/basic
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
echo "booted into $image"
echo "ok status test"

test "null" = $(jq '.status.staged' < status.json)
# Should be a no-op
bootc update
test "null" = $(jq '.status.staged' < status.json)

test '!' -w /usr
bootc usroverlay
test -w /usr
Expand Down

0 comments on commit 6849620

Please sign in to comment.