From 8569ed53def899cfb37169b4b68b5ad0784f77e3 Mon Sep 17 00:00:00 2001 From: HuijingHei Date: Thu, 31 Aug 2023 19:42:22 +0800 Subject: [PATCH] rdcore: run `blkid` with a clean cache to avoid collecting old devices which no longer exist Boot VM failed with following logs, the reproduce rate is 2/4. ``` systemd[1]: Starting CoreOS Ensure Unique Boot Filesystem... rdcore[1252]: blkid: error: /dev/sr0: No such file or directory rdcore[1252]: Error: "blkid" "-p" "/dev/sdb1" "/dev/sr0" "/dev/sda4" "/dev/sda2" "/dev/sda3" "/dev/sda1" failed with exit status: 2 systemd[1]: coreos-ignition-unique-boot.service: Main process exited, code=exited, status=1/FAILURE coreos-ignition-unique-boot.service: Failed with result 'exit-code'. Failed to start CoreOS Ensure Unique Boot Filesystem. systemd[1]: coreos-ignition-unique-boot.service: Triggering OnFailure= dependencies. ``` Seems `blkid` collecting old devices from cache which no longer exist, should run with a clean cache before gathering the list of devices. Fixes https://issues.redhat.com/browse/OCPBUGS-17643 --- src/blockdev.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/blockdev.rs b/src/blockdev.rs index 4bb9a422d..9aa71297e 100644 --- a/src/blockdev.rs +++ b/src/blockdev.rs @@ -885,11 +885,18 @@ fn split_blkid_line(line: &str) -> HashMap { } fn blkid() -> Result>> { - // Run once to gather the list of devices, and then run again with -p so - // that we don't rely on blkid cache: + // Run blkid with a clean cache to avoid collecting old devices which no + // longer exist. + // https://github.com/coreos/coreos-installer/pull/1288#discussion_r1312008111 + + // Run once to gather the list of devices, which we need to specify for + // the blkid -p below, which we use to probe the devices to not rely on + // the blkid cache: // https://github.com/coreos/fedora-coreos-config/pull/2181#issuecomment-1397386896 let devices = { let mut cmd = Command::new("blkid"); + cmd.arg("--cache-file"); + cmd.arg("/dev/null"); cmd.arg("-o"); cmd.arg("device"); cmd_output(&mut cmd)?