Skip to content

Commit 13bef32

Browse files
composefs/state: Require container details when writing state
Make `container_details` argument mandatory while writing composefs deployment state. It's better to fetch the container details from the source imgref, rather than the target imgref, as the target might not even exist at the time of deployment. Fixes CI failures as we were fetching from local registry (according to the target imgref), which doesn't exist Signed-off-by: Pragyan Poudyal <[email protected]>
1 parent 34e563e commit 13bef32

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ use rustix::{mount::MountFlags, path::Arg};
9696
use schemars::JsonSchema;
9797
use serde::{Deserialize, Serialize};
9898

99-
use crate::bootc_kargs::compute_new_kargs;
100-
use crate::composefs_consts::{TYPE1_ENT_PATH, TYPE1_ENT_PATH_STAGED};
10199
use crate::parsers::bls_config::{BLSConfig, BLSConfigType};
102100
use crate::parsers::grub_menuconfig::MenuEntry;
103101
use crate::task::Task;
102+
use crate::{
103+
bootc_composefs::repo::get_imgref,
104+
composefs_consts::{TYPE1_ENT_PATH, TYPE1_ENT_PATH_STAGED},
105+
};
104106
use crate::{
105107
bootc_composefs::repo::open_composefs_repo,
106108
store::{ComposefsFilesystem, Storage},
@@ -109,6 +111,9 @@ use crate::{
109111
bootc_composefs::state::{get_booted_bls, write_composefs_state},
110112
bootloader::esp_in,
111113
};
114+
use crate::{
115+
bootc_composefs::status::get_container_manifest_and_config, bootc_kargs::compute_new_kargs,
116+
};
112117
use crate::{bootc_composefs::status::get_sorted_grub_uki_boot_entries, install::PostFetchState};
113118
use crate::{
114119
composefs_consts::{
@@ -1217,7 +1222,11 @@ pub(crate) async fn setup_composefs_boot(
12171222
false,
12181223
boot_type,
12191224
boot_digest,
1220-
None,
1225+
&get_container_manifest_and_config(&get_imgref(
1226+
&state.source.imageref.transport.to_string(),
1227+
&state.source.imageref.name,
1228+
))
1229+
.await?,
12211230
)
12221231
.await?;
12231232

crates/lib/src/bootc_composefs/state.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ use rustix::{
2424

2525
use crate::bootc_composefs::boot::BootType;
2626
use crate::bootc_composefs::repo::get_imgref;
27-
use crate::bootc_composefs::status::{
28-
get_container_manifest_and_config, get_sorted_type1_boot_entries, ImgConfigManifest,
29-
};
27+
use crate::bootc_composefs::status::{get_sorted_type1_boot_entries, ImgConfigManifest};
3028
use crate::parsers::bls_config::BLSConfigType;
3129
use crate::store::{BootedComposefs, Storage};
3230
use crate::{
@@ -168,7 +166,7 @@ pub(crate) fn update_target_imgref_in_origin(
168166
/// * `staged` - Whether this is a staged deployment (writes to transient state dir)
169167
/// * `boot_type` - Boot loader type (`Bls` or `Uki`)
170168
/// * `boot_digest` - Optional boot digest for verification
171-
/// * `container_details` - Optional container manifest and config. Fetched if not provided
169+
/// * `container_details` - Container manifest and config used to create this deployment
172170
///
173171
/// # State Directory Structure
174172
///
@@ -183,11 +181,11 @@ pub(crate) fn update_target_imgref_in_origin(
183181
pub(crate) async fn write_composefs_state(
184182
root_path: &Utf8PathBuf,
185183
deployment_id: Sha512HashValue,
186-
imgref: &ImageReference,
184+
target_imgref: &ImageReference,
187185
staged: bool,
188186
boot_type: BootType,
189187
boot_digest: Option<String>,
190-
container_details: Option<&ImgConfigManifest>,
188+
container_details: &ImgConfigManifest,
191189
) -> Result<()> {
192190
let state_path = root_path
193191
.join(STATE_DIR_RELATIVE)
@@ -211,14 +209,11 @@ pub(crate) async fn write_composefs_state(
211209
image: image_name,
212210
transport,
213211
..
214-
} = &imgref;
212+
} = &target_imgref;
215213

216-
let imgref = get_imgref(&transport, &image_name);
214+
println!("imgref: {target_imgref:#?}");
217215

218-
let img_config = match container_details {
219-
Some(val) => val,
220-
None => &get_container_manifest_and_config(&imgref).await?,
221-
};
216+
let imgref = get_imgref(&transport, &image_name);
222217

223218
let mut config = tini::Ini::new().section("origin").item(
224219
ORIGIN_CONTAINER,
@@ -244,7 +239,7 @@ pub(crate) async fn write_composefs_state(
244239
state_dir
245240
.atomic_write(
246241
format!("{}.imginfo", deployment_id.to_hex()),
247-
serde_json::to_vec(&img_config)?,
242+
serde_json::to_vec(&container_details)?,
248243
)
249244
.context("Failed to write to .imginfo file")?;
250245

crates/lib/src/bootc_composefs/update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub(crate) async fn do_upgrade(
259259
true,
260260
boot_type,
261261
boot_digest,
262-
Some(img_manifest_config),
262+
img_manifest_config,
263263
)
264264
.await?;
265265

0 commit comments

Comments
 (0)