Skip to content

Commit d2cf832

Browse files
authored
for composite control plane artifacts, define both artifact name and file name (#33)
In oxidecomputer/omicron#8514 we found that the artifact and file names don't actually match all the time. With this change, both the artifact and the file name will have to be specified. oxidecomputer/omicron#8510 is the issue that tracks cleaning this up.
1 parent 8be78d0 commit d2cf832

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

bin/invalid-manifests/duplicate-zone.toml renamed to bin/invalid-manifests/duplicate-zone-file-name.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ version = "1.0.0"
99
[artifact.control_plane.source]
1010
kind = "composite-control-plane"
1111
zones = [
12-
{ kind = "fake", name = "zone1", size = "1MiB" },
13-
{ kind = "fake", name = "zone1", size = "1MiB" },
12+
{ kind = "fake", artifact_name = "zone-1", file_name = "zone1.tar.gz", size = "1MiB" },
13+
{ kind = "fake", artifact_name = "zone-1", file_name = "zone1-dup.tar.gz", size = "1MiB" },
1414
]

bin/manifests/fake-non-semver.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ version = "2.0.0"
4141
[artifact.control_plane.source]
4242
kind = "composite-control-plane"
4343
zones = [
44-
{ kind = "fake", name = "zone1", size = "1MiB" },
45-
{ kind = "fake", name = "zone2", size = "1MiB" },
44+
{ kind = "fake", artifact_name = "zone-1", file_name = "zone1.tar.gz", size = "1MiB" },
45+
{ kind = "fake", artifact_name = "zone-2", file_name = "zone2.tar.gz", size = "1MiB" },
4646
]
4747

4848
[[artifact.psc_sp]]

bin/manifests/fake.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ version = "1.0.0"
3939
[artifact.control_plane.source]
4040
kind = "composite-control-plane"
4141
zones = [
42-
{ kind = "fake", name = "zone1", size = "1MiB" },
43-
{ kind = "fake", name = "zone2", size = "1MiB" },
42+
{ kind = "fake", artifact_name = "zone-1", file_name = "zone1.tar.gz", size = "1MiB" },
43+
{ kind = "fake", artifact_name = "zone-2", file_name = "zone2.tar.gz", size = "1MiB" },
4444
]
4545

4646
[[artifact.psc_sp]]

bin/tests/integration-tests/command_tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ fn test_assemble_duplicate_zone() -> Result<()> {
240240
cmd.args([
241241
"assemble",
242242
"--skip-all-present",
243-
"invalid-manifests/duplicate-zone.toml",
243+
// TODO: should we also check duplicate zone artifact names?
244+
"invalid-manifests/duplicate-zone-file-name.toml",
244245
]);
245246
cmd.arg(&archive_path);
246247
cmd.assert()
@@ -250,7 +251,7 @@ fn test_assemble_duplicate_zone() -> Result<()> {
250251
))
251252
.stderr(predicate::str::contains("zone/"))
252253
.stderr(predicate::str::contains(
253-
r#"(existing name: zone1.tar.gz, version: 1.0.0; new name: zone1.tar.gz, version: 1.0.0)"#,
254+
r#"(existing name: zone1.tar.gz, version: 1.0.0; new name: zone1-dup.tar.gz, version: 1.0.0)"#,
254255
));
255256

256257
logctx.cleanup_successful();

lib/src/assemble/manifest.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,10 @@ pub enum DeserializedControlPlaneZoneSource {
704704
#[serde(skip_serializing_if = "Option::is_none")]
705705
file_name: Option<String>,
706706
},
707+
#[serde(rename_all = "snake_case")]
707708
Fake {
708-
name: String,
709+
artifact_name: String,
710+
file_name: String,
709711
#[serde(deserialize_with = "deserialize_byte_size")]
710712
size: u64,
711713
},
@@ -738,7 +740,11 @@ impl DeserializedControlPlaneZoneSource {
738740
// change this to use the mtime on disk in the future?)
739741
(name.to_owned(), data, MtimeSource::Now)
740742
}
741-
DeserializedControlPlaneZoneSource::Fake { name, size } => {
743+
DeserializedControlPlaneZoneSource::Fake {
744+
artifact_name,
745+
file_name,
746+
size,
747+
} => {
742748
use flate2::{Compression, write::GzEncoder};
743749
use tufaceous_brand_metadata::{
744750
ArchiveType, LayerInfo, Metadata,
@@ -750,7 +756,7 @@ impl DeserializedControlPlaneZoneSource {
750756
));
751757

752758
let metadata = Metadata::new(ArchiveType::Layer(LayerInfo {
753-
pkg: name.clone(),
759+
pkg: artifact_name.clone(),
754760
version: version.clone(),
755761
}));
756762
metadata.append_to_tar(&mut tar, 0)?;
@@ -764,11 +770,12 @@ impl DeserializedControlPlaneZoneSource {
764770
h.set_cksum();
765771
tar.append(
766772
&h,
767-
make_filler_text(name, version, *size as usize).as_slice(),
773+
make_filler_text(artifact_name, version, *size as usize)
774+
.as_slice(),
768775
)?;
769776

770777
let data = tar.into_inner()?.finish()?;
771-
(format!("{name}.tar.gz"), data, MtimeSource::Zero)
778+
(file_name.clone(), data, MtimeSource::Zero)
772779
}
773780
};
774781
let entry = CompositeEntry { data: &data, mtime_source };

0 commit comments

Comments
 (0)