Skip to content

Commit

Permalink
fix: Don't always return an error stating volumeMounts are colliding (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
sbernauer authored Sep 27, 2024
1 parent 90d4cc0 commit cb4460f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

9 changes: 9 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 10 additions & 9 deletions crates/stackable-operator/src/builder/pod/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 8 additions & 6 deletions crates/stackable-operator/src/builder/pod/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()?;
}
Expand Down

0 comments on commit cb4460f

Please sign in to comment.