Skip to content

Commit e5b7325

Browse files
fix: Disable 8081 (metrics) for 2xx (#794)
* Adding if clause to deactivate service port metrics if nifi 2.x.x is deployed * Add container port only if nifi 1xx * remove mut from container_nifi * Adding interface.lo to nifi.properties * Adapting startup and liveness probe * Removing old bash options * Removing uneccessary imports * Adding docs for portforwarding * Update docs/modules/nifi/pages/troubleshooting/index.adoc Co-authored-by: Malte Sander <[email protected]> * Update rust/operator-binary/src/controller.rs Co-authored-by: Malte Sander <[email protected]> * Removing property and add documentation * Apply suggestions from code review Adding review comments Co-authored-by: Malte Sander <[email protected]> * remove docs, not good enough solution * REmove leftover * Adding changelog * removing newline --------- Co-authored-by: Malte Sander <[email protected]>
1 parent f86bd96 commit e5b7325

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file.
2626
- BREAKING: Inject the vector aggregator address into the vector config using the env var `VECTOR_AGGREGATOR_ADDRESS` instead
2727
of having the operator write it to the vector config ([#772]).
2828
- test: Bump to Vector `0.46.1` ([#789]).
29+
- The ReportingTask metrics ports now is only exposed in NiFi 1.x.x ([#794])
2930
- BREAKING: Previously this operator would hardcode the UID and GID of the Pods being created to 1000/0, this has changed now ([#801])
3031
- The `runAsUser` and `runAsGroup` fields will not be set anymore by the operator
3132
- The defaults from the docker images itself will now apply, which will be different from 1000/0 going forward
@@ -52,6 +53,7 @@ All notable changes to this project will be documented in this file.
5253
[#787]: https://github.com/stackabletech/nifi-operator/pull/787
5354
[#789]: https://github.com/stackabletech/nifi-operator/pull/789
5455
[#793]: https://github.com/stackabletech/nifi-operator/pull/793
56+
[#794]: https://github.com/stackabletech/nifi-operator/pull/794
5557
[#799]: https://github.com/stackabletech/nifi-operator/pull/799
5658
[#801]: https://github.com/stackabletech/nifi-operator/pull/801
5759

rust/operator-binary/src/controller.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,23 @@ fn build_node_rolegroup_service(
846846
resolved_product_image: &ResolvedProductImage,
847847
rolegroup: &RoleGroupRef<v1alpha1::NifiCluster>,
848848
) -> Result<Service> {
849+
let mut enabled_ports = vec![ServicePort {
850+
name: Some(HTTPS_PORT_NAME.to_string()),
851+
port: HTTPS_PORT.into(),
852+
protocol: Some("TCP".to_string()),
853+
..ServicePort::default()
854+
}];
855+
856+
// NiFi 2.x.x offers nifi-api/flow/metrics/prometheus at the HTTPS_PORT, therefore METRICS_PORT is only required for NiFi 1.x.x...
857+
if resolved_product_image.product_version.starts_with("1.") {
858+
enabled_ports.push(ServicePort {
859+
name: Some(METRICS_PORT_NAME.to_string()),
860+
port: METRICS_PORT.into(),
861+
protocol: Some("TCP".to_string()),
862+
..ServicePort::default()
863+
})
864+
}
865+
849866
Ok(Service {
850867
metadata: ObjectMetaBuilder::new()
851868
.name_and_namespace(nifi)
@@ -865,20 +882,7 @@ fn build_node_rolegroup_service(
865882
// Internal communication does not need to be exposed
866883
type_: Some("ClusterIP".to_string()),
867884
cluster_ip: Some("None".to_string()),
868-
ports: Some(vec![
869-
ServicePort {
870-
name: Some(HTTPS_PORT_NAME.to_string()),
871-
port: HTTPS_PORT.into(),
872-
protocol: Some("TCP".to_string()),
873-
..ServicePort::default()
874-
},
875-
ServicePort {
876-
name: Some(METRICS_PORT_NAME.to_string()),
877-
port: METRICS_PORT.into(),
878-
protocol: Some("TCP".to_string()),
879-
..ServicePort::default()
880-
},
881-
]),
885+
ports: Some(enabled_ports),
882886
selector: Some(
883887
Labels::role_group_selector(nifi, APP_NAME, &rolegroup.role, &rolegroup.role_group)
884888
.context(LabelBuildSnafu)?
@@ -1187,7 +1191,6 @@ async fn build_node_rolegroup_statefulset(
11871191
.add_container_port(HTTPS_PORT_NAME, HTTPS_PORT.into())
11881192
.add_container_port(PROTOCOL_PORT_NAME, PROTOCOL_PORT.into())
11891193
.add_container_port(BALANCE_PORT_NAME, BALANCE_PORT.into())
1190-
.add_container_port(METRICS_PORT_NAME, METRICS_PORT.into())
11911194
.liveness_probe(Probe {
11921195
initial_delay_seconds: Some(10),
11931196
period_seconds: Some(10),
@@ -1209,6 +1212,11 @@ async fn build_node_rolegroup_statefulset(
12091212
})
12101213
.resources(merged_config.resources.clone().into());
12111214

1215+
// NiFi 2.x.x offers nifi-api/flow/metrics/prometheus at the HTTPS_PORT, therefore METRICS_PORT is only required for NiFi 1.x.x.
1216+
if resolved_product_image.product_version.starts_with("1.") {
1217+
container_nifi.add_container_port(METRICS_PORT_NAME, METRICS_PORT.into());
1218+
}
1219+
12121220
let mut pod_builder = PodBuilder::new();
12131221
add_graceful_shutdown_config(merged_config, &mut pod_builder).context(GracefulShutdownSnafu)?;
12141222

0 commit comments

Comments
 (0)