Skip to content

Commit 922273d

Browse files
fix: Fix republishing volumes after a Node restart (#284)
* fix: Fix an error after a Node restart * Check if the default-address symlink needs to be updated * chore: Fix clippy warning * chore: Upgrade ring
1 parent c1f49eb commit 922273d

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ All notable changes to this project will be documented in this file.
1717
### Fixed
1818

1919
- Give RBAC permission to `delete` Services, which is needed to set an ownerRef on already existing Services ([#283]).
20+
- Fix the error "failed to write content: File exists (os error 17)" after a
21+
Node restart ([#284]).
2022

2123
[#267]: https://github.com/stackabletech/listener-operator/pull/267
2224
[#268]: https://github.com/stackabletech/listener-operator/pull/268
2325
[#279]: https://github.com/stackabletech/listener-operator/pull/279
2426
[#282]: https://github.com/stackabletech/listener-operator/pull/282
2527
[#283]: https://github.com/stackabletech/listener-operator/pull/283
28+
[#284]: https://github.com/stackabletech/listener-operator/pull/284
2629

2730
## [24.11.1] - 2025-01-10
2831

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/operator-binary/src/csi_server/node.rs

+20-8
Original file line numberDiff line numberDiff line change
@@ -591,14 +591,26 @@ mod pod_dir {
591591
}
592592
default_addr_dir.get_or_insert(addr_dir);
593593
}
594-
tokio::fs::symlink(
595-
default_addr_dir
596-
.context(NoDefaultAddressSnafu)?
597-
.strip_prefix(target_path)
598-
.context(DefaultAddrIsOutsideRootSnafu)?,
599-
target_path.join("default-address"),
600-
)
601-
.await?;
594+
595+
let relative_default_addr_dir = default_addr_dir
596+
.context(NoDefaultAddressSnafu)?
597+
.strip_prefix(target_path)
598+
.context(DefaultAddrIsOutsideRootSnafu)?
599+
.to_owned();
600+
let default_addr_dir_link = target_path.join("default-address");
601+
// Check if the symlink needs to be updated
602+
if tokio::fs::read_link(&default_addr_dir_link)
603+
.await
604+
.ok()
605+
.as_ref()
606+
!= Some(&relative_default_addr_dir)
607+
{
608+
// Remove any existing symlink because `tokio::fs::symlink` fails if it already exists.
609+
// This happens if the node was restarted. The pod then restarts with the same UID and
610+
// the pre-populated volume.
611+
let _ = tokio::fs::remove_file(&default_addr_dir_link).await;
612+
tokio::fs::symlink(relative_default_addr_dir, &default_addr_dir_link).await?;
613+
}
602614
Ok(())
603615
}
604616
}

rust/operator-binary/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async fn main() -> anyhow::Result<()> {
9797
.await?;
9898
if csi_endpoint
9999
.symlink_metadata()
100-
.map_or(false, |meta| meta.file_type().is_socket())
100+
.is_ok_and(|meta| meta.file_type().is_socket())
101101
{
102102
let _ = std::fs::remove_file(&csi_endpoint);
103103
}

0 commit comments

Comments
 (0)