Skip to content

Commit 5060045

Browse files
authored
Fix omdb support-bundles download --output (#9400)
I noticed we were unable to save a support bundle when passing an output location. ``` root@oxz_switch1:~# omdb nexus support-bundles list note: Nexus URL not specified. Will pick one from DNS. note: using DNS server for subnet fd00:1122:3344::/48 note: (if this is not right, use --dns-server to specify an alternate DNS server) note: using Nexus URL http://[fd00:1122:3344:102::5]:12232 ID TIME_CREATED REASON_FOR_CREATION REASON_FOR_FAILURE STATE USER_COMMENT e3adf9b8-f16a-4d89-b8c9-d1de6e888b89 2025-11-12 16:38:21.171665 UTC Created by internal API - Active - root@oxz_switch1:~# omdb nexus support-bundles download -o /root/support-bundle.zip e3adf9b8-f16a-4d89-b8c9-d1de6e888b89 note: Nexus URL not specified. Will pick one from DNS. note: using DNS server for subnet fd00:1122:3344::/48 note: (if this is not right, use --dns-server to specify an alternate DNS server) note: using Nexus URL http://[fd00:1122:3344:102::5]:12232 Error: Invalid argument (os error 22) ``` I spent some time with DTrace and truss but I couldn't find any calls to `open(2)` where an actual `EINVAL` was being returned. After some further inspection it turns out[ Rust is making up this `EINVAL`]( https://github.com/rust-lang/rust/blob/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/sys/fs/unix.rs#L1129-L1142) on it's own rather then passing the open flags to the `open(2)` call. ```rust fn get_creation_mode(&self) -> io::Result<c_int> { match (self.write, self.append) { (true, false) => {} (false, false) => { if self.truncate || self.create || self.create_new { return Err(Error::from_raw_os_error(libc::EINVAL)); } } (_, true) => { if self.truncate && !self.create_new { return Err(Error::from_raw_os_error(libc::EINVAL)); } } } ```
1 parent 2f7f807 commit 5060045

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

dev-tools/omdb/src/bin/omdb/nexus.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,13 +4500,18 @@ async fn cmd_nexus_support_bundles_download(
45004500
let stream =
45014501
support_bundle_download_ranges(client, args.id, start, total_length);
45024502

4503+
let mut open_opts = OpenOptions::new();
4504+
open_opts.create(true);
4505+
45034506
let sink: Box<dyn std::io::Write> = match &args.output {
45044507
Some(path) => Box::new(
4505-
OpenOptions::new()
4506-
.create(true)
4507-
.append(true)
4508-
.truncate(!args.resume)
4509-
.open(path)?,
4508+
if args.resume {
4509+
open_opts.append(true)
4510+
} else {
4511+
open_opts.write(true).truncate(true)
4512+
}
4513+
.open(path)
4514+
.with_context(|| format!("failed to create {path}"))?,
45104515
),
45114516
None => Box::new(std::io::stdout()),
45124517
};

0 commit comments

Comments
 (0)