Skip to content

Commit 1bf239e

Browse files
committed
feat: Improve startup times by setting flow.election.max.candidates
1 parent 99f9069 commit 1bf239e

22 files changed

Lines changed: 47 additions & 79 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ All notable changes to this project will be documented in this file.
2323
- test: Bump vector-aggregator to 0.55.0, replace /graphql call with gRPC call ([#940]).
2424
- BREAKING: Removed product-config machinery. This is a breaking change in terms of configuration.
2525
Users relying on the product-config `properties.yaml` file have to set these properties via the CRD ([#945]).
26+
- In case the user specifies a fixed number of NiFi nodes (i.e. no auto-scaling), set `nifi.cluster.flow.election.max.candidates` to that number.
27+
This results in much faster NiFi startups, as it doesn't need to wait for the 5 minutes of `nifi.cluster.flow.election.max.wait.time` ([#953]).
2628

2729
### Fixed
2830

@@ -38,6 +40,7 @@ All notable changes to this project will be documented in this file.
3840
[#936]: https://github.com/stackabletech/nifi-operator/pull/936
3941
[#940]: https://github.com/stackabletech/nifi-operator/pull/940
4042
[#945]: https://github.com/stackabletech/nifi-operator/pull/945
43+
[#953]: https://github.com/stackabletech/nifi-operator/pull/953
4144
[#959]: https://github.com/stackabletech/nifi-operator/pull/959
4245

4346
## [26.3.0] - 2026-03-16

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ tokio = { version = "1.52", features = ["full"] }
3333
tracing = "0.1"
3434
url = { version = "2.5.7" }
3535

36-
# [patch."https://github.com/stackabletech/operator-rs.git"]
37-
# stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
36+
[patch."https://github.com/stackabletech/operator-rs.git"]
37+
stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "refactor/replica-counting" }
3838
# stackable-operator = { path = "../operator-rs/crates/stackable-operator" }

docs/modules/nifi/assets/attachments/entraid-nifi.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ spec:
204204
nifi.security.user.oidc.additional.scopes: "profile"
205205
nifi.security.user.oidc.claim.identifying.user: "upn"
206206
nifi.process.group.root.placeholder: "root"
207-
nifi.cluster.flow.election.max.wait.time: "10 secs"
208207
podOverrides:
209208
spec:
210209
initContainers:

docs/modules/nifi/pages/usage_guide/overrides.adoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ For example per role group:
7171
nodes:
7272
roleGroups:
7373
default:
74-
config: {}
7574
replicas: 1
7675
envOverrides:
7776
MY_ENV_VAR: "MY_VALUE"
@@ -86,7 +85,6 @@ nodes:
8685
MY_ENV_VAR: "MY_VALUE"
8786
roleGroups:
8887
default:
89-
config: {}
9088
replicas: 1
9189
----
9290

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
use std::collections::BTreeMap;
44

55
use snafu::{ResultExt, Snafu, ensure};
6-
use stackable_operator::memory::MemoryQuantity;
6+
use stackable_operator::{
7+
memory::MemoryQuantity,
8+
role_utils::{ZeroReplicasCounting, fixed_replica_count},
9+
};
710

811
use super::{
912
ConfigFileName, env_reference, file_reference, format_properties,
@@ -21,7 +24,7 @@ use crate::{
2124
},
2225
},
2326
},
24-
crd::{storage::NifiRepository, v1alpha1},
27+
crd::{NifiRole, storage::NifiRepository, v1alpha1},
2528
security::{
2629
authentication::{
2730
NifiAuthenticationConfig, STACKABLE_SERVER_TLS_DIR, STACKABLE_TLS_STORE_PASSWORD,
@@ -526,9 +529,26 @@ pub fn build(
526529
"nifi.cluster.node.protocol.port".to_string(),
527530
PROTOCOL_PORT.to_string(),
528531
);
532+
533+
// In case the number of NiFi nodes is hard-coded to a fixed number (no auto-scaling), we can
534+
// tell this NiFi, so that startup is much quicker.
535+
let fixed_replica_count = fixed_replica_count(
536+
cluster
537+
.role_group_configs
538+
.get(&NifiRole::Node)
539+
.iter()
540+
.flat_map(|nodes| nodes.values())
541+
.map(|rg| rg.replicas),
542+
// We rather treat explicit 0 values as [`None`], so that we don't end up with too few nodes
543+
ZeroReplicasCounting::TreatAsZero,
544+
);
545+
let max_election_candidates = fixed_replica_count
546+
.map(|count| count.to_string())
547+
// In case we don't know the replica count, we set it to "" as that's what we always did
548+
.unwrap_or_default();
529549
properties.insert(
530550
"nifi.cluster.flow.election.max.candidates".to_string(),
531-
"".to_string(),
551+
max_election_candidates,
532552
);
533553

534554
match cluster.cluster_config.clustering_backend {

tests/templates/kuttl/cluster-sync-cs-bug/20-install-nifi.yaml.j2

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ spec:
186186
nifi.properties:
187187
nifi.web.https.sni.required: "false"
188188
nifi.web.https.sni.host.check: "false"
189-
# Quicker startup, and we only have a single node
190-
nifi.cluster.flow.election.max.wait.time: "10 secs"
191189
podOverrides:
192190
spec:
193191
initContainers:

tests/templates/kuttl/cluster_operation/20-install-nifi.yaml.j2

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ spec:
5050
gracefulShutdownTimeout: 1m
5151
logging:
5252
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
53-
configOverrides:
54-
"nifi.properties":
55-
# Quicker startup, and we only have a single node
56-
"nifi.cluster.flow.election.max.wait.time": "10 secs"
5753
roleGroups:
5854
default:
5955
replicas: 2

tests/templates/kuttl/custom-components-git-sync/30_install-nifi.yaml.j2

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ spec:
6767
config:
6868
logging:
6969
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
70-
configOverrides:
71-
"nifi.properties":
72-
# Quicker startup, and we only have a single node
73-
"nifi.cluster.flow.election.max.wait.time": "10 secs"
7470
roleConfig:
7571
listenerClass: external-unstable
7672
podOverrides:

tests/templates/kuttl/external-access/30_nifi.yaml.j2

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ spec:
5353
config:
5454
logging:
5555
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
56-
configOverrides:
57-
"nifi.properties":
58-
# Quicker startup, and we only have a single node
59-
"nifi.cluster.flow.election.max.wait.time": "10 secs"
6056
roleConfig:
6157
listenerClass: test-external-unstable-$NAMESPACE
6258
roleGroups:

0 commit comments

Comments
 (0)