Skip to content

Commit 8d443e7

Browse files
authored
Merge pull request #135 from vyaghras/2_4_1_updates
Cherrypick changes for 2.4.1
2 parents 8d610d4 + 5dece3d commit 8d443e7

File tree

5 files changed

+38
-41
lines changed

5 files changed

+38
-41
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# v2.4.1 (2024-09-09)
2+
3+
## OS Changes
4+
* Use direct paths for ephemeral storage ([#133])
5+
* Update libexpat to 2.6.3 ([#130])
6+
7+
[#130]: https://github.com/bottlerocket-os/bottlerocket-core-kit/pull/130
8+
[#133]: https://github.com/bottlerocket-os/bottlerocket-core-kit/pull/133
9+
110
# v2.4.0 (2024-09-05)
211

312
## OS Changes

Twoliter.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
schema-version = 1
2-
release-version = "2.4.0"
2+
release-version = "2.4.1"
33

44
[vendor.bottlerocket]
55
registry = "public.ecr.aws/bottlerocket"

packages/libexpat/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ path = "../packages.rs"
1212
releases-url = "https://github.com/libexpat/libexpat/releases/"
1313

1414
[[package.metadata.build-package.external-files]]
15-
url = "https://github.com/libexpat/libexpat/releases/download/R_2_6_2/expat-2.6.2.tar.xz"
16-
sha512 = "47b60967d6346d330dded87ea1a2957aa7d34dd825043386a89aa131054714f618ede57bfe97cf6caa40582a4bc67e198d2a915e7d8dbe8ee4f581857c2e3c2e"
15+
url = "https://github.com/libexpat/libexpat/releases/download/R_2_6_3/expat-2.6.3.tar.xz"
16+
sha512 = "e02c4ad88f9d539258aa1c1db71ded7770a8f12c77b5535e5b34f040ae5b1361ef23132f16d96bdb7c096a83acd637a7c907916bdfcc6d5cfb9e35d04020ca0b"
1717

1818
[build-dependencies]
1919
glibc = { path = "../glibc" }

packages/libexpat/libexpat.spec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%global unversion 2_6_2
1+
%global unversion 2_6_3
22

33
Name: %{_cross_os}libexpat
44
Version: %(echo %{unversion} | sed 's/_/./g')
@@ -43,7 +43,6 @@ Requires: %{name}
4343
%{_cross_libdir}/*.so
4444
%{_cross_includedir}/*.h
4545
%{_cross_pkgconfigdir}/*.pc
46-
%exclude %{_cross_libdir}/*.la
4746
%exclude %{_cross_libdir}/cmake
4847

4948
%changelog

sources/api/apiserver/src/server/ephemeral_storage.rs

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ static FINDMNT: &str = "/usr/bin/findmnt";
1818

1919
/// Name of the array (if created) and filesystem label. Selected to be 12 characters so it
2020
/// fits within both the xfs and ext4 volume label limit.
21-
static EPHEMERAL: &str = ".ephemeral";
21+
static EPHEMERAL_MNT: &str = ".ephemeral";
22+
/// Name of the device and its path from the MD driver
23+
static RAID_DEVICE_DIR: &str = "/dev/md/";
24+
static RAID_DEVICE_NAME: &str = "ephemeral";
2225

2326
/// initialize prepares the ephemeral storage for formatting and formats it. For multiple disks
2427
/// preparation is the creation of a RAID0 array, for a single disk this is a no-op. The array or disk
@@ -70,11 +73,14 @@ pub fn initialize(fs: Option<Filesystem>, disks: Option<Vec<String>>) -> Result<
7073
let scan_output = mdadm_scan()?;
7174
// no previously configured array found, so construct a new one
7275
if scan_output.is_empty() {
73-
info!("creating array named {:?} from {:?}", EPHEMERAL, disks);
74-
mdadm_create(EPHEMERAL, disks.iter().map(|x| x.as_str()).collect())?;
76+
info!(
77+
"creating array named {:?} from {:?}",
78+
RAID_DEVICE_NAME, disks
79+
);
80+
mdadm_create(RAID_DEVICE_NAME, disks.iter().map(|x| x.as_str()).collect())?;
7581
}
76-
// can't lookup the array until it's created
77-
resolve_array_by_id()?
82+
// Once it is built, it will be available in `/dev/md/`
83+
format!("{}{}", RAID_DEVICE_DIR, RAID_DEVICE_NAME)
7884
}
7985
};
8086

@@ -95,14 +101,18 @@ pub fn initialize(fs: Option<Filesystem>, disks: Option<Vec<String>>) -> Result<
95101
/// binds the specified directories to the pre-configured array, creating those directories if
96102
/// they do not exist.
97103
pub fn bind(variant: &str, dirs: Vec<String>) -> Result<()> {
98-
// handle the no local instance storage case
99-
if ephemeral_devices()?.is_empty() {
100-
info!("no ephemeral disks found, skipping ephemeral storage binding");
101-
return Ok(());
102-
}
104+
let device_name = match ephemeral_devices()?.len() {
105+
// handle the no local instance storage case
106+
0 => {
107+
info!("no ephemeral disks found, skipping ephemeral storage binding");
108+
return Ok(());
109+
}
110+
// If there is only one device, use that
111+
1 => ephemeral_devices()?.first().expect("non-empty").clone(),
112+
_ => format!("{}{}", RAID_DEVICE_DIR, RAID_DEVICE_NAME),
113+
};
103114

104-
let device_name = resolve_device_by_label()?;
105-
let mount_point = format!("/mnt/{}", EPHEMERAL);
115+
let mount_point = format!("/mnt/{}", EPHEMERAL_MNT);
106116
let mount_point = Path::new(&mount_point);
107117
let allowed_dirs = allowed_bind_dirs(variant);
108118
for dir in &dirs {
@@ -202,34 +212,16 @@ fn is_mounted(path: &String) -> Result<bool> {
202212
Ok(status.success())
203213
}
204214

205-
/// resolve_device_by_label resolves the by-label link for the raid array or single disk to the device name
206-
fn resolve_device_by_label() -> Result<String> {
207-
canonical_name(format!("/dev/disk/by-label/{}", EPHEMERAL))
208-
}
209-
210-
/// resolve_array_by_name resolves the by-id link for the raid array
211-
fn resolve_array_by_id() -> Result<String> {
212-
canonical_name(format!("/dev/disk/by-id/md-name-{}", EPHEMERAL))
213-
}
214-
215-
/// canonical_name will create the canonical, absolute form of a path with all intermediate
216-
/// components normalized and symbolic links resolved
217-
fn canonical_name(name: String) -> Result<String> {
218-
Ok(std::fs::canonicalize(OsString::from(name))
219-
.context(error::CanonicalizeFailureSnafu {})?
220-
.to_string_lossy()
221-
.to_string())
222-
}
223-
224215
/// creates the array with the given name from the specified disks
225216
fn mdadm_create<T: AsRef<str>>(name: T, disks: Vec<T>) -> Result<()> {
226-
let mut device_name = OsString::from("/dev/md/");
217+
let mut device_name = OsString::from(RAID_DEVICE_DIR);
227218
device_name.push(name.as_ref());
228219

229220
let mut cmd = Command::new(MDADM);
230221
cmd.arg("--create");
231222
cmd.arg("--force");
232223
cmd.arg("--verbose");
224+
cmd.arg("--homehost=any");
233225
cmd.arg(device_name);
234226
cmd.arg("--level=0");
235227
// By default, mdadm uses a 512KB chunk size. mkfs.xfs attempts to match some of its settings to
@@ -332,7 +324,7 @@ pub fn format_device<S: AsRef<OsStr>>(device: S, format: &Filesystem) -> Result<
332324
mkfs.arg(device.as_ref());
333325
// labeled, XFS has a max of 12 characters, EXT4 allows 16
334326
mkfs.arg("-L");
335-
mkfs.arg(EPHEMERAL);
327+
mkfs.arg(RAID_DEVICE_NAME);
336328

337329
let output = mkfs
338330
.output()
@@ -405,9 +397,6 @@ pub mod error {
405397

406398
#[snafu(display("Failed to create directory, {}", source))]
407399
Mkdir { source: std::io::Error },
408-
409-
#[snafu(display("Failed to canonicalize path, {}", source))]
410-
CanonicalizeFailure { source: std::io::Error },
411400
}
412401
}
413402

0 commit comments

Comments
 (0)