Skip to content

Commit 8a9c5b9

Browse files
chore: Version CRD and HiveClusterConfig (#571)
* chore: Remove separate CRD crate * chore: Remove unused constant * chore: Version HiveCluster * chore: Move HiveCluster impl blocks * chore: Version HiveClusterConfig * chore: make regenerate-nix --------- Co-authored-by: Nick Larsen <nick.larsen@stackable.tech>
1 parent f584811 commit 8a9c5b9

File tree

17 files changed

+1724
-545
lines changed

17 files changed

+1724
-545
lines changed

Cargo.lock

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

Cargo.nix

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

Cargo.toml

Lines changed: 5 additions & 3 deletions
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/hive-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"
@@ -24,8 +28,6 @@ serde = { version = "1.0", features = ["derive"] }
2428
serde_json = "1.0"
2529
serde_yaml = "0.9"
2630
snafu = "0.8"
27-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.85.0" }
28-
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
2931
strum = { version = "0.26", features = ["derive"] }
3032
tokio = { version = "1.40", features = ["full"] }
3133
tracing = "0.1"

crate-hashes.json

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

rust/crd/Cargo.toml

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

rust/operator-binary/Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ repository.workspace = true
99
publish = false
1010

1111
[dependencies]
12-
stackable-hive-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
@@ -22,11 +24,13 @@ semver.workspace = true
2224
serde.workspace = true
2325
serde_json.workspace = true
2426
snafu.workspace = true
25-
stackable-operator.workspace = true
26-
product-config.workspace = true
2727
strum.workspace = true
2828
tokio.workspace = true
2929
tracing.workspace = true
3030

31+
[dev-dependencies]
32+
rstest.workspace = true
33+
serde_yaml.workspace = true
34+
3135
[build-dependencies]
3236
built.workspace = true

rust/operator-binary/src/command.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
use stackable_hive_crd::{
2-
HiveCluster, DB_PASSWORD_ENV, DB_PASSWORD_PLACEHOLDER, DB_USERNAME_ENV,
3-
DB_USERNAME_PLACEHOLDER, HIVE_METASTORE_LOG4J2_PROPERTIES, HIVE_SITE_XML, STACKABLE_CONFIG_DIR,
1+
use stackable_operator::commons::s3::S3ConnectionSpec;
2+
3+
use crate::crd::{
4+
v1alpha1, DB_PASSWORD_ENV, DB_PASSWORD_PLACEHOLDER, DB_USERNAME_ENV, DB_USERNAME_PLACEHOLDER,
5+
HIVE_METASTORE_LOG4J2_PROPERTIES, HIVE_SITE_XML, STACKABLE_CONFIG_DIR,
46
STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_TRUST_STORE,
57
STACKABLE_TRUST_STORE_PASSWORD, SYSTEM_TRUST_STORE, SYSTEM_TRUST_STORE_PASSWORD,
68
};
7-
use stackable_operator::commons::s3::S3ConnectionSpec;
89

910
pub fn build_container_command_args(
10-
hive: &HiveCluster,
11+
hive: &v1alpha1::HiveCluster,
1112
start_command: String,
1213
s3_connection_spec: Option<&S3ConnectionSpec>,
1314
) -> Vec<String> {

rust/operator-binary/src/controller.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! Ensures that `Pod`s are configured and running for each [`HiveCluster`]
1+
//! Ensures that `Pod`s are configured and running for each [`v1alpha1::HiveCluster`]
2+
23
use std::{
34
borrow::Cow,
45
collections::{BTreeMap, HashMap},
@@ -15,14 +16,6 @@ use product_config::{
1516
ProductConfigManager,
1617
};
1718
use snafu::{OptionExt, ResultExt, Snafu};
18-
use stackable_hive_crd::{
19-
Container, HiveCluster, HiveClusterStatus, HiveRole, MetaStoreConfig, APP_NAME, CORE_SITE_XML,
20-
DB_PASSWORD_ENV, DB_USERNAME_ENV, HADOOP_HEAPSIZE, HIVE_ENV_SH, HIVE_PORT, HIVE_PORT_NAME,
21-
HIVE_SITE_XML, JVM_HEAP_FACTOR, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT, METRICS_PORT_NAME,
22-
STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME, STACKABLE_CONFIG_MOUNT_DIR,
23-
STACKABLE_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_CONFIG_MOUNT_DIR,
24-
STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_DIR, STACKABLE_LOG_DIR_NAME,
25-
};
2619
use stackable_operator::{
2720
builder::{
2821
self,
@@ -86,6 +79,15 @@ use tracing::warn;
8679

8780
use crate::{
8881
command::build_container_command_args,
82+
crd::{
83+
v1alpha1, Container, HiveClusterStatus, HiveRole, MetaStoreConfig, APP_NAME, CORE_SITE_XML,
84+
DB_PASSWORD_ENV, DB_USERNAME_ENV, HADOOP_HEAPSIZE, HIVE_ENV_SH, HIVE_PORT, HIVE_PORT_NAME,
85+
HIVE_SITE_XML, JVM_HEAP_FACTOR, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT,
86+
METRICS_PORT_NAME, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME,
87+
STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_CONFIG_MOUNT_DIR_NAME,
88+
STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_DIR,
89+
STACKABLE_LOG_DIR_NAME,
90+
},
8991
discovery,
9092
kerberos::{
9193
self, add_kerberos_pod_config, kerberos_config_properties,
@@ -128,7 +130,7 @@ pub enum Error {
128130

129131
#[snafu(display("failed to calculate service name for role {rolegroup}"))]
130132
RoleGroupServiceNameNotFound {
131-
rolegroup: RoleGroupRef<HiveCluster>,
133+
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
132134
},
133135

134136
#[snafu(display("failed to apply global Service"))]
@@ -139,25 +141,25 @@ pub enum Error {
139141
#[snafu(display("failed to apply Service for {rolegroup}"))]
140142
ApplyRoleGroupService {
141143
source: stackable_operator::cluster_resources::Error,
142-
rolegroup: RoleGroupRef<HiveCluster>,
144+
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
143145
},
144146

145147
#[snafu(display("failed to build ConfigMap for {rolegroup}"))]
146148
BuildRoleGroupConfig {
147149
source: stackable_operator::builder::configmap::Error,
148-
rolegroup: RoleGroupRef<HiveCluster>,
150+
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
149151
},
150152

151153
#[snafu(display("failed to apply ConfigMap for {rolegroup}"))]
152154
ApplyRoleGroupConfig {
153155
source: stackable_operator::cluster_resources::Error,
154-
rolegroup: RoleGroupRef<HiveCluster>,
156+
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
155157
},
156158

157159
#[snafu(display("failed to apply StatefulSet for {rolegroup}"))]
158160
ApplyRoleGroupStatefulSet {
159161
source: stackable_operator::cluster_resources::Error,
160-
rolegroup: RoleGroupRef<HiveCluster>,
162+
rolegroup: RoleGroupRef<v1alpha1::HiveCluster>,
161163
},
162164

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

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

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

256258
#[snafu(display("internal operator failure"))]
257-
InternalOperatorError { source: stackable_hive_crd::Error },
259+
InternalOperatorError { source: crate::crd::Error },
258260

259261
#[snafu(display(
260262
"failed to serialize [{JVM_SECURITY_PROPERTIES_FILE}] for {}",
@@ -336,7 +338,7 @@ impl ReconcilerError for Error {
336338
}
337339

338340
pub async fn reconcile_hive(
339-
hive: Arc<DeserializeGuard<HiveCluster>>,
341+
hive: Arc<DeserializeGuard<v1alpha1::HiveCluster>>,
340342
ctx: Arc<Ctx>,
341343
) -> Result<Action> {
342344
tracing::info!("Starting reconcile");
@@ -554,7 +556,7 @@ pub async fn reconcile_hive(
554556
/// The server-role service is the primary endpoint that should be used by clients that do not
555557
/// perform internal load balancing including targets outside of the cluster.
556558
pub fn build_metastore_role_service(
557-
hive: &HiveCluster,
559+
hive: &v1alpha1::HiveCluster,
558560
resolved_product_image: &ResolvedProductImage,
559561
) -> Result<Service> {
560562
let role_name = HiveRole::MetaStore.to_string();
@@ -593,10 +595,10 @@ pub fn build_metastore_role_service(
593595
/// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the administrator
594596
#[allow(clippy::too_many_arguments)]
595597
fn build_metastore_rolegroup_config_map(
596-
hive: &HiveCluster,
598+
hive: &v1alpha1::HiveCluster,
597599
hive_namespace: &str,
598600
resolved_product_image: &ResolvedProductImage,
599-
rolegroup: &RoleGroupRef<HiveCluster>,
601+
rolegroup: &RoleGroupRef<v1alpha1::HiveCluster>,
600602
role_group_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
601603
s3_connection_spec: Option<&S3ConnectionSpec>,
602604
merged_config: &MetaStoreConfig,
@@ -766,9 +768,9 @@ fn build_metastore_rolegroup_config_map(
766768
///
767769
/// This is mostly useful for internal communication between peers, or for clients that perform client-side load balancing.
768770
fn build_rolegroup_service(
769-
hive: &HiveCluster,
771+
hive: &v1alpha1::HiveCluster,
770772
resolved_product_image: &ResolvedProductImage,
771-
rolegroup: &RoleGroupRef<HiveCluster>,
773+
rolegroup: &RoleGroupRef<v1alpha1::HiveCluster>,
772774
) -> Result<Service> {
773775
Ok(Service {
774776
metadata: ObjectMetaBuilder::new()
@@ -808,10 +810,10 @@ fn build_rolegroup_service(
808810
/// corresponding [`Service`] (from [`build_rolegroup_service`]).
809811
#[allow(clippy::too_many_arguments)]
810812
fn build_metastore_rolegroup_statefulset(
811-
hive: &HiveCluster,
813+
hive: &v1alpha1::HiveCluster,
812814
hive_role: &HiveRole,
813815
resolved_product_image: &ResolvedProductImage,
814-
rolegroup_ref: &RoleGroupRef<HiveCluster>,
816+
rolegroup_ref: &RoleGroupRef<v1alpha1::HiveCluster>,
815817
metastore_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
816818
s3_connection: Option<&S3ConnectionSpec>,
817819
merged_config: &MetaStoreConfig,
@@ -1143,7 +1145,7 @@ fn env_var_from_secret(var_name: &str, secret: &str, secret_key: &str) -> EnvVar
11431145
}
11441146

11451147
pub fn error_policy(
1146-
_obj: Arc<DeserializeGuard<HiveCluster>>,
1148+
_obj: Arc<DeserializeGuard<v1alpha1::HiveCluster>>,
11471149
error: &Error,
11481150
_ctx: Arc<Ctx>,
11491151
) -> Action {

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

Lines changed: 3 additions & 3 deletions
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::{HiveRole, APP_NAME};
6+
use crate::crd::{HiveRole, APP_NAME};
77

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

3535
use super::*;
36-
use crate::HiveCluster;
36+
use crate::crd::v1alpha1;
3737

3838
#[rstest]
3939
#[case(HiveRole::MetaStore)]
@@ -56,7 +56,7 @@ mod tests {
5656
default:
5757
replicas: 1
5858
"#;
59-
let hive: HiveCluster = serde_yaml::from_str(input).expect("illegal test input");
59+
let hive: v1alpha1::HiveCluster = serde_yaml::from_str(input).expect("illegal test input");
6060
let merged_config = hive
6161
.merged_config(&role, &role.rolegroup_ref(&hive, "default"))
6262
.unwrap();

0 commit comments

Comments
 (0)