Skip to content

Commit dd42d58

Browse files
authored
fix(ctl): Skip creating operator-namespace when passing --skip-release in stack/demo command (#106)
* Initial commit * Apply suggestion
1 parent 1b65f88 commit dd42d58

File tree

5 files changed

+74
-65
lines changed

5 files changed

+74
-65
lines changed

rust/stackable-cockpit/src/platform/demo/spec.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,13 @@ impl DemoSpecV2 {
136136
.context(StackSnafu)?;
137137
self.check_prerequisites(product_namespace).await?;
138138

139-
// Install release
140-
stack_spec
141-
.install_release(
142-
release_list,
143-
operator_namespace,
144-
product_namespace,
145-
skip_release,
146-
)
147-
.await
148-
.context(StackSnafu)?;
139+
// Install release if not opted out
140+
if !skip_release {
141+
stack_spec
142+
.install_release(release_list, operator_namespace, product_namespace)
143+
.await
144+
.context(StackSnafu)?;
145+
}
149146

150147
// Install stack
151148
stack_spec

rust/stackable-cockpit/src/platform/stack/spec.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,8 @@ impl StackSpecV2 {
159159
release_list: ReleaseList,
160160
operator_namespace: &str,
161161
product_namespace: &str,
162-
skip_release_install: bool,
163162
) -> Result<(), StackError> {
164-
info!("Installing release for stack");
165-
166-
if skip_release_install {
167-
info!("Skipping release installation during stack installation process");
168-
return Ok(());
169-
}
163+
info!("Trying to install release {}", self.release);
170164

171165
// Get the release by name
172166
let release = release_list

rust/stackablectl/src/cmds/demo.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,20 @@ async fn install_cmd(
275275
.clone()
276276
.unwrap_or(DEFAULT_OPERATOR_NAMESPACE.into());
277277

278-
namespace::create_if_needed(operator_namespace.clone())
279-
.await
280-
.context(NamespaceSnafu {
281-
namespace: operator_namespace.clone(),
282-
})?;
283-
284278
let product_namespace = args
285279
.namespaces
286280
.product_namespace
287281
.clone()
288282
.unwrap_or(DEFAULT_PRODUCT_NAMESPACE.into());
289283

284+
if !args.skip_release {
285+
namespace::create_if_needed(operator_namespace.clone())
286+
.await
287+
.context(NamespaceSnafu {
288+
namespace: operator_namespace.clone(),
289+
})?;
290+
}
291+
290292
namespace::create_if_needed(product_namespace.clone())
291293
.await
292294
.context(NamespaceSnafu {

rust/stackablectl/src/cmds/release.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use tracing::{debug, info, instrument};
99
use stackable_cockpit::{
1010
common::ListError,
1111
constants::DEFAULT_OPERATOR_NAMESPACE,
12-
platform::release::{ReleaseInstallError, ReleaseList, ReleaseUninstallError},
12+
platform::{
13+
namespace::{self, NamespaceError},
14+
release::{ReleaseInstallError, ReleaseList, ReleaseUninstallError},
15+
},
1316
utils::path::PathOrUrlParseError,
1417
xfer::{cache::Cache, FileTransferClient, FileTransferError},
1518
};
@@ -117,6 +120,12 @@ pub enum ReleaseCmdError {
117120

118121
#[snafu(display("transfer error"))]
119122
TransferError { source: FileTransferError },
123+
124+
#[snafu(display("failed to create namespace '{namespace}'"))]
125+
NamespaceError {
126+
source: NamespaceError,
127+
namespace: String,
128+
},
120129
}
121130

122131
impl ReleaseArgs {
@@ -235,14 +244,21 @@ async fn install_cmd(
235244
) -> Result<String, ReleaseCmdError> {
236245
info!("Installing release");
237246

238-
// Install local cluster if needed
239-
args.local_cluster
240-
.install_if_needed(None)
241-
.await
242-
.context(CommonClusterArgsSnafu)?;
243-
244247
match release_list.get(&args.release) {
245248
Some(release) => {
249+
// Install local cluster if needed
250+
args.local_cluster
251+
.install_if_needed(None)
252+
.await
253+
.context(CommonClusterArgsSnafu)?;
254+
255+
// Create operator namespace if needed
256+
namespace::create_if_needed(args.operator_namespace.clone())
257+
.await
258+
.context(NamespaceSnafu {
259+
namespace: args.operator_namespace.clone(),
260+
})?;
261+
246262
release
247263
.install(
248264
&args.included_products,
@@ -251,7 +267,7 @@ async fn install_cmd(
251267
)
252268
.context(ReleaseInstallSnafu)?;
253269

254-
Ok("Installed release".into())
270+
Ok(format!("Installed release {}", args.release))
255271
}
256272
None => Ok("No such release".into()),
257273
}
@@ -261,15 +277,15 @@ async fn uninstall_cmd(
261277
args: &ReleaseUninstallArgs,
262278
release_list: ReleaseList,
263279
) -> Result<String, ReleaseCmdError> {
264-
info!("Installing release");
280+
info!("Uninstalling release");
265281

266282
match release_list.get(&args.release) {
267283
Some(release) => {
268284
release
269285
.uninstall(&args.operator_namespace)
270286
.context(ReleaseUninstallSnafu)?;
271287

272-
Ok("Installed release".into())
288+
Ok(format!("Uninstalled release {}", args.release))
273289
}
274290
None => Ok("No such release".into()),
275291
}

rust/stackablectl/src/cmds/stack.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -242,54 +242,54 @@ async fn install_cmd(
242242
.await
243243
.context(ListSnafu)?;
244244

245-
// Install local cluster if needed
246-
args.local_cluster
247-
.install_if_needed(None)
248-
.await
249-
.context(CommonClusterArgsSnafu)?;
250-
251-
let operator_namespace = args
252-
.namespaces
253-
.operator_namespace
254-
.clone()
255-
.unwrap_or(DEFAULT_OPERATOR_NAMESPACE.into());
256-
257-
namespace::create_if_needed(operator_namespace.clone())
258-
.await
259-
.context(NamespaceSnafu {
260-
namespace: operator_namespace.clone(),
261-
})?;
262-
263245
let product_namespace = args
264246
.namespaces
265247
.product_namespace
266248
.clone()
267249
.unwrap_or(DEFAULT_PRODUCT_NAMESPACE.into());
268250

269-
namespace::create_if_needed(product_namespace.clone())
270-
.await
271-
.context(NamespaceSnafu {
272-
namespace: product_namespace.clone(),
273-
})?;
251+
let operator_namespace = args
252+
.namespaces
253+
.operator_namespace
254+
.clone()
255+
.unwrap_or(DEFAULT_OPERATOR_NAMESPACE.into());
274256

275257
match stack_list.get(&args.stack_name) {
276258
Some(stack_spec) => {
259+
// Install local cluster if needed
260+
args.local_cluster
261+
.install_if_needed(None)
262+
.await
263+
.context(CommonClusterArgsSnafu)?;
264+
277265
// Check perquisites
278266
stack_spec
279267
.check_prerequisites(&product_namespace)
280268
.await
281269
.context(StackSnafu)?;
282270

283-
// Install release
284-
stack_spec
285-
.install_release(
286-
release_list,
287-
&operator_namespace,
288-
&product_namespace,
289-
args.skip_release,
290-
)
271+
// Install release if not opted out
272+
if !args.skip_release {
273+
namespace::create_if_needed(operator_namespace.clone())
274+
.await
275+
.context(NamespaceSnafu {
276+
namespace: operator_namespace.clone(),
277+
})?;
278+
279+
stack_spec
280+
.install_release(release_list, &operator_namespace, &product_namespace)
281+
.await
282+
.context(StackSnafu)?;
283+
} else {
284+
info!("Skipping release installation during stack installation process");
285+
}
286+
287+
// Create product namespace if needed
288+
namespace::create_if_needed(product_namespace.clone())
291289
.await
292-
.context(StackSnafu)?;
290+
.context(NamespaceSnafu {
291+
namespace: product_namespace.clone(),
292+
})?;
293293

294294
// Install stack
295295
stack_spec

0 commit comments

Comments
 (0)