@@ -5,23 +5,16 @@ use snafu::{ResultExt, Snafu};
55use stackable_operator:: {
66 client:: Client ,
77 k8s_openapi:: { api:: apps:: v1:: StatefulSet , apimachinery:: pkg:: apis:: meta:: v1:: LabelSelector } ,
8- kvp:: Labels ,
9- v2:: types:: kubernetes:: NamespaceName ,
108} ;
119
12- use crate :: crd :: { APP_NAME , NifiRole , v1alpha1 } ;
10+ use super :: ValidatedCluster ;
1311
1412#[ derive( Snafu , Debug ) ]
1513pub enum Error {
1614 #[ snafu( display( "failed to fetch deployed StatefulSets" ) ) ]
1715 FetchStatefulsets {
1816 source : stackable_operator:: client:: Error ,
1917 } ,
20-
21- #[ snafu( display( "failed to build labels" ) ) ]
22- LabelBuild {
23- source : stackable_operator:: kvp:: LabelError ,
24- } ,
2518}
2619
2720type Result < T , E = Error > = std:: result:: Result < T , E > ;
@@ -37,29 +30,26 @@ pub enum ClusterVersionUpdateState {
3730}
3831
3932pub async fn cluster_version_update_state (
40- nifi : & v1alpha1 :: NifiCluster ,
33+ cluster : & ValidatedCluster ,
4134 client : & Client ,
42- namespace : & NamespaceName ,
43- resolved_version : & String ,
4435 deployed_version : Option < & String > ,
4536) -> Result < ClusterVersionUpdateState > {
37+ // The version we want to converge to, i.e. the resolved product image version.
38+ let resolved_version = & cluster. image . product_version ;
39+
4640 // Handle full restarts for a version change
4741 match deployed_version {
4842 Some ( deployed_version) => {
4943 if deployed_version != resolved_version {
5044 // Check if statefulsets are already scaled to zero, if not - requeue
5145 let selector = LabelSelector {
5246 match_expressions : None ,
53- match_labels : Some (
54- Labels :: role_selector ( nifi, APP_NAME , & NifiRole :: Node . to_string ( ) )
55- . context ( LabelBuildSnafu ) ?
56- . into ( ) ,
57- ) ,
47+ match_labels : Some ( cluster. role_selector ( ) . into ( ) ) ,
5848 } ;
5949
6050 // Retrieve the deployed statefulsets to check on the current status of the restart
6151 let deployed_statefulsets = client
62- . list_with_label_selector :: < StatefulSet > ( namespace. as_ref ( ) , & selector)
52+ . list_with_label_selector :: < StatefulSet > ( cluster . namespace . as_ref ( ) , & selector)
6353 . await
6454 . context ( FetchStatefulsetsSnafu ) ?;
6555
0 commit comments