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

two minor rhsm followups #989

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/src/rhsm.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Integration with Red Hat Subscription Manager

use anyhow::Result;
use cap_std::fs::{Dir, OpenOptions};
use cap_std_ext::cap_std;
use anyhow::{Context, Result};
use cap_std::fs::Dir;
use cap_std_ext::{cap_std, dirext::CapStdExtDirExt};
use fn_error_context::context;
use serde::Serialize;

Expand Down Expand Up @@ -96,11 +96,11 @@ pub(crate) async fn publish_facts(root: &Dir) -> Result<()> {
let (_deployments, host) = crate::status::get_status(&sysroot, booted_deployment.as_ref())?;

let facts = RhsmFacts::from(host.status);
let mut bootc_facts_file = root.open_with(
FACTS_PATH,
OpenOptions::new().write(true).create(true).truncate(true),
)?;
serde_json::to_writer_pretty(&mut bootc_facts_file, &facts)?;
root.atomic_replace_with(FACTS_PATH, |w| {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 TIL!

serde_json::to_writer_pretty(w, &facts)?;
anyhow::Ok(())
})
.with_context(|| format!("Writing {FACTS_PATH}"))?;
Ok(())
}

Expand Down
8 changes: 8 additions & 0 deletions tests/booted/test-image-pushpull-upgrade.nu
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ RUN echo test content > /usr/share/blah.txt
# Just sanity check it
let v = podman run --rm localhost/bootc-derived cat /usr/share/blah.txt | str trim
assert equal $v "test content"

let orig_root_mtime = ls -Dl /ostree/bootc | get modified

# Now, fetch it back into the bootc storage!
bootc switch --transport containers-storage localhost/bootc-derived

# Also test that the mtime changes on modification
let new_root_mtime = ls -Dl /ostree/bootc | get modified
assert ($new_root_mtime > $orig_root_mtime)

# And reboot into it
tmt-reboot
}
Expand Down
Loading