From 2747cdee845074b94639a8042eb9fe1fd81ed24f Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Fri, 7 Mar 2025 14:09:43 +0100 Subject: [PATCH 1/4] fix: Fix an error after a Node restart --- CHANGELOG.md | 3 +++ rust/operator-binary/src/csi_server/node.rs | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aab989e0..9b73b78b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,12 +17,15 @@ All notable changes to this project will be documented in this file. ### Fixed - Give RBAC permission to `delete` Services, which is needed to set an ownerRef on already existing Services ([#283]). +- Fix the error "failed to write content: File exists (os error 17)" after a + Node restart ([#284]). [#267]: https://github.com/stackabletech/listener-operator/pull/267 [#268]: https://github.com/stackabletech/listener-operator/pull/268 [#279]: https://github.com/stackabletech/listener-operator/pull/279 [#282]: https://github.com/stackabletech/listener-operator/pull/282 [#283]: https://github.com/stackabletech/listener-operator/pull/283 +[#284]: https://github.com/stackabletech/listener-operator/pull/284 ## [24.11.1] - 2025-01-10 diff --git a/rust/operator-binary/src/csi_server/node.rs b/rust/operator-binary/src/csi_server/node.rs index 67159487..e680b5cf 100644 --- a/rust/operator-binary/src/csi_server/node.rs +++ b/rust/operator-binary/src/csi_server/node.rs @@ -591,12 +591,18 @@ mod pod_dir { } default_addr_dir.get_or_insert(addr_dir); } + + let default_addr_link = target_path.join("default-address"); + // Remove any existing symlink because `tokio::fs::symlink` fails if it already exists. + // This happens if the node was restarted. The pod then restarts with the same UID and + // the pre-populated volume. + let _ = tokio::fs::remove_file(&default_addr_link).await; tokio::fs::symlink( default_addr_dir .context(NoDefaultAddressSnafu)? .strip_prefix(target_path) .context(DefaultAddrIsOutsideRootSnafu)?, - target_path.join("default-address"), + &default_addr_link, ) .await?; Ok(()) From 3dc5186186dd0ce7393bd14f10fb6caea23c0057 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Fri, 7 Mar 2025 18:01:47 +0100 Subject: [PATCH 2/4] Check if the default-address symlink needs to be updated --- rust/operator-binary/src/csi_server/node.rs | 32 ++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/rust/operator-binary/src/csi_server/node.rs b/rust/operator-binary/src/csi_server/node.rs index e680b5cf..fffbf240 100644 --- a/rust/operator-binary/src/csi_server/node.rs +++ b/rust/operator-binary/src/csi_server/node.rs @@ -592,19 +592,25 @@ mod pod_dir { default_addr_dir.get_or_insert(addr_dir); } - let default_addr_link = target_path.join("default-address"); - // Remove any existing symlink because `tokio::fs::symlink` fails if it already exists. - // This happens if the node was restarted. The pod then restarts with the same UID and - // the pre-populated volume. - let _ = tokio::fs::remove_file(&default_addr_link).await; - tokio::fs::symlink( - default_addr_dir - .context(NoDefaultAddressSnafu)? - .strip_prefix(target_path) - .context(DefaultAddrIsOutsideRootSnafu)?, - &default_addr_link, - ) - .await?; + let relative_default_addr_dir = default_addr_dir + .context(NoDefaultAddressSnafu)? + .strip_prefix(target_path) + .context(DefaultAddrIsOutsideRootSnafu)? + .to_owned(); + let default_addr_dir_link = target_path.join("default-address"); + // Check if the symlink needs to be updated + if tokio::fs::read_link(&default_addr_dir_link) + .await + .ok() + .as_ref() + != Some(&relative_default_addr_dir) + { + // Remove any existing symlink because `tokio::fs::symlink` fails if it already exists. + // This happens if the node was restarted. The pod then restarts with the same UID and + // the pre-populated volume. + let _ = tokio::fs::remove_file(&default_addr_dir_link).await; + tokio::fs::symlink(relative_default_addr_dir, &default_addr_dir_link).await?; + } Ok(()) } } From c2ef060050d0338808c519350975ed39de9b2437 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Fri, 7 Mar 2025 18:06:11 +0100 Subject: [PATCH 3/4] chore: Fix clippy warning --- rust/operator-binary/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index 752eef3d..d31088be 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -97,7 +97,7 @@ async fn main() -> anyhow::Result<()> { .await?; if csi_endpoint .symlink_metadata() - .map_or(false, |meta| meta.file_type().is_socket()) + .is_ok_and(|meta| meta.file_type().is_socket()) { let _ = std::fs::remove_file(&csi_endpoint); } From a9059764361473f20b43217106f1e70116ab6367 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Mon, 10 Mar 2025 09:14:17 +0100 Subject: [PATCH 4/4] chore: Upgrade ring --- Cargo.lock | 4 ++-- Cargo.nix | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 09503b59..2a3286e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2126,9 +2126,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "ring" -version = "0.17.11" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da5349ae27d3887ca812fb375b45a4fbb36d8d12d2df394968cd86e35683fe73" +checksum = "70ac5d832aa16abd7d1def883a8545280c20a60f523a370aa3a9617c2b8550ee" dependencies = [ "cc", "cfg-if", diff --git a/Cargo.nix b/Cargo.nix index 2590ec4f..9e600b66 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -6791,10 +6791,10 @@ rec { }; "ring" = rec { crateName = "ring"; - version = "0.17.11"; + version = "0.17.13"; edition = "2021"; - links = "ring_core_0_17_11_"; - sha256 = "0wzyhdbf71ndd14kkpyj2a6nvczvli2mndzv2al7r26k4yp4jlys"; + links = "ring_core_0_17_13_"; + sha256 = "1vjhhlmpqqd9lc53ffjj1yk203188n2km27g3myvssm15a1mvb3h"; dependencies = [ { name = "cfg-if";