Skip to content

Commit 43281b2

Browse files
authored
chore: Version CRD and NifiClusterConfig (#752)
* chore: Remove separate CRD crate * chore: Remove unused constant * chore: Version NifiCluster * docs: Fix invalid rustdoc reference * chore: Version NifiClusterConfig * chore: Move NifiCluster impl blocks
1 parent ebbea85 commit 43281b2

24 files changed

+1730
-571
lines changed

Cargo.lock

+272-42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

+1,137-203
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["rust/crd", "rust/operator-binary"]
2+
members = ["rust/operator-binary"]
33
resolver = "2"
44

55
[workspace.package]
@@ -10,6 +10,10 @@ edition = "2021"
1010
repository = "https://github.com/stackabletech/nifi-operator"
1111

1212
[workspace.dependencies]
13+
stackable-versioned = { git = "https://github.com/stackabletech/operator-rs.git", features = ["k8s"], tag = "stackable-versioned-0.5.0" }
14+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.85.0" }
15+
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
16+
1317
anyhow = "1.0"
1418
built = { version = "0.7", features = ["chrono", "git2"] }
1519
clap = "4.5"
@@ -18,15 +22,13 @@ fnv = "1.0"
1822
futures = { version = "0.3", features = ["compat"] }
1923
indoc = "2.0"
2024
pin-project = "1.1"
21-
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
2225
rand = "0.8"
2326
rstest = "0.24"
2427
semver = "1.0"
2528
serde = { version = "1.0", features = ["derive"] }
2629
serde_json = "1.0"
2730
serde_yaml = "0.9"
2831
snafu = "0.8"
29-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.85.0" }
3032
strum = { version = "0.26", features = ["derive"] }
3133
tokio = { version = "1.40", features = ["full"] }
3234
tracing = "0.1"

crate-hashes.json

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/helm/nifi-operator/crds/crds.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
name: v1alpha1
2121
schema:
2222
openAPIV3Schema:
23-
description: Auto-generated derived type for NifiSpec via `CustomResource`
23+
description: Auto-generated derived type for NifiClusterSpec via `CustomResource`
2424
properties:
2525
spec:
2626
description: A NiFi cluster stacklet. This resource is managed by the Stackable operator for Apache NiFi. Find more information on how to use it and the resources that the operator generates in the [operator documentation](https://docs.stackable.tech/home/nightly/nifi/).

rust/crd/Cargo.toml

-22
This file was deleted.

rust/operator-binary/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ repository.workspace = true
99
publish = false
1010

1111
[dependencies]
12-
stackable-nifi-crd = { path = "../crd" }
12+
stackable-versioned.workspace = true
13+
stackable-operator.workspace = true
14+
product-config.workspace = true
1315

1416
anyhow.workspace = true
1517
clap.workspace = true
@@ -23,8 +25,6 @@ semver.workspace = true
2325
serde.workspace = true
2426
serde_json.workspace = true
2527
snafu.workspace = true
26-
stackable-operator.workspace = true
27-
product-config.workspace = true
2828
strum.workspace = true
2929
tokio.workspace = true
3030
tracing.workspace = true

rust/operator-binary/src/config/jvm.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
use snafu::{OptionExt, ResultExt, Snafu};
2-
use stackable_nifi_crd::{NifiConfig, NifiConfigFragment};
32
use stackable_operator::{
43
memory::{BinaryMultiple, MemoryQuantity},
54
role_utils::{self, GenericRoleConfig, JavaCommonConfig, JvmArgumentOverrides, Role},
65
};
76

8-
use super::{JVM_SECURITY_PROPERTIES_FILE, NIFI_CONFIG_DIRECTORY};
7+
use crate::{
8+
config::{JVM_SECURITY_PROPERTIES_FILE, NIFI_CONFIG_DIRECTORY},
9+
crd::{NifiConfig, NifiConfigFragment},
10+
};
911

1012
// Part of memory resources allocated for Java heap
1113
const JAVA_HEAP_FACTOR: f32 = 0.8;

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ use std::{
66
use jvm::build_merged_jvm_config;
77
use product_config::{types::PropertyNameKind, ProductConfigManager};
88
use snafu::{ResultExt, Snafu};
9-
use stackable_nifi_crd::{
10-
NifiCluster, NifiConfig, NifiConfigFragment, NifiRole, NifiSpec, NifiStorageConfig, HTTPS_PORT,
11-
PROTOCOL_PORT,
12-
};
139
use stackable_operator::{
1410
commons::resources::Resources,
1511
memory::MemoryQuantity,
@@ -22,6 +18,10 @@ use stackable_operator::{
2218
use strum::{Display, EnumIter};
2319

2420
use crate::{
21+
crd::{
22+
v1alpha1, NifiConfig, NifiConfigFragment, NifiRole, NifiStorageConfig, HTTPS_PORT,
23+
PROTOCOL_PORT,
24+
},
2525
operations::graceful_shutdown::graceful_shutdown_config_properties,
2626
security::{
2727
authentication::{
@@ -135,7 +135,7 @@ pub fn build_bootstrap_conf(
135135

136136
/// Create the NiFi nifi.properties
137137
pub fn build_nifi_properties(
138-
spec: &NifiSpec,
138+
spec: &v1alpha1::NifiClusterSpec,
139139
resource_config: &Resources<NifiStorageConfig>,
140140
proxy_hosts: &str,
141141
auth_config: &NifiAuthenticationConfig,
@@ -616,7 +616,7 @@ pub fn build_state_management_xml() -> String {
616616
/// * `product_config` - The product config to validate and complement the user config.
617617
///
618618
pub fn validated_product_config(
619-
resource: &NifiCluster,
619+
resource: &v1alpha1::NifiCluster,
620620
version: &str,
621621
role: &Role<NifiConfigFragment, GenericRoleConfig, JavaCommonConfig>,
622622
product_config: &ProductConfigManager,
@@ -667,10 +667,9 @@ fn storage_quantity_to_nifi(quantity: MemoryQuantity) -> String {
667667
#[cfg(test)]
668668
mod tests {
669669
use indoc::indoc;
670-
use stackable_nifi_crd::NifiCluster;
671670

672671
use super::*;
673-
use crate::config::build_bootstrap_conf;
672+
use crate::{config::build_bootstrap_conf, crd::v1alpha1};
674673

675674
#[test]
676675
fn test_build_bootstrap_conf_defaults() {
@@ -792,7 +791,8 @@ mod tests {
792791
}
793792

794793
fn construct_bootstrap_conf(nifi_cluster: &str) -> String {
795-
let nifi: NifiCluster = serde_yaml::from_str(nifi_cluster).expect("illegal test input");
794+
let nifi: v1alpha1::NifiCluster =
795+
serde_yaml::from_str(nifi_cluster).expect("illegal test input");
796796

797797
let nifi_role = NifiRole::Node;
798798
let role = nifi.spec.nodes.as_ref().unwrap();

rust/operator-binary/src/controller.rs

+30-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! Ensures that `Pod`s are configured and running for each [`NifiCluster`]
1+
//! Ensures that `Pod`s are configured and running for each [`v1alpha1::NifiCluster`].
2+
23
use std::{
34
borrow::Cow,
45
collections::{BTreeMap, HashMap, HashSet},
@@ -13,12 +14,6 @@ use product_config::{
1314
ProductConfigManager,
1415
};
1516
use snafu::{OptionExt, ResultExt, Snafu};
16-
use stackable_nifi_crd::{
17-
authentication::AuthenticationClassResolved, Container, CurrentlySupportedListenerClasses,
18-
NifiCluster, NifiConfig, NifiConfigFragment, NifiRole, NifiStatus, APP_NAME, BALANCE_PORT,
19-
BALANCE_PORT_NAME, HTTPS_PORT, HTTPS_PORT_NAME, METRICS_PORT, METRICS_PORT_NAME, PROTOCOL_PORT,
20-
PROTOCOL_PORT_NAME, STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_DIR,
21-
};
2217
use stackable_operator::{
2318
builder::{
2419
self,
@@ -84,6 +79,13 @@ use crate::{
8479
validated_product_config, NifiRepository, JVM_SECURITY_PROPERTIES_FILE,
8580
NIFI_BOOTSTRAP_CONF, NIFI_CONFIG_DIRECTORY, NIFI_PROPERTIES, NIFI_STATE_MANAGEMENT_XML,
8681
},
82+
crd::{
83+
authentication::AuthenticationClassResolved, v1alpha1, Container,
84+
CurrentlySupportedListenerClasses, NifiConfig, NifiConfigFragment, NifiRole, NifiStatus,
85+
APP_NAME, BALANCE_PORT, BALANCE_PORT_NAME, HTTPS_PORT, HTTPS_PORT_NAME, METRICS_PORT,
86+
METRICS_PORT_NAME, PROTOCOL_PORT, PROTOCOL_PORT_NAME, STACKABLE_LOG_CONFIG_DIR,
87+
STACKABLE_LOG_DIR,
88+
},
8789
operations::{graceful_shutdown::add_graceful_shutdown_config, pdb::add_pdbs},
8890
product_logging::{extend_role_group_config_map, resolve_vector_aggregator_address},
8991
reporting_task::{self, build_maybe_reporting_task, build_reporting_task_service_name},
@@ -159,13 +161,13 @@ pub enum Error {
159161
#[snafu(display("failed to apply Service for {}", rolegroup))]
160162
ApplyRoleGroupService {
161163
source: stackable_operator::cluster_resources::Error,
162-
rolegroup: RoleGroupRef<NifiCluster>,
164+
rolegroup: RoleGroupRef<v1alpha1::NifiCluster>,
163165
},
164166

165167
#[snafu(display("failed to build ConfigMap for {}", rolegroup))]
166168
BuildRoleGroupConfig {
167169
source: stackable_operator::builder::configmap::Error,
168-
rolegroup: RoleGroupRef<NifiCluster>,
170+
rolegroup: RoleGroupRef<v1alpha1::NifiCluster>,
169171
},
170172

171173
#[snafu(display("object has no nodes defined"))]
@@ -174,13 +176,13 @@ pub enum Error {
174176
#[snafu(display("failed to apply ConfigMap for {}", rolegroup))]
175177
ApplyRoleGroupConfig {
176178
source: stackable_operator::cluster_resources::Error,
177-
rolegroup: RoleGroupRef<NifiCluster>,
179+
rolegroup: RoleGroupRef<v1alpha1::NifiCluster>,
178180
},
179181

180182
#[snafu(display("failed to apply StatefulSet for {}", rolegroup))]
181183
ApplyRoleGroupStatefulSet {
182184
source: stackable_operator::cluster_resources::Error,
183-
rolegroup: RoleGroupRef<NifiCluster>,
185+
rolegroup: RoleGroupRef<v1alpha1::NifiCluster>,
184186
},
185187

186188
#[snafu(display("failed to apply create ReportingTask service"))]
@@ -210,7 +212,7 @@ pub enum Error {
210212
#[snafu(display("Failed to find any nodes in cluster {obj_ref}",))]
211213
MissingNodes {
212214
source: stackable_operator::client::Error,
213-
obj_ref: ObjectRef<NifiCluster>,
215+
obj_ref: ObjectRef<v1alpha1::NifiCluster>,
214216
},
215217

216218
#[snafu(display("Failed to find service {obj_ref}"))]
@@ -235,7 +237,7 @@ pub enum Error {
235237
BuildProductConfig {
236238
#[snafu(source(from(config::Error, Box::new)))]
237239
source: Box<config::Error>,
238-
rolegroup: RoleGroupRef<NifiCluster>,
240+
rolegroup: RoleGroupRef<v1alpha1::NifiCluster>,
239241
},
240242

241243
#[snafu(display("illegal container name: [{container_name}]"))]
@@ -247,11 +249,11 @@ pub enum Error {
247249
#[snafu(display("failed to validate resources for {rolegroup}"))]
248250
ResourceValidation {
249251
source: fragment::ValidationError,
250-
rolegroup: RoleGroupRef<NifiCluster>,
252+
rolegroup: RoleGroupRef<v1alpha1::NifiCluster>,
251253
},
252254

253255
#[snafu(display("failed to resolve and merge config for role and role group"))]
254-
FailedToResolveConfig { source: stackable_nifi_crd::Error },
256+
FailedToResolveConfig { source: crate::crd::Error },
255257

256258
#[snafu(display("failed to resolve the Vector aggregator address"))]
257259
ResolveVectorAggregatorAddress {
@@ -295,7 +297,7 @@ pub enum Error {
295297

296298
#[snafu(display("Failed to resolve NiFi Authentication Configuration"))]
297299
FailedResolveNifiAuthenticationConfig {
298-
source: stackable_nifi_crd::authentication::Error,
300+
source: crate::crd::authentication::Error,
299301
},
300302

301303
#[snafu(display("failed to create PodDisruptionBudget"))]
@@ -365,7 +367,7 @@ pub enum VersionChangeState {
365367
}
366368

367369
pub async fn reconcile_nifi(
368-
nifi: Arc<DeserializeGuard<NifiCluster>>,
370+
nifi: Arc<DeserializeGuard<v1alpha1::NifiCluster>>,
369371
ctx: Arc<Ctx>,
370372
) -> Result<Action> {
371373
tracing::info!("Starting reconcile");
@@ -686,7 +688,7 @@ pub async fn reconcile_nifi(
686688
/// The node-role service is the primary endpoint that should be used by clients that do not
687689
/// perform internal load balancing including targets outside of the cluster.
688690
pub fn build_node_role_service(
689-
nifi: &NifiCluster,
691+
nifi: &v1alpha1::NifiCluster,
690692
resolved_product_image: &ResolvedProductImage,
691693
) -> Result<Service> {
692694
let role_name = NifiRole::Node.to_string();
@@ -732,11 +734,11 @@ pub fn build_node_role_service(
732734
/// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the administrator
733735
#[allow(clippy::too_many_arguments)]
734736
async fn build_node_rolegroup_config_map(
735-
nifi: &NifiCluster,
737+
nifi: &v1alpha1::NifiCluster,
736738
resolved_product_image: &ResolvedProductImage,
737739
nifi_auth_config: &NifiAuthenticationConfig,
738740
role: &Role<NifiConfigFragment, GenericRoleConfig, JavaCommonConfig>,
739-
rolegroup: &RoleGroupRef<NifiCluster>,
741+
rolegroup: &RoleGroupRef<v1alpha1::NifiCluster>,
740742
rolegroup_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
741743
merged_config: &NifiConfig,
742744
vector_aggregator_address: Option<&str>,
@@ -846,9 +848,9 @@ async fn build_node_rolegroup_config_map(
846848
///
847849
/// This is mostly useful for internal communication between peers, or for clients that perform client-side load balancing.
848850
fn build_node_rolegroup_service(
849-
nifi: &NifiCluster,
851+
nifi: &v1alpha1::NifiCluster,
850852
resolved_product_image: &ResolvedProductImage,
851-
rolegroup: &RoleGroupRef<NifiCluster>,
853+
rolegroup: &RoleGroupRef<v1alpha1::NifiCluster>,
852854
) -> Result<Service> {
853855
Ok(Service {
854856
metadata: ObjectMetaBuilder::new()
@@ -903,10 +905,10 @@ const USERDATA_MOUNTPOINT: &str = "/stackable/userdata";
903905
/// corresponding [`Service`] (from [`build_node_rolegroup_service`]).
904906
#[allow(clippy::too_many_arguments)]
905907
async fn build_node_rolegroup_statefulset(
906-
nifi: &NifiCluster,
908+
nifi: &v1alpha1::NifiCluster,
907909
resolved_product_image: &ResolvedProductImage,
908910
cluster_info: &KubernetesClusterInfo,
909-
rolegroup_ref: &RoleGroupRef<NifiCluster>,
911+
rolegroup_ref: &RoleGroupRef<v1alpha1::NifiCluster>,
910912
role: &Role<NifiConfigFragment, GenericRoleConfig, JavaCommonConfig>,
911913
rolegroup_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
912914
merged_config: &NifiConfig,
@@ -1476,7 +1478,7 @@ fn zookeeper_env_var(name: &str, configmap_name: &str) -> EnvVar {
14761478

14771479
async fn get_proxy_hosts(
14781480
client: &Client,
1479-
nifi: &NifiCluster,
1481+
nifi: &v1alpha1::NifiCluster,
14801482
nifi_service: &Service,
14811483
) -> Result<String> {
14821484
let host_header_check = nifi.spec.cluster_config.host_header_check.clone();
@@ -1541,7 +1543,7 @@ async fn get_proxy_hosts(
15411543
}
15421544

15431545
pub fn error_policy(
1544-
_obj: Arc<DeserializeGuard<NifiCluster>>,
1546+
_obj: Arc<DeserializeGuard<v1alpha1::NifiCluster>>,
15451547
error: &Error,
15461548
_ctx: Arc<Ctx>,
15471549
) -> Action {
@@ -1554,11 +1556,11 @@ pub fn error_policy(
15541556
}
15551557

15561558
pub fn build_recommended_labels<'a>(
1557-
owner: &'a NifiCluster,
1559+
owner: &'a v1alpha1::NifiCluster,
15581560
app_version: &'a str,
15591561
role: &'a str,
15601562
role_group: &'a str,
1561-
) -> ObjectLabels<'a, NifiCluster> {
1563+
) -> ObjectLabels<'a, v1alpha1::NifiCluster> {
15621564
ObjectLabels {
15631565
owner,
15641566
app_name: APP_NAME,

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use stackable_operator::{
33
k8s_openapi::api::core::v1::PodAntiAffinity,
44
};
55

6-
use crate::{NifiRole, APP_NAME};
6+
use crate::crd::{NifiRole, APP_NAME};
77

88
pub fn get_affinity(cluster_name: &str, role: &NifiRole) -> StackableAffinityFragment {
99
StackableAffinityFragment {
@@ -32,7 +32,7 @@ mod tests {
3232
};
3333

3434
use super::*;
35-
use crate::NifiCluster;
35+
use crate::crd::v1alpha1;
3636

3737
#[test]
3838
fn test_affinity_defaults() {
@@ -57,7 +57,7 @@ mod tests {
5757
replicas: 1
5858
"#;
5959
let deserializer = serde_yaml::Deserializer::from_str(input);
60-
let nifi: NifiCluster =
60+
let nifi: v1alpha1::NifiCluster =
6161
serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap();
6262
let merged_config = nifi.merged_config(&NifiRole::Node, "default").unwrap();
6363

0 commit comments

Comments
 (0)