Skip to content

Commit 0aeb965

Browse files
committed
Remove all unneeded code
1 parent b316f0a commit 0aeb965

18 files changed

Lines changed: 62 additions & 1071 deletions

File tree

extra/crds.yaml

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -139,33 +139,6 @@ spec:
139139
- accessPolicyProvider
140140
type: object
141141
type: object
142-
createReportingTaskJob:
143-
default:
144-
enabled: true
145-
podOverrides: {}
146-
description: |-
147-
This section creates a `create-reporting-task` Kubernetes Job, which enables the export of
148-
Prometheus metrics within NiFi.
149-
properties:
150-
enabled:
151-
default: true
152-
description: |-
153-
Whether the Kubernetes Job should be created, defaults to true. It can be helpful to disable
154-
the Job, e.g. when you configOverride an authentication mechanism, which the Job currently
155-
can't use to authenticate against NiFi.
156-
type: boolean
157-
podOverrides:
158-
default: {}
159-
description: |-
160-
Here you can define a
161-
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core)
162-
to override any property that can be set on the Pod of the create-reporting-task Kubernetes Job.
163-
Read the
164-
[Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides)
165-
for more information.
166-
type: object
167-
x-kubernetes-preserve-unknown-fields: true
168-
type: object
169142
customComponentsGitSync:
170143
default: []
171144
description: |-
@@ -347,26 +320,11 @@ spec:
347320
`nifiPbkdf2AesGcm256` (the default value),
348321
`nifiArgon2AesGcm256`,
349322
350-
The following algorithms are deprecated and will be removed in future versions:
351-
352-
`nifiArgon2AesGcm128`,
353-
`nifiBcryptAesGcm128`,
354-
`nifiBcryptAesGcm256`,
355-
`nifiPbkdf2AesGcm128`,
356-
`nifiScryptAesGcm128`,
357-
`nifiScryptAesGcm256`.
358-
359323
Learn more about the specifics of the algorithm parameters in the
360324
[NiFi documentation](https://nifi.apache.org/docs/nifi-docs/html/administration-guide.html#property-encryption-algorithms).
361325
enum:
362326
- nifiPbkdf2AesGcm256
363327
- nifiArgon2AesGcm256
364-
- nifiBcryptAesGcm128
365-
- nifiBcryptAesGcm256
366-
- nifiPbkdf2AesGcm128
367-
- nifiArgon2AesGcm128
368-
- nifiScryptAesGcm128
369-
- nifiScryptAesGcm256
370328
- null
371329
nullable: true
372330
type: string
@@ -422,8 +380,7 @@ spec:
422380
When using the [Stackable operator for Apache ZooKeeper](https://docs.stackable.tech/home/nightly/zookeeper/)
423381
to deploy a ZooKeeper cluster, this will simply be the name of your ZookeeperCluster resource.
424382
425-
The Kubernetes provider will be used if this field is unset. Kubernetes is only supported for NiFi 2.x and newer,
426-
NiFi 1.x requires ZooKeeper.
383+
The Kubernetes provider will be used if this field is unset.
427384
maxLength: 253
428385
minLength: 1
429386
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$

rust/operator-binary/src/controller/build.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ pub const PROTOCOL_PORT_NAME: &str = "protocol";
2323
pub const PROTOCOL_PORT: Port = Port(9088);
2424
pub const BALANCE_PORT_NAME: &str = "balance";
2525
pub const BALANCE_PORT: Port = Port(6243);
26-
pub const METRICS_PORT_NAME: &str = "metrics";
27-
pub const METRICS_PORT: Port = Port(8081);
2826

2927
// Filesystem paths shared by multiple builders. Single-consumer paths live in their builder.
3028
pub const NIFI_CONFIG_DIRECTORY: &str = "/stackable/nifi/conf";

rust/operator-binary/src/controller/build/properties.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ pub(crate) mod test_support {
9494

9595
use crate::{
9696
controller::{
97-
NifiRoleGroupConfig, ValidatedCluster, ValidatedClusterConfig, ValidatedReportingTask,
98-
ValidatedRoleConfig, ValidatedSensitiveProperties, validate::build_role_group_configs,
97+
NifiRoleGroupConfig, ValidatedCluster, ValidatedClusterConfig, ValidatedRoleConfig,
98+
ValidatedSensitiveProperties, validate::build_role_group_configs,
9999
},
100100
crd::{NifiRole, v1alpha1},
101101
security::{
@@ -105,8 +105,7 @@ pub(crate) mod test_support {
105105
};
106106

107107
/// A minimal NiFi cluster YAML. Mirrors the fixture used by bootstrap_conf tests,
108-
/// stripped down to the mandatory fields only (NiFi 2.x, Kubernetes clustering backend,
109-
/// SingleUser auth).
108+
/// stripped down to the mandatory fields only (Kubernetes clustering backend, SingleUser auth).
110109
pub const MINIMAL_NIFI_YAML: &str = r#"
111110
apiVersion: nifi.stackable.tech/v1alpha1
112111
kind: NifiCluster
@@ -196,15 +195,6 @@ pub(crate) mod test_support {
196195
},
197196
server_tls_secret_class: nifi.server_tls_secret_class().clone(),
198197
extra_volumes: nifi.spec.cluster_config.extra_volumes.clone(),
199-
reporting_task: ValidatedReportingTask {
200-
enabled: nifi.spec.cluster_config.create_reporting_task_job.enabled,
201-
pod_overrides: nifi
202-
.spec
203-
.cluster_config
204-
.create_reporting_task_job
205-
.pod_overrides
206-
.clone(),
207-
},
208198
host_header_check: nifi.spec.cluster_config.host_header_check.clone(),
209199
},
210200
)

rust/operator-binary/src/controller/build/properties/nifi_properties.rs

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::collections::BTreeMap;
44

5-
use snafu::{ResultExt, Snafu, ensure};
5+
use snafu::{ResultExt, Snafu};
66
use 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]

rust/operator-binary/src/controller/build/proxy_hosts.rs

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22
33
use std::collections::HashSet;
44

5-
use stackable_operator::utils::cluster_info::KubernetesClusterInfo;
6-
75
use crate::controller::{
86
ValidatedCluster,
97
build::{
10-
HTTPS_PORT,
118
properties::env_reference,
12-
resource::{
13-
reporting_task,
14-
statefulset::{LISTENER_DEFAULT_ADDRESS_ENV, LISTENER_DEFAULT_PORT_HTTPS_ENV},
15-
},
9+
resource::statefulset::{LISTENER_DEFAULT_ADDRESS_ENV, LISTENER_DEFAULT_PORT_HTTPS_ENV},
1610
},
1711
};
1812

@@ -21,10 +15,7 @@ use crate::controller::{
2115
/// The proxy hosts allow-list lets external users access NiFi via addresses we cannot predict,
2216
/// so all of them are added to the setting. For more information see
2317
/// <https://nifi.apache.org/docs/nifi-docs/html/administration-guide.html#proxy_configuration>
24-
pub fn compute_proxy_hosts(
25-
cluster: &ValidatedCluster,
26-
cluster_info: &KubernetesClusterInfo,
27-
) -> String {
18+
pub fn compute_proxy_hosts(cluster: &ValidatedCluster) -> String {
2819
let host_header_check = &cluster.cluster_config.host_header_check;
2920

3021
if host_header_check.allow_all {
@@ -47,17 +38,6 @@ pub fn compute_proxy_hosts(
4738
)]);
4839
proxy_hosts.extend(host_header_check.additional_allowed_hosts.iter().cloned());
4940

50-
// Reporting task only exists for NiFi 1.x
51-
if cluster.image.product_version.starts_with("1.") {
52-
let reporting_task_service_name = reporting_task::build_reporting_task_fqdn_service_name(
53-
cluster.name.as_ref(),
54-
&cluster.namespace,
55-
cluster_info,
56-
);
57-
58-
proxy_hosts.insert(format!("{reporting_task_service_name}:{HTTPS_PORT}"));
59-
}
60-
6141
let mut proxy_hosts = Vec::from_iter(proxy_hosts);
6242
proxy_hosts.sort();
6343

@@ -66,21 +46,9 @@ pub fn compute_proxy_hosts(
6646

6747
#[cfg(test)]
6848
mod tests {
69-
use std::str::FromStr;
70-
71-
use stackable_operator::{
72-
commons::networking::DomainName, utils::cluster_info::KubernetesClusterInfo,
73-
};
74-
7549
use super::compute_proxy_hosts;
7650
use crate::controller::build::properties::test_support::minimal_validated_cluster;
7751

78-
fn cluster_info() -> KubernetesClusterInfo {
79-
KubernetesClusterInfo {
80-
cluster_domain: DomainName::from_str("cluster.local").expect("valid cluster domain"),
81-
}
82-
}
83-
8452
/// `allow_all` short-circuits to `*` and ignores any additional allowed hosts.
8553
#[test]
8654
fn allow_all_returns_wildcard_and_ignores_additional_hosts() {
@@ -91,21 +59,21 @@ mod tests {
9159
.host_header_check
9260
.additional_allowed_hosts = vec!["ignored.example.com".to_string()];
9361

94-
assert_eq!(compute_proxy_hosts(&cluster, &cluster_info()), "*");
62+
assert_eq!(compute_proxy_hosts(&cluster), "*");
9563
}
9664

9765
/// Without `allow_all`, the listener placeholder is always present and user-provided hosts are
98-
/// merged in, sorted and comma-joined. On NiFi 2.x no reporting-task FQDN is added.
66+
/// merged in, sorted and comma-joined.
9967
#[test]
100-
fn explicit_hosts_include_listener_placeholder_on_nifi_2() {
68+
fn explicit_hosts_include_listener_placeholder() {
10169
let mut cluster = minimal_validated_cluster();
10270
cluster.cluster_config.host_header_check.allow_all = false;
10371
cluster
10472
.cluster_config
10573
.host_header_check
10674
.additional_allowed_hosts = vec!["extra.example.com".to_string()];
10775

108-
let hosts = compute_proxy_hosts(&cluster, &cluster_info());
76+
let hosts = compute_proxy_hosts(&cluster);
10977

11078
assert!(
11179
hosts.contains("${env:LISTENER_DEFAULT_ADDRESS}:${env:LISTENER_DEFAULT_PORT_HTTPS}"),
@@ -115,25 +83,5 @@ mod tests {
11583
hosts.contains("extra.example.com"),
11684
"expected the additional host in {hosts}"
11785
);
118-
// No reporting-task FQDN on NiFi 2.x.
119-
assert!(
120-
!hosts.contains("cluster.local"),
121-
"did not expect a reporting-task FQDN on NiFi 2.x in {hosts}"
122-
);
123-
}
124-
125-
/// On NiFi 1.x the reporting-task FQDN (which embeds the cluster domain) is added.
126-
#[test]
127-
fn nifi_1_adds_reporting_task_fqdn() {
128-
let mut cluster = minimal_validated_cluster();
129-
cluster.cluster_config.host_header_check.allow_all = false;
130-
cluster.image.product_version = "1.27.0".to_string();
131-
132-
let hosts = compute_proxy_hosts(&cluster, &cluster_info());
133-
134-
assert!(
135-
hosts.contains("cluster.local"),
136-
"expected the reporting-task FQDN on NiFi 1.x in {hosts}"
137-
);
13886
}
13987
}

0 commit comments

Comments
 (0)