Skip to content

Commit

Permalink
Graceful handle inconsistent fs version between layers
Browse files Browse the repository at this point in the history
Signed-off-by: zyfjeff <zyfjeff@linux.alibaba.com>
  • Loading branch information
zyfjeff committed Jun 13, 2022
1 parent 9707185 commit 61dadb6
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/bin/nydus-image/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,22 @@ impl Merger {
chunk_dict_blobs.insert(blob.blob_id().to_string());
}
}
let mut fs_versions = HashSet::new();
let mut fs_version = None;
for (layer_idx, bootstrap_path) in sources.iter().enumerate() {
let rs = RafsSuper::load_from_metadata(bootstrap_path, RafsMode::Direct, true)
.context(format!("load bootstrap {:?}", bootstrap_path))?;
fs_versions.insert(rs.meta.version);

match fs_version {
Some(version) => {
if version != rs.meta.version {
bail!(
"inconsistent fs version between layers, expected version {}",
version
);
}
}
None => fs_version = Some(rs.meta.version),
}
let current_flags = Flags::from_meta(&rs.meta);
if let Some(flags) = &flags {
if flags != &current_flags {
Expand Down Expand Up @@ -171,10 +182,8 @@ impl Merger {
}
}

assert!(fs_versions.len() == 1);
for v in fs_versions.drain() {
ctx.fs_version = v.into();
}
// Safe to unwrap because a valid version must exist
ctx.fs_version = fs_version.unwrap().into();
// Safe to unwrap because there is at least one source bootstrap.
let mut tree = tree.unwrap();
let mut bootstrap = Bootstrap::new()?;
Expand Down

0 comments on commit 61dadb6

Please sign in to comment.