Skip to content

chore: Version CRD and HiveClusterConfig #571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
324 changes: 278 additions & 46 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions 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 All @@ -10,6 +10,10 @@ edition = "2021"
repository = "https://github.com/stackabletech/hive-operator"

[workspace.dependencies]
stackable-versioned = { git = "https://github.com/stackabletech/operator-rs.git", features = ["k8s"], tag = "stackable-versioned-0.5.0" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.85.0" }
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }

anyhow = "1.0"
built = { version = "0.7", features = ["chrono", "git2"] }
clap = "4.5"
Expand All @@ -24,8 +28,6 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
snafu = "0.8"
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.85.0" }
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
strum = { version = "0.26", features = ["derive"] }
tokio = { version = "1.40", features = ["full"] }
tracing = "0.1"
Expand Down
22 changes: 0 additions & 22 deletions rust/crd/Cargo.toml

This file was deleted.

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

[dependencies]
stackable-hive-crd = { path = "../crd" }
stackable-versioned.workspace = true
stackable-operator.workspace = true
product-config.workspace = true

anyhow.workspace = true
clap.workspace = true
Expand All @@ -22,11 +24,13 @@ semver.workspace = true
serde.workspace = true
serde_json.workspace = true
snafu.workspace = true
stackable-operator.workspace = true
product-config.workspace = true
strum.workspace = true
tokio.workspace = true
tracing.workspace = true

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

