Skip to content

Commit cb4460f

Browse files
authored
fix: Don't always return an error stating volumeMounts are colliding (#879)
* fix: Don't always return an error stating volumeMounts are colliding * refactoring * changelog * Bump crate to 0.77.1 * remove details from tracing error message
1 parent 90d4cc0 commit cb4460f

File tree

5 files changed

+29
-17
lines changed

5 files changed

+29
-17
lines changed

Cargo.lock

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

crates/stackable-operator/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## [0.77.1] - 2024-09-27
8+
9+
### Fixed
10+
11+
- Fix always returning an error stating that volumeMounts are colliding. Instead move the error
12+
creation to the correct location within an `if` statement ([#879]).
13+
14+
[#879]: https://github.com/stackabletech/operator-rs/pull/879
15+
716
## [0.77.0] - 2024-09-26
817

918
### Fixed

crates/stackable-operator/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "stackable-operator"
33
description = "Stackable Operator Framework"
4-
version = "0.77.0"
4+
version = "0.77.1"
55
authors.workspace = true
66
license.workspace = true
77
edition.workspace = true

crates/stackable-operator/src/builder/pod/container.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ pub enum Error {
2828
},
2929

3030
#[snafu(display(
31-
"Colliding mountPath {mount_path:?} in volumeMounts with different content. \
31+
"Colliding mountPath {colliding_mount_path:?} in volumeMounts with different content. \
3232
Existing volume name {existing_volume_name:?}, new volume name {new_volume_name:?}"
3333
))]
3434
MountPathCollision {
35-
mount_path: String,
35+
colliding_mount_path: String,
3636
existing_volume_name: String,
3737
new_volume_name: String,
3838
},
@@ -230,15 +230,16 @@ impl ContainerBuilder {
230230
tracing::error!(
231231
colliding_mount_path,
232232
?existing_volume_mount,
233-
"Colliding mountPath {colliding_mount_path:?} in volumeMounts with different content"
233+
"Colliding mountPath in volumeMounts with different content"
234234
);
235+
236+
MountPathCollisionSnafu {
237+
colliding_mount_path,
238+
existing_volume_name: &existing_volume_mount.name,
239+
new_volume_name: &volume_mount.name,
240+
}
241+
.fail()?;
235242
}
236-
MountPathCollisionSnafu {
237-
mount_path: &volume_mount.mount_path,
238-
existing_volume_name: &existing_volume_mount.name,
239-
new_volume_name: &volume_mount.name,
240-
}
241-
.fail()?;
242243
} else {
243244
self.volume_mounts
244245
.insert(volume_mount.mount_path.clone(), volume_mount);

crates/stackable-operator/src/builder/pod/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ pub enum Error {
5252
#[snafu(display("object is missing key {key:?}"))]
5353
MissingObjectKey { key: &'static str },
5454

55-
#[snafu(display("Colliding volume name {volume_name:?} in volumes with different content"))]
56-
VolumeNameCollision { volume_name: String },
55+
#[snafu(display(
56+
"Colliding volume name {colliding_volume_name:?} in volumes with different content"
57+
))]
58+
VolumeNameCollision { colliding_volume_name: String },
5759
}
5860

5961
/// A builder to build [`Pod`] or [`PodTemplateSpec`] objects.
@@ -292,16 +294,16 @@ impl PodBuilder {
292294
pub fn add_volume(&mut self, volume: Volume) -> Result<&mut Self> {
293295
if let Some(existing_volume) = self.volumes.get(&volume.name) {
294296
if existing_volume != &volume {
295-
let colliding_name = &volume.name;
297+
let colliding_volume_name = &volume.name;
296298
// We don't want to include the details in the error message, but instead trace them
297299
tracing::error!(
298-
colliding_name,
300+
colliding_volume_name,
299301
?existing_volume,
300-
"Colliding volume name {colliding_name:?} in volumes with different content"
302+
"Colliding volume name in volumes with different content"
301303
);
302304

303305
VolumeNameCollisionSnafu {
304-
volume_name: &volume.name,
306+
colliding_volume_name,
305307
}
306308
.fail()?;
307309
}

0 commit comments

Comments
 (0)