Skip to content

Commit

Permalink
fix: Fix republishing volumes after a Node restart (#284)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
siegfriedweber authored Mar 10, 2025
1 parent c1f49eb commit 922273d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 20 additions & 8 deletions rust/operator-binary/src/csi_server/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,14 +591,26 @@ mod pod_dir {
}
default_addr_dir.get_or_insert(addr_dir);
}
tokio::fs::symlink(
default_addr_dir
.context(NoDefaultAddressSnafu)?
.strip_prefix(target_path)
.context(DefaultAddrIsOutsideRootSnafu)?,
target_path.join("default-address"),
)
.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(())
}
}
2 changes: 1 addition & 1 deletion rust/operator-binary/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 922273d

Please sign in to comment.