Skip to content

Commit bc69572

Browse files
authored
fix: Use the provided cluster name when creating a local cluster (#181)
* fix: Use the provided cluster name when creating a local cluster * Add changelog entry
1 parent 5d86d6d commit bc69572

File tree

8 files changed

+22
-20
lines changed

8 files changed

+22
-20
lines changed

rust/stackable-cockpit/src/engine/kind/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use tokio::{io::AsyncWriteExt, process::Command};
55
use tracing::{debug, info, instrument};
66

77
use crate::{
8-
constants::DEFAULT_LOCAL_CLUSTER_NAME,
98
engine::{
109
docker::{self, check_if_docker_is_running},
1110
kind::config::Config,
@@ -56,11 +55,11 @@ impl Cluster {
5655
/// system, but instead will return a data structure representing the
5756
/// cluster. To actually create the cluster, the `create` method must be
5857
/// called.
59-
pub fn new(node_count: usize, cp_node_count: usize, name: Option<String>) -> Self {
58+
pub fn new(node_count: usize, cp_node_count: usize, name: String) -> Self {
6059
Self {
61-
name: name.unwrap_or(DEFAULT_LOCAL_CLUSTER_NAME.into()),
6260
cp_node_count,
6361
node_count,
62+
name,
6463
}
6564
}
6665

rust/stackable-cockpit/src/engine/minikube/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use tokio::process::Command;
33
use tracing::{debug, info, instrument};
44

55
use crate::{
6-
constants::DEFAULT_LOCAL_CLUSTER_NAME,
76
engine::docker::{self, check_if_docker_is_running},
87
utils::check::binaries_present_with_name,
98
};
@@ -37,11 +36,8 @@ pub struct Cluster {
3736
impl Cluster {
3837
/// Create a new kind cluster. This will NOT yet create the cluster on the system, but instead will return a data
3938
/// structure representing the cluster. To actually create the cluster, the `create` method must be called.
40-
pub fn new(node_count: usize, name: Option<String>) -> Self {
41-
Self {
42-
name: name.unwrap_or(DEFAULT_LOCAL_CLUSTER_NAME.into()),
43-
node_count,
44-
}
39+
pub fn new(node_count: usize, name: String) -> Self {
40+
Self { node_count, name }
4541
}
4642

4743
/// Create a new local cluster by calling the Minikube binary

rust/stackablectl/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Fixed
8+
9+
- Fix `--cluster-name` not taking effect. The local test clusters always used the default cluster name ([#181]).
10+
11+
[#181]: https://github.com/stackabletech/stackable-cockpit/pull/181
12+
713
## [23.11.3] - 2024-01-03
814

915
### Fixed

rust/stackablectl/src/args/cluster.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,27 @@ impl CommonClusterArgs {
7676
/// skips creation of the local cluster. If a cluster needs to be created,
7777
/// the function first validates cluster node counts. If this validation
7878
/// fails, an error is returned.
79-
pub async fn install_if_needed(
80-
&self,
81-
name: Option<String>,
82-
) -> Result<(), CommonClusterArgsError> {
79+
pub async fn install_if_needed(&self) -> Result<(), CommonClusterArgsError> {
8380
match &self.cluster_type {
8481
Some(cluster_type) => {
8582
self.validate()?;
8683

8784
match cluster_type {
8885
ClusterType::Kind => {
89-
let kind_cluster =
90-
kind::Cluster::new(self.cluster_nodes, self.cluster_cp_nodes, name);
86+
let kind_cluster = kind::Cluster::new(
87+
self.cluster_nodes,
88+
self.cluster_cp_nodes,
89+
self.cluster_name.clone(),
90+
);
9191

9292
kind_cluster
9393
.create_if_not_exists()
9494
.await
9595
.context(KindClusterCreateSnafu)
9696
}
9797
ClusterType::Minikube => {
98-
let minikube_cluster = minikube::Cluster::new(self.cluster_nodes, name);
98+
let minikube_cluster =
99+
minikube::Cluster::new(self.cluster_nodes, self.cluster_name.clone());
99100

100101
minikube_cluster
101102
.create_if_not_exists()

rust/stackablectl/src/cmds/demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ async fn install_cmd(
292292

293293
// Install local cluster if needed
294294
args.local_cluster
295-
.install_if_needed(None)
295+
.install_if_needed()
296296
.await
297297
.context(CommonClusterArgsSnafu)?;
298298

rust/stackablectl/src/cmds/operator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ async fn install_cmd(args: &OperatorInstallArgs, cli: &Cli) -> Result<String, Cm
282282
info!("Installing operator(s)");
283283

284284
args.local_cluster
285-
.install_if_needed(None)
285+
.install_if_needed()
286286
.await
287287
.context(CommonClusterArgsSnafu)?;
288288

rust/stackablectl/src/cmds/release.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ async fn install_cmd(
272272

273273
// Install local cluster if needed
274274
args.local_cluster
275-
.install_if_needed(None)
275+
.install_if_needed()
276276
.await
277277
.context(CommonClusterArgsSnafu)?;
278278

rust/stackablectl/src/cmds/stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ async fn install_cmd(
285285

286286
// Install local cluster if needed
287287
args.local_cluster
288-
.install_if_needed(None)
288+
.install_if_needed()
289289
.await
290290
.context(CommonClusterArgsSnafu)?;
291291

0 commit comments

Comments
 (0)