22
33use std:: collections:: BTreeMap ;
44
5- use snafu:: { ResultExt , Snafu , ensure } ;
5+ use snafu:: { ResultExt , Snafu } ;
66use stackable_operator:: {
77 memory:: MemoryQuantity ,
88 role_utils:: { ZeroReplicasCounting , fixed_replica_count} ,
@@ -51,11 +51,6 @@ pub enum Error {
5151 GenerateOidcConfig {
5252 source : crate :: security:: oidc:: Error ,
5353 } ,
54-
55- #[ snafu( display(
56- "NiFi 1.x requires ZooKeeper (hint: upgrade to NiFi 2.x or set .spec.clusterConfig.zookeeperConfigMapName)"
57- ) ) ]
58- Nifi1RequiresZookeeper ,
5954}
6055
6156/// NiFi Python (`nipy`) extension directories, mounted only by the `nifi.properties` builder.
@@ -72,36 +67,15 @@ pub fn build(
7267 proxy_hosts : & str ,
7368) -> Result < String , Error > {
7469 let git_sync_resources = & rg. config . git_sync_resources ;
75- let product_version = & cluster. image . product_version ;
7670 let auth_config = & cluster. cluster_config . authentication ;
7771 let resource_config = & rg. config . resources ;
7872
79- // TODO: Remove once we dropped support for all NiFi 1.x versions
80- let is_nifi_1 = product_version. starts_with ( "1." ) ;
81-
8273 let mut properties = BTreeMap :: new ( ) ;
8374 // Core Properties
84- // According to https://cwiki.apache.org/confluence/display/NIFI/Migration+Guidance#MigrationGuidance-Migratingto2.0.0-M1
85- // The nifi.flow.configuration.file property in nifi.properties must be changed to reference
86- // "flow.json.gz" instead of "flow.xml.gz"
87- // TODO: Remove once we dropped support for all 1.x.x versions
88- // TODO(malte): In order to use CLI tools like: ./bin/nifi.sh set-sensitive-properties-algorithm NIFI_PBKDF2_AES_GCM_256
89- // we have to set both "nifi.flow.configuration.file" and "nifi.flow.configuration.json.file" in NiFi 1.x.x.
90- if is_nifi_1 {
91- properties. insert (
92- "nifi.flow.configuration.file" . to_string ( ) ,
93- NifiRepository :: Database . mount_path ( ) + "/flow.xml.gz" ,
94- ) ;
95- properties. insert (
96- "nifi.flow.configuration.json.file" . to_string ( ) ,
97- NifiRepository :: Database . mount_path ( ) + "/flow.json.gz" ,
98- ) ;
99- } else {
100- properties. insert (
101- "nifi.flow.configuration.file" . to_string ( ) ,
102- NifiRepository :: Database . mount_path ( ) + "/flow.json.gz" ,
103- ) ;
104- }
75+ properties. insert (
76+ "nifi.flow.configuration.file" . to_string ( ) ,
77+ NifiRepository :: Database . mount_path ( ) + "/flow.json.gz" ,
78+ ) ;
10579
10680 properties. insert (
10781 "nifi.flow.configuration.archive.enabled" . to_string ( ) ,
@@ -454,7 +428,6 @@ pub fn build(
454428 "" . to_string ( ) ,
455429 ) ;
456430
457- // The algorithm has already been validated in the validate step (check_for_nifi_version).
458431 properties. insert (
459432 "nifi.sensitive.props.algorithm" . to_string ( ) ,
460433 cluster
@@ -572,8 +545,6 @@ pub fn build(
572545 }
573546
574547 v1alpha1:: NifiClusteringBackend :: Kubernetes { } => {
575- ensure ! ( !is_nifi_1, Nifi1RequiresZookeeperSnafu ) ;
576-
577548 properties. insert (
578549 "nifi.cluster.leader.election.implementation" . to_string ( ) ,
579550 "KubernetesLeaderElectionManager" . to_string ( ) ,
@@ -590,9 +561,6 @@ pub fn build(
590561 //####################
591562 // Custom components #
592563 //####################
593- // NiFi 1.x does not support Python components and the Python configuration below is just
594- // ignored.
595-
596564 // The command used to launch Python.
597565 // This property must be set to enable Python-based processors.
598566 properties. insert ( "nifi.python.command" . to_string ( ) , "python3" . to_string ( ) ) ;
@@ -807,53 +775,6 @@ mod tests {
807775 ) ;
808776 }
809777
810- /// NiFi 1.x cannot use the Kubernetes clustering backend, so building must fail.
811- #[ test]
812- fn kubernetes_backend_is_rejected_on_nifi_1 ( ) {
813- let mut cluster = minimal_validated_cluster ( ) ;
814- cluster. image . product_version = "1.27.0" . to_string ( ) ;
815- let rg = default_rg ( & cluster) ;
816-
817- let error = build ( & cluster, rg, "*" )
818- . expect_err ( "NiFi 1.x with the Kubernetes backend must be rejected" ) ;
819-
820- assert ! ( matches!( error, Error :: Nifi1RequiresZookeeper ) ) ;
821- }
822-
823- /// NiFi 1.x with the ZooKeeper backend is valid.
824- #[ test]
825- fn zookeeper_backend_is_allowed_on_nifi_1 ( ) {
826- let mut cluster = minimal_validated_cluster ( ) ;
827- cluster. image . product_version = "1.27.0" . to_string ( ) ;
828- cluster. cluster_config . clustering_backend = v1alpha1:: NifiClusteringBackend :: ZooKeeper {
829- zookeeper_config_map_name : "my-zk" . parse ( ) . expect ( "valid ConfigMap name" ) ,
830- } ;
831- let rg = default_rg ( & cluster) ;
832-
833- assert ! ( build( & cluster, rg, "*" ) . is_ok( ) ) ;
834- }
835-
836- /// NiFi 2.x configures only the JSON flow file; NiFi 1.x configures both the XML and JSON files.
837- #[ test]
838- fn flow_configuration_files_differ_between_nifi_versions ( ) {
839- let cluster_2 = minimal_validated_cluster ( ) ; // NiFi 2.x
840- let props_2 = build ( & cluster_2, default_rg ( & cluster_2) , "*" ) . expect ( "build should succeed" ) ;
841- assert ! ( props_2. contains( "nifi.flow.configuration.file=" ) ) ;
842- assert ! ( props_2. contains( "flow.json.gz" ) ) ;
843- assert ! ( !props_2. contains( "flow.xml.gz" ) ) ;
844- assert ! ( !props_2. contains( "nifi.flow.configuration.json.file=" ) ) ;
845-
846- let mut cluster_1 = minimal_validated_cluster ( ) ;
847- cluster_1. image . product_version = "1.27.0" . to_string ( ) ;
848- // NiFi 1.x must use the ZooKeeper backend.
849- cluster_1. cluster_config . clustering_backend = v1alpha1:: NifiClusteringBackend :: ZooKeeper {
850- zookeeper_config_map_name : "my-zk" . parse ( ) . expect ( "valid ConfigMap name" ) ,
851- } ;
852- let props_1 = build ( & cluster_1, default_rg ( & cluster_1) , "*" ) . expect ( "build should succeed" ) ;
853- assert ! ( props_1. contains( "flow.xml.gz" ) ) ;
854- assert ! ( props_1. contains( "nifi.flow.configuration.json.file=" ) ) ;
855- }
856-
857778 /// The flow archive max storage is the flowfile-repo capacity scaled by the 0.9 utilization
858779 /// factor (default capacity 1024Mi -> ~921 MB).
859780 #[ test]
0 commit comments