diff --git a/Cargo.lock b/Cargo.lock index 627b95b87..7923582b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2926,7 +2926,7 @@ dependencies = [ [[package]] name = "stackable-operator" -version = "0.77.0" +version = "0.77.1" dependencies = [ "chrono", "clap", diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index 3d27d6165..6d7ebe9f4 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [0.77.1] - 2024-09-27 + +### Fixed + +- Fix always returning an error stating that volumeMounts are colliding. Instead move the error + creation to the correct location within an `if` statement ([#879]). + +[#879]: https://github.com/stackabletech/operator-rs/pull/879 + ## [0.77.0] - 2024-09-26 ### Fixed diff --git a/crates/stackable-operator/Cargo.toml b/crates/stackable-operator/Cargo.toml index 5a19c8ec8..4619582b0 100644 --- a/crates/stackable-operator/Cargo.toml +++ b/crates/stackable-operator/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "stackable-operator" description = "Stackable Operator Framework" -version = "0.77.0" +version = "0.77.1" authors.workspace = true license.workspace = true edition.workspace = true diff --git a/crates/stackable-operator/src/builder/pod/container.rs b/crates/stackable-operator/src/builder/pod/container.rs index 8357493ac..49b847b13 100644 --- a/crates/stackable-operator/src/builder/pod/container.rs +++ b/crates/stackable-operator/src/builder/pod/container.rs @@ -28,11 +28,11 @@ pub enum Error { }, #[snafu(display( - "Colliding mountPath {mount_path:?} in volumeMounts with different content. \ + "Colliding mountPath {colliding_mount_path:?} in volumeMounts with different content. \ Existing volume name {existing_volume_name:?}, new volume name {new_volume_name:?}" ))] MountPathCollision { - mount_path: String, + colliding_mount_path: String, existing_volume_name: String, new_volume_name: String, }, @@ -230,15 +230,16 @@ impl ContainerBuilder { tracing::error!( colliding_mount_path, ?existing_volume_mount, - "Colliding mountPath {colliding_mount_path:?} in volumeMounts with different content" + "Colliding mountPath in volumeMounts with different content" ); + + MountPathCollisionSnafu { + colliding_mount_path, + existing_volume_name: &existing_volume_mount.name, + new_volume_name: &volume_mount.name, + } + .fail()?; } - MountPathCollisionSnafu { - mount_path: &volume_mount.mount_path, - existing_volume_name: &existing_volume_mount.name, - new_volume_name: &volume_mount.name, - } - .fail()?; } else { self.volume_mounts .insert(volume_mount.mount_path.clone(), volume_mount); diff --git a/crates/stackable-operator/src/builder/pod/mod.rs b/crates/stackable-operator/src/builder/pod/mod.rs index fb5bda51d..54b34bd3a 100644 --- a/crates/stackable-operator/src/builder/pod/mod.rs +++ b/crates/stackable-operator/src/builder/pod/mod.rs @@ -52,8 +52,10 @@ pub enum Error { #[snafu(display("object is missing key {key:?}"))] MissingObjectKey { key: &'static str }, - #[snafu(display("Colliding volume name {volume_name:?} in volumes with different content"))] - VolumeNameCollision { volume_name: String }, + #[snafu(display( + "Colliding volume name {colliding_volume_name:?} in volumes with different content" + ))] + VolumeNameCollision { colliding_volume_name: String }, } /// A builder to build [`Pod`] or [`PodTemplateSpec`] objects. @@ -292,16 +294,16 @@ impl PodBuilder { pub fn add_volume(&mut self, volume: Volume) -> Result<&mut Self> { if let Some(existing_volume) = self.volumes.get(&volume.name) { if existing_volume != &volume { - let colliding_name = &volume.name; + let colliding_volume_name = &volume.name; // We don't want to include the details in the error message, but instead trace them tracing::error!( - colliding_name, + colliding_volume_name, ?existing_volume, - "Colliding volume name {colliding_name:?} in volumes with different content" + "Colliding volume name in volumes with different content" ); VolumeNameCollisionSnafu { - volume_name: &volume.name, + colliding_volume_name, } .fail()?; }