@@ -7,8 +7,14 @@ use snafu::{ResultExt, Snafu};
7
7
use stackable_cockpit:: {
8
8
common:: list,
9
9
constants:: DEFAULT_OPERATOR_NAMESPACE ,
10
- platform:: { namespace, operator:: ChartSourceType , release} ,
10
+ helm:: { self , Release } ,
11
+ platform:: {
12
+ namespace,
13
+ operator:: { self , ChartSourceType } ,
14
+ release,
15
+ } ,
11
16
utils:: {
17
+ self ,
12
18
k8s:: { self , Client } ,
13
19
path:: PathOrUrlParseError ,
14
20
} ,
@@ -118,6 +124,9 @@ pub struct ReleaseUninstallArgs {
118
124
119
125
#[ derive( Debug , Snafu ) ]
120
126
pub enum CmdError {
127
+ #[ snafu( display( "Helm error" ) ) ]
128
+ HelmError { source : helm:: Error } ,
129
+
121
130
#[ snafu( display( "failed to serialize YAML output" ) ) ]
122
131
SerializeYamlOutput { source : serde_yaml:: Error } ,
123
132
@@ -353,19 +362,40 @@ async fn upgrade_cmd(
353
362
let mut output = cli. result ( ) ;
354
363
let client = Client :: new ( ) . await . context ( KubeClientCreateSnafu ) ?;
355
364
365
+ // Get all currently installed operators to only upgrade those
366
+ let installed_charts: Vec < Release > =
367
+ helm:: list_releases ( & args. operator_namespace ) . context ( HelmSnafu ) ?;
368
+
369
+ let mut operators: Vec < String > = operator:: VALID_OPERATORS
370
+ . iter ( )
371
+ . filter ( |operator| {
372
+ installed_charts
373
+ . iter ( )
374
+ . any ( |release| release. name == utils:: operator_chart_name ( operator) )
375
+ } )
376
+ . map ( |operator| operator. to_string ( ) )
377
+ . collect ( ) ;
378
+
356
379
// Uninstall the old operator release first
357
380
release
358
381
. uninstall (
359
- & args . included_products ,
382
+ & operators ,
360
383
& args. excluded_products ,
361
384
& args. operator_namespace ,
362
385
)
363
386
. context ( ReleaseUninstallSnafu ) ?;
364
387
388
+ // If operators were added to args.included_products, install them as well
389
+ for product in & args. included_products {
390
+ if !operators. contains ( product) {
391
+ operators. push ( product. clone ( ) ) ;
392
+ }
393
+ }
394
+
365
395
// Upgrade the CRDs for all the operators to be upgraded
366
396
release
367
397
. upgrade_crds (
368
- & args . included_products ,
398
+ & operators ,
369
399
& args. excluded_products ,
370
400
& args. operator_namespace ,
371
401
& client,
@@ -376,7 +406,7 @@ async fn upgrade_cmd(
376
406
// Install the new operator release
377
407
release
378
408
. install (
379
- & args . included_products ,
409
+ & operators ,
380
410
& args. excluded_products ,
381
411
& args. operator_namespace ,
382
412
& ChartSourceType :: from ( cli. chart_type ( ) ) ,
0 commit comments