From 2747cdee845074b94639a8042eb9fe1fd81ed24f Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Fri, 7 Mar 2025 14:09:43 +0100 Subject: [PATCH] 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 aab989e..9b73b78 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 6715948..e680b5c 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(())