Skip to content

Commit

Permalink
chore: Remove separate CRD crate
Browse files Browse the repository at this point in the history
  • Loading branch information
Techassi committed Feb 7, 2025
1 parent 0191244 commit 3a43ee6
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 94 deletions.
27 changes: 6 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["rust/crd", "rust/operator-binary"]
members = ["rust/operator-binary"]
resolver = "2"

[workspace.package]
Expand Down
23 changes: 0 additions & 23 deletions rust/crd/Cargo.toml

This file was deleted.

3 changes: 2 additions & 1 deletion rust/operator-binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository.workspace = true
publish = false

[dependencies]
stackable-kafka-crd = { path = "../crd" }
indoc.workspace = true
anyhow.workspace = true
clap.workspace = true
const_format.workspace = true
Expand All @@ -25,6 +25,7 @@ tracing.workspace = true

[dev-dependencies]
serde_yaml.workspace = true
rstest.workspace = true

[build-dependencies]
built.workspace = true
Expand Down
12 changes: 6 additions & 6 deletions rust/operator-binary/src/config/jvm.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use snafu::{OptionExt, ResultExt, Snafu};
use stackable_kafka_crd::{
KafkaConfig, KafkaConfigFragment, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT,
STACKABLE_CONFIG_DIR,
};
use stackable_operator::{
memory::{BinaryMultiple, MemoryQuantity},
role_utils::{self, GenericRoleConfig, JavaCommonConfig, JvmArgumentOverrides, Role},
};

use crate::crd::{
KafkaConfig, KafkaConfigFragment, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT,
STACKABLE_CONFIG_DIR,
};

const JAVA_HEAP_FACTOR: f32 = 0.8;