[build-dependencies]
built.workspace = true
11 changes: 6 additions & 5 deletions rust/operator-binary/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use stackable_hive_crd::{
HiveCluster, DB_PASSWORD_ENV, DB_PASSWORD_PLACEHOLDER, DB_USERNAME_ENV,
DB_USERNAME_PLACEHOLDER, HIVE_METASTORE_LOG4J2_PROPERTIES, HIVE_SITE_XML, STACKABLE_CONFIG_DIR,
use stackable_operator::commons::s3::S3ConnectionSpec;

use crate::crd::{
v1alpha1, DB_PASSWORD_ENV, DB_PASSWORD_PLACEHOLDER, DB_USERNAME_ENV, DB_USERNAME_PLACEHOLDER,
HIVE_METASTORE_LOG4J2_PROPERTIES, HIVE_SITE_XML, STACKABLE_CONFIG_DIR,
STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_TRUST_STORE,
STACKABLE_TRUST_STORE_PASSWORD, SYSTEM_TRUST_STORE, SYSTEM_TRUST_STORE_PASSWORD,
};
use stackable_operator::commons::s3::S3ConnectionSpec;

pub fn build_container_command_args(
hive: &HiveCluster,
hive: &v1alpha1::HiveCluster,
start_command: String,
s3_connection_spec: Option<&S3ConnectionSpec>,
) -> Vec<String> {
Expand Down
52 changes: 27 additions & 25 deletions rust/operator-binary/src/controller.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Ensures that `Pod`s are configured and running for each [`HiveCluster`]
//! Ensures that `Pod`s are configured and running for each [`v1alpha1::HiveCluster`]

use std::{
borrow::Cow,
collections::{BTreeMap, HashMap},
Expand All @@ -15,14 +16,6 @@ use product_config::{
ProductConfigManager,
};
use snafu::{OptionExt, ResultExt, Snafu};
use stackable_hive_crd::{
Container, HiveCluster, HiveClusterStatus, HiveRole, MetaStoreConfig, APP_NAME, CORE_SITE_XML,
DB_PASSWORD_ENV, DB_USERNAME_ENV, HADOOP_HEAPSIZE, HIVE_ENV_SH, HIVE_PORT, HIVE_PORT_NAME,
HIVE_SITE_XML, JVM_HEAP_FACTOR, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT, METRICS_PORT_NAME,
STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME, STACKABLE_CONFIG_MOUNT_DIR,
STACKABLE_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_CONFIG_MOUNT_DIR,
STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_DIR, STACKABLE_LOG_DIR_NAME,
};
use stackable_operator::{
builder::{
self,
Expand Down Expand Up @@ -86,6 +79,15 @@ use tracing::warn;

use crate::{
command::build_container_command_args,
crd::{
v1alpha1, Container, HiveClusterStatus, HiveRole, MetaStoreConfig, APP_NAME, CORE_SITE_XML,
DB_PASSWORD_ENV, DB_USERNAME_ENV, HADOOP_HEAPSIZE, HIVE_ENV_SH, HIVE_PORT, HIVE_PORT_NAME,
HIVE_SITE_XML, JVM_HEAP_FACTOR, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT,
METRICS_PORT_NAME, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME,
STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_CONFIG_MOUNT_DIR_NAME,
STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_DIR,
STACKABLE_LOG_DIR_NAME,
},
discovery,
kerberos::{
self, add_kerberos_pod_config, kerberos_config_properties,
Expand Down Expand Up @@ -128,7 +130,7 @@ pub enum Error {

#[snafu(display("failed to calculate service name for role {rolegroup}"))]
RoleGroupServiceNameNotFound {
rolegroup: RoleGroupRef<HiveCluster>,
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
},

#[snafu(display("failed to apply global Service"))]
Expand All @@ -139,25 +141,25 @@ pub enum Error {
#[snafu(display("failed to apply Service for {rolegroup}"))]
ApplyRoleGroupService {
source: stackable_operator::cluster_resources::Error,
rolegroup: RoleGroupRef<HiveCluster>,
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
},

#[snafu(display("failed to build ConfigMap for {rolegroup}"))]
BuildRoleGroupConfig {
source: stackable_operator::builder::configmap::Error,
rolegroup: RoleGroupRef<HiveCluster>,
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
},

#[snafu(display("failed to apply ConfigMap for {rolegroup}"))]
ApplyRoleGroupConfig {
source: stackable_operator::cluster_resources::Error,
rolegroup: RoleGroupRef<HiveCluster>,
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
},

#[snafu(display("failed to apply StatefulSet for {rolegroup}"))]
ApplyRoleGroupStatefulSet {
source: stackable_operator::cluster_resources::Error,
rolegroup: RoleGroupRef<HiveCluster>,
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
},

#[snafu(display("failed to generate product config"))]
Expand Down Expand Up @@ -200,7 +202,7 @@ pub enum Error {
S3TlsNoVerificationNotSupported,

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

#[snafu(display("invalid java heap config - missing default or value in crd?"))]
InvalidJavaHeapConfig,
Expand Down Expand Up @@ -254,7 +256,7 @@ pub enum Error {
},

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

#[snafu(display(
"failed to serialize [{JVM_SECURITY_PROPERTIES_FILE}] for {}",
Expand Down Expand Up @@ -336,7 +338,7 @@ impl ReconcilerError for Error {
}

pub async fn reconcile_hive(
hive: Arc<DeserializeGuard<HiveCluster>>,
hive: Arc<DeserializeGuard<v1alpha1::HiveCluster>>,
ctx: Arc<Ctx>,
) -> Result<Action> {
tracing::info!("Starting reconcile");
Expand Down Expand Up @@ -554,7 +556,7 @@ pub async fn reconcile_hive(
/// The server-role service is the primary endpoint that should be used by clients that do not
/// perform internal load balancing including targets outside of the cluster.
pub fn build_metastore_role_service(
hive: &HiveCluster,
hive: &v1alpha1::HiveCluster,
resolved_product_image: &ResolvedProductImage,
) -> Result<Service> {
let role_name = HiveRole::MetaStore.to_string();
Expand Down Expand Up @@ -593,10 +595,10 @@ pub fn build_metastore_role_service(
/// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the administrator
#[allow(clippy::too_many_arguments)]
fn build_metastore_rolegroup_config_map(
hive: &HiveCluster,
hive: &v1alpha1::HiveCluster,
hive_namespace: &str,
resolved_product_image: &ResolvedProductImage,
rolegroup: &RoleGroupRef<HiveCluster>,
rolegroup: &RoleGroupRef<v1alpha1::HiveCluster>,
role_group_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
s3_connection_spec: Option<&S3ConnectionSpec>,
merged_config: &MetaStoreConfig,
Expand Down Expand Up @@ -766,9 +768,9 @@ fn build_metastore_rolegroup_config_map(
///
/// This is mostly useful for internal communication between peers, or for clients that perform client-side load balancing.
fn build_rolegroup_service(
hive: &HiveCluster,
hive: &v1alpha1::HiveCluster,
resolved_product_image: &ResolvedProductImage,
rolegroup: &RoleGroupRef<HiveCluster>,
rolegroup: &RoleGroupRef<v1alpha1::HiveCluster>,
) -> Result<Service> {
Ok(Service {
metadata: ObjectMetaBuilder::new()
Expand Down Expand Up @@ -808,10 +810,10 @@ fn build_rolegroup_service(
/// corresponding [`Service`] (from [`build_rolegroup_service`]).
#[allow(clippy::too_many_arguments)]
fn build_metastore_rolegroup_statefulset(
hive: &HiveCluster,
hive: &v1alpha1::HiveCluster,
hive_role: &HiveRole,
resolved_product_image: &ResolvedProductImage,
rolegroup_ref: &RoleGroupRef<HiveCluster>,
rolegroup_ref: &RoleGroupRef<v1alpha1::HiveCluster>,
metastore_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
s3_connection: Option<&S3ConnectionSpec>,
merged_config: &MetaStoreConfig,
Expand Down Expand Up @@ -1143,7 +1145,7 @@ fn env_var_from_secret(var_name: &str, secret: &str, secret_key: &str) -> EnvVar
}

pub fn error_policy(
_obj: Arc<DeserializeGuard<HiveCluster>>,
_obj: Arc<DeserializeGuard<v1alpha1::HiveCluster>>,
error: &Error,
_ctx: Arc<Ctx>,
) -> Action {
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::{HiveRole, APP_NAME};
use crate::crd::{HiveRole, APP_NAME};

pub fn get_affinity(cluster_name: &str, role: &HiveRole) -> StackableAffinityFragment {
StackableAffinityFragment {
Expand Down Expand Up @@ -33,7 +33,7 @@ mod tests {
};

use super::*;
use crate::HiveCluster;
use crate::crd::v1alpha1;

#[rstest]
#[case(HiveRole::MetaStore)]
Expand All @@ -56,7 +56,7 @@ mod tests {
default:
replicas: 1
"#;
let hive: HiveCluster = serde_yaml::from_str(input).expect("illegal test input");
let hive: v1alpha1::HiveCluster = serde_yaml::from_str(input).expect("illegal test input");
let merged_config = hive
.merged_config(&role, &role.rolegroup_ref(&hive, "default"))
.unwrap();
Expand Down
Loading