Skip to content

Commit bf88cc1

Browse files
committed
address feedback from review
1 parent afc55ac commit bf88cc1

5 files changed

Lines changed: 19 additions & 129 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file.
77
### Added
88

99
- Add rolling upgrade support for upgrades between NiFi 2 versions ([#771]).
10-
- Added listener support for Nifi ([#784]).
10+
- Added Listener support for NiFi ([#784]).
1111
- Adds new telemetry CLI arguments and environment variables ([#782]).
1212
- Use `--file-log-max-files` (or `FILE_LOG_MAX_FILES`) to limit the number of log files kept.
1313
- Use `--file-log-rotation-period` (or `FILE_LOG_ROTATION_PERIOD`) to configure the frequency of rotation.

rust/operator-binary/src/controller.rs

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ pub enum Error {
140140
#[snafu(display("object defines no name"))]
141141
ObjectHasNoName,
142142

143-
#[snafu(display("object defines no spec"))]
144-
ObjectHasNoSpec,
145-
146143
#[snafu(display("object defines no namespace"))]
147144
ObjectHasNoNamespace,
148145

@@ -222,21 +219,12 @@ pub enum Error {
222219
#[snafu(display("Failed to find information about file [{}] in product config", kind))]
223220
ProductConfigKindNotSpecified { kind: String },
224221

225-
#[snafu(display("Failed to find any nodes in cluster {obj_ref}",))]
226-
MissingNodes {
227-
source: stackable_operator::client::Error,
228-
obj_ref: ObjectRef<v1alpha1::NifiCluster>,
229-
},
230-
231222
#[snafu(display("Failed to find service {obj_ref}"))]
232223
MissingService {
233224
source: stackable_operator::client::Error,
234225
obj_ref: ObjectRef<Service>,
235226
},
236227

237-
#[snafu(display("Failed to find an external port to use for proxy hosts"))]
238-
ExternalPort,
239-
240228
#[snafu(display("Could not build role service fqdn"))]
241229
NoRoleServiceFqdn,
242230

@@ -534,8 +522,7 @@ pub async fn reconcile_nifi(
534522
// Since we cannot predict which of the addresses a user might decide to use we will simply
535523
// add all of them to the setting for now.
536524
// For more information see <https://nifi.apache.org/docs/nifi-docs/html/administration-guide.html#proxy_configuration>
537-
// let proxy_hosts = get_proxy_hosts(client, nifi, &merged_config).await?;
538-
let proxy_hosts = get_proxy_hosts(client, nifi).await?;
525+
let proxy_hosts = get_proxy_hosts(client, nifi, &resolved_product_image).await?;
539526

540527
let rg_configmap = build_node_rolegroup_config_map(
541528
nifi,
@@ -1560,7 +1547,7 @@ async fn build_node_rolegroup_statefulset(
15601547
async fn get_proxy_hosts(
15611548
client: &Client,
15621549
nifi: &v1alpha1::NifiCluster,
1563-
// merged_config: &NifiConfig,
1550+
resolved_product_image: &ResolvedProductImage,
15641551
) -> Result<String> {
15651552
let host_header_check = nifi.spec.cluster_config.host_header_check.clone();
15661553

@@ -1576,27 +1563,24 @@ async fn get_proxy_hosts(
15761563
return Ok("*".to_string());
15771564
}
15781565

1579-
let node_role_service_fqdn = nifi
1580-
.node_role_service_fqdn(&client.kubernetes_cluster_info)
1581-
.context(NoRoleServiceFqdnSnafu)?;
1582-
let reporting_task_service_name = reporting_task::build_reporting_task_fqdn_service_name(
1583-
nifi,
1584-
&client.kubernetes_cluster_info,
1585-
)
1586-
.context(ReportingTaskSnafu)?;
1587-
let mut proxy_hosts_set = HashSet::from([
1588-
node_role_service_fqdn.clone(),
1589-
format!("{node_role_service_fqdn}:{HTTPS_PORT}"),
1590-
format!("{reporting_task_service_name}:{HTTPS_PORT}"),
1566+
// Address and port are injected from the listener volume during the prepare container
1567+
let mut proxy_hosts = HashSet::from([
1568+
"${env:LISTENER_DEFAULT_ADDRESS}:${env:LISTENER_DEFAULT_PORT_HTTPS}".to_string(),
15911569
]);
1570+
proxy_hosts.extend(host_header_check.additional_allowed_hosts);
15921571

1593-
proxy_hosts_set.extend(host_header_check.additional_allowed_hosts);
1572+
// Reporting task only exists for NiFi 1.x
1573+
if resolved_product_image.product_version.starts_with("1.") {
1574+
let reporting_task_service_name = reporting_task::build_reporting_task_fqdn_service_name(
1575+
nifi,
1576+
&client.kubernetes_cluster_info,
1577+
)
1578+
.context(ReportingTaskSnafu)?;
15941579

1595-
// Inject the address and port from the listener volume during the prepare container
1596-
proxy_hosts_set
1597-
.insert("${env:LISTENER_DEFAULT_ADDRESS}:${env:LISTENER_DEFAULT_PORT_HTTPS}".to_string());
1580+
proxy_hosts.insert(format!("{reporting_task_service_name}:{HTTPS_PORT}"));
1581+
}
15981582

1599-
let mut proxy_hosts = Vec::from_iter(proxy_hosts_set);
1583+
let mut proxy_hosts = Vec::from_iter(proxy_hosts);
16001584
proxy_hosts.sort();
16011585

16021586
Ok(proxy_hosts.join(","))

rust/operator-binary/src/crd/mod.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ pub mod affinity;
22
pub mod authentication;
33
pub mod sensitive_properties;
44
pub mod tls;
5-
pub mod utils;
65

7-
use std::collections::{BTreeMap, HashMap};
6+
use std::collections::BTreeMap;
87

98
use affinity::get_affinity;
109
use sensitive_properties::NifiSensitivePropertiesConfig;
@@ -46,7 +45,6 @@ use stackable_operator::{
4645
versioned::versioned,
4746
};
4847
use tls::NifiTls;
49-
use utils::PodRef;
5048

5149
pub const APP_NAME: &str = "nifi";
5250

@@ -84,9 +82,6 @@ pub enum Error {
8482

8583
#[snafu(display("object has no nodes defined"))]
8684
NoNodesDefined,
87-
88-
#[snafu(display("listener podrefs could not be resolved"))]
89-
ListenerPodRef { source: utils::Error },
9085
}
9186

9287
#[versioned(version(name = "v1alpha1"))]
@@ -250,36 +245,6 @@ impl v1alpha1::NifiCluster {
250245
&self.spec.cluster_config.tls.server_secret_class
251246
}
252247

253-
/// List all pods expected to form the cluster
254-
///
255-
/// We try to predict the pods here rather than looking at the current cluster state in order to
256-
/// avoid instance churn.
257-
pub fn pods(&self) -> Result<impl Iterator<Item = PodRef> + '_, Error> {
258-
let ns = self.metadata.namespace.clone().context(NoNamespaceSnafu)?;
259-
Ok(self
260-
.spec
261-
.nodes
262-
.iter()
263-
.flat_map(|role| &role.role_groups)
264-
// Order rolegroups consistently, to avoid spurious downstream rewrites
265-
.collect::<BTreeMap<_, _>>()
266-
.into_iter()
267-
.flat_map(move |(rolegroup_name, rolegroup)| {
268-
let rolegroup_ref = self.node_rolegroup_ref(rolegroup_name);
269-
let ns = ns.clone();
270-
(0..rolegroup.replicas.unwrap_or(0)).map(move |i| PodRef {
271-
namespace: ns.clone(),
272-
role_group_service_name: rolegroup_ref.object_name(),
273-
pod_name: format!("{}-{}", rolegroup_ref.object_name(), i),
274-
ports: HashMap::from([
275-
(HTTPS_PORT_NAME.to_owned(), HTTPS_PORT),
276-
(METRICS_PORT_NAME.to_owned(), METRICS_PORT),
277-
]),
278-
fqdn_override: None,
279-
})
280-
}))
281-
}
282-
283248
/// Retrieve and merge resource configs for role and role groups
284249
pub fn merged_config(&self, role: &NifiRole, role_group: &str) -> Result<NifiConfig, Error> {
285250
// Initialize the result with all default values as baseline

rust/operator-binary/src/crd/utils.rs

Lines changed: 0 additions & 59 deletions
This file was deleted.

tests/templates/kuttl/external-access/30-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: install-nifi
66
timeout: 300
77
commands:
8-
- script: kubectl -n $NAMESPACE wait --for=condition=available=true nificlusters.nifi.stackable.tech/nifi --timeout 301s
8+
- script: kubectl -n $NAMESPACE wait --for=condition=available=true nificlusters.nifi.stackable.tech/test-nifi --timeout 301s
99
---
1010
apiVersion: apps/v1
1111
kind: StatefulSet

0 commit comments

Comments
 (0)