#[derive(Snafu, Debug)]
Expand Down Expand Up @@ -97,9 +98,8 @@ fn is_heap_jvm_argument(jvm_argument: &str) -> bool {

#[cfg(test)]
mod tests {
use stackable_kafka_crd::{KafkaCluster, KafkaRole};

use super::*;
use crate::crd::{KafkaCluster, KafkaRole};

#[test]
fn test_construct_jvm_arguments_defaults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use stackable_operator::{
k8s_openapi::api::core::v1::PodAntiAffinity,
};

use crate::{KafkaRole, APP_NAME};
use crate::crd::{KafkaRole, APP_NAME};

pub fn get_affinity(cluster_name: &str, role: &KafkaRole) -> StackableAffinityFragment {
StackableAffinityFragment {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use stackable_operator::{
schemars::{self, JsonSchema},
};

use crate::ObjectRef;
use crate::crd::ObjectRef;

pub const SUPPORTED_AUTHENTICATION_CLASS_PROVIDERS: [&str; 2] = ["TLS", "Kerberos"];

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use snafu::{OptionExt, Snafu};
use stackable_operator::{kube::ResourceExt, utils::cluster_info::KubernetesClusterInfo};
use strum::{EnumDiscriminants, EnumString};

use crate::{security::KafkaTlsSecurity, KafkaCluster, STACKABLE_LISTENER_BROKER_DIR};
use crate::crd::{security::KafkaTlsSecurity, KafkaCluster, STACKABLE_LISTENER_BROKER_DIR};

const LISTENER_LOCAL_ADDRESS: &str = "0.0.0.0";

Expand Down Expand Up @@ -273,7 +273,7 @@ mod tests {
};

use super::*;
use crate::authentication::ResolvedAuthenticationClasses;
use crate::crd::authentication::ResolvedAuthenticationClasses;

fn default_cluster_info() -> KubernetesClusterInfo {
KubernetesClusterInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use stackable_operator::{
};
use strum::{Display, EnumIter, EnumString, IntoEnumIterator};

use crate::{authorization::KafkaAuthorization, tls::KafkaTls};
use crate::crd::{authorization::KafkaAuthorization, tls::KafkaTls};

pub const DOCKER_IMAGE_BASE_NAME: &str = "kafka";
pub const APP_NAME: &str = "kafka";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use stackable_operator::{
utils::COMMON_BASH_TRAP_FUNCTIONS,
};

use crate::{
use crate::crd::{
authentication::{self, ResolvedAuthenticationClasses},
listener::{self, node_address_cmd, KafkaListenerConfig},
tls, KafkaCluster, KafkaRole, LISTENER_BOOTSTRAP_VOLUME_NAME, LISTENER_BROKER_VOLUME_NAME,
Expand Down
File renamed without changes.
7 changes: 5 additions & 2 deletions rust/operator-binary/src/discovery.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use std::num::TryFromIntError;

use snafu::{OptionExt, ResultExt, Snafu};
use stackable_kafka_crd::{security::KafkaTlsSecurity, KafkaCluster, KafkaRole};
use stackable_operator::{
builder::{configmap::ConfigMapBuilder, meta::ObjectMetaBuilder},
commons::{listener::Listener, product_image_selection::ResolvedProductImage},
k8s_openapi::api::core::v1::{ConfigMap, Service},
kube::{runtime::reflector::ObjectRef, Resource, ResourceExt},
};

use crate::{kafka_controller::KAFKA_CONTROLLER_NAME, utils::build_recommended_labels};
use crate::{
crd::{security::KafkaTlsSecurity, KafkaCluster, KafkaRole},
kafka_controller::KAFKA_CONTROLLER_NAME,
utils::build_recommended_labels,
};

#[derive(Snafu, Debug)]
pub enum Error {
Expand Down
38 changes: 16 additions & 22 deletions rust/operator-binary/src/kafka_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ use product_config::{
ProductConfigManager,
};
use snafu::{OptionExt, ResultExt, Snafu};
use stackable_kafka_crd::{
listener::{get_kafka_listener_config, pod_fqdn, KafkaListenerError},
security::KafkaTlsSecurity,
Container, KafkaCluster, KafkaClusterStatus, KafkaConfig, KafkaRole, APP_NAME,
DOCKER_IMAGE_BASE_NAME, JVM_SECURITY_PROPERTIES_FILE, KAFKA_HEAP_OPTS,
LISTENER_BOOTSTRAP_VOLUME_NAME, LISTENER_BROKER_VOLUME_NAME, LOG_DIRS_VOLUME_NAME,
METRICS_PORT, METRICS_PORT_NAME, OPERATOR_NAME, SERVER_PROPERTIES_FILE, STACKABLE_CONFIG_DIR,
STACKABLE_DATA_DIR, STACKABLE_LISTENER_BOOTSTRAP_DIR, STACKABLE_LISTENER_BROKER_DIR,
STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_DIR,
};
use stackable_operator::{
builder::{
self,
Expand Down Expand Up @@ -84,6 +74,16 @@ use strum::{EnumDiscriminants, IntoStaticStr};

use crate::{
config::jvm::{construct_heap_jvm_args, construct_non_heap_jvm_args},
crd::{
listener::{get_kafka_listener_config, pod_fqdn, KafkaListenerError},
security::KafkaTlsSecurity,
Container, KafkaCluster, KafkaClusterStatus, KafkaConfig, KafkaRole, APP_NAME,
DOCKER_IMAGE_BASE_NAME, JVM_SECURITY_PROPERTIES_FILE, KAFKA_HEAP_OPTS,
LISTENER_BOOTSTRAP_VOLUME_NAME, LISTENER_BROKER_VOLUME_NAME, LOG_DIRS_VOLUME_NAME,
METRICS_PORT, METRICS_PORT_NAME, OPERATOR_NAME, SERVER_PROPERTIES_FILE,
STACKABLE_CONFIG_DIR, STACKABLE_DATA_DIR, STACKABLE_LISTENER_BOOTSTRAP_DIR,
STACKABLE_LISTENER_BROKER_DIR, STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_DIR,
},
discovery::{self, build_discovery_configmaps},
kerberos::{self, add_kerberos_pod_config},
operations::{
Expand Down Expand Up @@ -221,7 +221,7 @@ pub enum Error {

#[snafu(display("invalid kafka listeners"))]
InvalidKafkaListeners {
source: stackable_kafka_crd::listener::KafkaListenerError,
source: crate::crd::listener::KafkaListenerError,
},

#[snafu(display("failed to add listener volume"))]
Expand All @@ -241,17 +241,15 @@ pub enum Error {
},

#[snafu(display("failed to initialize security context"))]
FailedToInitializeSecurityContext {
source: stackable_kafka_crd::security::Error,
},
FailedToInitializeSecurityContext { source: crate::crd::security::Error },

#[snafu(display("failed to create cluster resources"))]
CreateClusterResources {
source: stackable_operator::cluster_resources::Error,
},

#[snafu(display("failed to resolve and merge config for role and role group"))]
FailedToResolveConfig { source: stackable_kafka_crd::Error },
FailedToResolveConfig { source: crate::crd::Error },

#[snafu(display("failed to resolve the Vector aggregator address"))]
ResolveVectorAggregatorAddress {
Expand Down Expand Up @@ -285,7 +283,7 @@ pub enum Error {
},

#[snafu(display("internal operator failure"))]
InternalOperatorError { source: stackable_kafka_crd::Error },
InternalOperatorError { source: crate::crd::Error },

#[snafu(display(
"failed to serialize [{JVM_SECURITY_PROPERTIES_FILE}] for {}",
Expand Down Expand Up @@ -323,9 +321,7 @@ pub enum Error {
},

#[snafu(display("failed to add Secret Volumes and VolumeMounts"))]
AddVolumesAndVolumeMounts {
source: stackable_kafka_crd::security::Error,
},
AddVolumesAndVolumeMounts { source: crate::crd::security::Error },

#[snafu(display("failed to resolve the fully-qualified pod name"))]
ResolveNamespace { source: KafkaListenerError },
Expand All @@ -334,9 +330,7 @@ pub enum Error {
AddKerberosConfig { source: kerberos::Error },

#[snafu(display("failed to validate authentication method"))]
FailedToValidateAuthenticationMethod {
source: stackable_kafka_crd::security::Error,
},
FailedToValidateAuthenticationMethod { source: crate::crd::security::Error },

#[snafu(display("failed to add needed volume"))]
AddVolume { source: builder::pod::Error },
Expand Down
9 changes: 5 additions & 4 deletions rust/operator-binary/src/kerberos.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use snafu::{ResultExt, Snafu};
use stackable_kafka_crd::{
security::KafkaTlsSecurity, KafkaRole, LISTENER_BOOTSTRAP_VOLUME_NAME,
LISTENER_BROKER_VOLUME_NAME, STACKABLE_KERBEROS_DIR, STACKABLE_KERBEROS_KRB5_PATH,
};
use stackable_operator::builder::{
self,
pod::{
Expand All @@ -15,6 +11,11 @@ use stackable_operator::builder::{
},
};

use crate::crd::{
security::KafkaTlsSecurity, KafkaRole, LISTENER_BOOTSTRAP_VOLUME_NAME,
LISTENER_BROKER_VOLUME_NAME, STACKABLE_KERBEROS_DIR, STACKABLE_KERBEROS_KRB5_PATH,
};

#[derive(Snafu, Debug)]
pub enum Error {
#[snafu(display("failed to add Kerberos secret volume"))]
Expand Down
7 changes: 5 additions & 2 deletions rust/operator-binary/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::sync::Arc;
use clap::{crate_description, crate_version, Parser};
use futures::StreamExt;
use product_config::ProductConfigManager;
use stackable_kafka_crd::{KafkaCluster, APP_NAME, OPERATOR_NAME};
use stackable_operator::{
cli::{Command, ProductOperatorRun},
client::{self, Client},
Expand All @@ -25,9 +24,13 @@ use stackable_operator::{
CustomResourceExt,
};

use crate::kafka_controller::KAFKA_FULL_CONTROLLER_NAME;
use crate::{
crd::{KafkaCluster, APP_NAME, OPERATOR_NAME},
kafka_controller::KAFKA_FULL_CONTROLLER_NAME,
};

mod config;
mod crd;
mod discovery;
mod kafka_controller;
mod kerberos;
Expand Down
3 changes: 2 additions & 1 deletion rust/operator-binary/src/operations/graceful_shutdown.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::collections::BTreeMap;

use snafu::{ResultExt, Snafu};
use stackable_kafka_crd::KafkaConfig;
use stackable_operator::builder::pod::PodBuilder;

use crate::crd::KafkaConfig;

#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("Failed to set terminationGracePeriod"))]
Expand Down
6 changes: 4 additions & 2 deletions rust/operator-binary/src/operations/pdb.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use snafu::{ResultExt, Snafu};
use stackable_kafka_crd::{KafkaCluster, KafkaRole, APP_NAME, OPERATOR_NAME};
use stackable_operator::{
builder::pdb::PodDisruptionBudgetBuilder, client::Client, cluster_resources::ClusterResources,
commons::pdb::PdbConfig, kube::ResourceExt,
};

use crate::kafka_controller::KAFKA_CONTROLLER_NAME;
use crate::{
crd::{KafkaCluster, KafkaRole, APP_NAME, OPERATOR_NAME},
kafka_controller::KAFKA_CONTROLLER_NAME,
};

#[derive(Snafu, Debug)]
pub enum Error {
Expand Down
Loading

0 comments on commit 3a43ee6

Please sign in to comment.