Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't always return an error stating volumeMounts are colliding #879

Merged
merged 5 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading