Skip to content

chore: Update templated files (f1f1a9e) #587

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
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE/pre-release-rust-deps.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Bump Rust Dependencies for Stackable Release XX.(X)X
# Bump Rust Dependencies for Stackable Release YY.M.X

<!--
Make sure to update the link in 'issues/.github/ISSUE_TEMPLATE/pre-release-operator-rust-deps.md'
Expand Down Expand Up @@ -32,7 +32,7 @@ Part of <https://github.com/stackabletech/issues/issues/TRACKING_ISSUE>

```[tasklist]
### Bump Rust Dependencies
- [ ] Bump `stackable-operator` and friends.
- [ ] Bump `product-version`.
- [ ] Bump all other dependencies.
- [ ] Bump `stackable-operator` and friends
- [ ] Bump `product-config`
- [ ] Bump all other dependencies
```
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: '0'
CARGO_PROFILE_DEV_DEBUG: '0'
RUST_TOOLCHAIN_VERSION: "1.84.1"
RUST_TOOLCHAIN_VERSION: "1.85.0"
RUST_NIGHTLY_TOOLCHAIN_VERSION: "nightly-2025-01-15"
PYTHON_VERSION: "3.12"
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: "-D warnings"
Expand Down Expand Up @@ -136,9 +137,11 @@ jobs:
submodules: recursive
- uses: dtolnay/rust-toolchain@c5a29ddb4d9d194e7c84ec8c3fba61b1c31fee8c
with:
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN_VERSION }}
components: rustfmt
- run: cargo fmt --all -- --check
- env:
RUST_TOOLCHAIN_VERSION: ${{ env.RUST_NIGHTLY_TOOLCHAIN_VERSION }}
run: cargo "+$RUST_TOOLCHAIN_VERSION" fmt --all -- --check

run_clippy:
name: Run Clippy
Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rust-analyzer.rustfmt.overrideCommand": [
"rustfmt",
"+nightly-2025-01-15",
"--"
],
}
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# DO NOT EDIT, this file is generated by operator-templating
[toolchain]
channel = "1.84.1"
channel = "1.85.0"
27 changes: 17 additions & 10 deletions rust/operator-binary/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use stackable_operator::commons::s3::S3ConnectionSpec;

use crate::crd::{
v1alpha1, DB_PASSWORD_ENV, DB_PASSWORD_PLACEHOLDER, DB_USERNAME_ENV, DB_USERNAME_PLACEHOLDER,
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,
STACKABLE_TRUST_STORE_PASSWORD, SYSTEM_TRUST_STORE, SYSTEM_TRUST_STORE_PASSWORD, v1alpha1,
};

pub fn build_container_command_args(
Expand All @@ -16,17 +16,24 @@ pub fn build_container_command_args(
// copy config files to a writeable empty folder in order to set s3 access and secret keys
format!("echo copying {STACKABLE_CONFIG_MOUNT_DIR} to {STACKABLE_CONFIG_DIR}"),
format!("cp -RL {STACKABLE_CONFIG_MOUNT_DIR}/* {STACKABLE_CONFIG_DIR}"),

// Copy log4j2 properties
format!("echo copying {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES} to {STACKABLE_CONFIG_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES}"),
format!("cp -RL {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES} {STACKABLE_CONFIG_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES}"),

format!(
"echo copying {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES} to {STACKABLE_CONFIG_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES}"
),
format!(
"cp -RL {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES} {STACKABLE_CONFIG_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES}"
),
// Template config files
format!("if test -f {STACKABLE_CONFIG_DIR}/core-site.xml; then config-utils template {STACKABLE_CONFIG_DIR}/core-site.xml; fi"),
format!("if test -f {STACKABLE_CONFIG_DIR}/hive-site.xml; then config-utils template {STACKABLE_CONFIG_DIR}/hive-site.xml; fi"),

format!(
"if test -f {STACKABLE_CONFIG_DIR}/core-site.xml; then config-utils template {STACKABLE_CONFIG_DIR}/core-site.xml; fi"
),
format!(
"if test -f {STACKABLE_CONFIG_DIR}/hive-site.xml; then config-utils template {STACKABLE_CONFIG_DIR}/hive-site.xml; fi"
),
// Copy system truststore to stackable truststore
format!("keytool -importkeystore -srckeystore {SYSTEM_TRUST_STORE} -srcstoretype jks -srcstorepass {SYSTEM_TRUST_STORE_PASSWORD} -destkeystore {STACKABLE_TRUST_STORE} -deststoretype pkcs12 -deststorepass {STACKABLE_TRUST_STORE_PASSWORD} -noprompt")
format!(
"keytool -importkeystore -srckeystore {SYSTEM_TRUST_STORE} -srcstoretype jks -srcstorepass {SYSTEM_TRUST_STORE_PASSWORD} -destkeystore {STACKABLE_TRUST_STORE} -deststoretype pkcs12 -deststorepass {STACKABLE_TRUST_STORE_PASSWORD} -noprompt"
),
];

if hive.spec.cluster_config.hdfs.is_some() {
Expand Down
9 changes: 6 additions & 3 deletions rust/operator-binary/src/config/jvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use stackable_operator::{
};

use crate::crd::{
v1alpha1::HiveCluster, MetaStoreConfig, MetaStoreConfigFragment, JVM_SECURITY_PROPERTIES_FILE,
METRICS_PORT, STACKABLE_CONFIG_DIR, STACKABLE_TRUST_STORE, STACKABLE_TRUST_STORE_PASSWORD,
JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT, MetaStoreConfig, MetaStoreConfigFragment,
STACKABLE_CONFIG_DIR, STACKABLE_TRUST_STORE, STACKABLE_TRUST_STORE_PASSWORD,
v1alpha1::HiveCluster,
};

const JAVA_HEAP_FACTOR: f32 = 0.8;
Expand All @@ -33,7 +34,9 @@ fn construct_jvm_args(
) -> Result<Vec<String>, Error> {
let mut jvm_args = vec![
format!("-Djava.security.properties={STACKABLE_CONFIG_DIR}/{JVM_SECURITY_PROPERTIES_FILE}"),
format!("-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar={METRICS_PORT}:/stackable/jmx/jmx_hive_config.yaml"),
format!(
"-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar={METRICS_PORT}:/stackable/jmx/jmx_hive_config.yaml"
),
format!("-Djavax.net.ssl.trustStore={STACKABLE_TRUST_STORE}"),
format!("-Djavax.net.ssl.trustStorePassword={STACKABLE_TRUST_STORE_PASSWORD}"),
format!("-Djavax.net.ssl.trustStoreType=pkcs12"),
Expand Down
32 changes: 17 additions & 15 deletions rust/operator-binary/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use const_format::concatcp;
use fnv::FnvHasher;
use indoc::formatdoc;
use product_config::{
types::PropertyNameKind,
writer::{to_hadoop_xml, to_java_properties_string, PropertiesWriterError},
ProductConfigManager,
types::PropertyNameKind,
writer::{PropertiesWriterError, to_hadoop_xml, to_java_properties_string},
};
use snafu::{OptionExt, ResultExt, Snafu};
use stackable_operator::{
Expand All @@ -22,8 +22,8 @@ use stackable_operator::{
configmap::ConfigMapBuilder,
meta::ObjectMetaBuilder,
pod::{
container::ContainerBuilder, resources::ResourceRequirementsBuilder,
security::PodSecurityContextBuilder, volume::VolumeBuilder, PodBuilder,
PodBuilder, container::ContainerBuilder, resources::ResourceRequirementsBuilder,
security::PodSecurityContextBuilder, volume::VolumeBuilder,
},
},
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
Expand All @@ -34,6 +34,7 @@ use stackable_operator::{
tls_verification::TlsClientDetailsError,
},
k8s_openapi::{
DeepMerge,
api::{
apps::v1::{StatefulSet, StatefulSetSpec},
core::v1::{
Expand All @@ -44,12 +45,11 @@ use stackable_operator::{
apimachinery::pkg::{
api::resource::Quantity, apis::meta::v1::LabelSelector, util::intstr::IntOrString,
},
DeepMerge,
},
kube::{
core::{error_boundary, DeserializeGuard},
runtime::controller::Action,
Resource, ResourceExt,
core::{DeserializeGuard, error_boundary},
runtime::controller::Action,
},
kvp::{Label, Labels, ObjectLabels},
logging::controller::ReconcilerError,
Expand All @@ -58,7 +58,7 @@ use stackable_operator::{
product_logging::{
self,
framework::{
create_vector_shutdown_file_command, remove_vector_shutdown_file_command, LoggingError,
LoggingError, create_vector_shutdown_file_command, remove_vector_shutdown_file_command,
},
spec::{
ConfigMapLogConfig, ContainerLogConfig, ContainerLogConfigChoice,
Expand All @@ -71,21 +71,22 @@ use stackable_operator::{
statefulset::StatefulSetConditionBuilder,
},
time::Duration,
utils::{cluster_info::KubernetesClusterInfo, COMMON_BASH_TRAP_FUNCTIONS},
utils::{COMMON_BASH_TRAP_FUNCTIONS, cluster_info::KubernetesClusterInfo},
};
use strum::EnumDiscriminants;
use tracing::warn;

use crate::{
OPERATOR_NAME,
command::build_container_command_args,
config::jvm::{construct_hadoop_heapsize_env, construct_non_heap_jvm_args},
crd::{
v1alpha1, Container, HiveClusterStatus, HiveRole, MetaStoreConfig, APP_NAME, CORE_SITE_XML,
DB_PASSWORD_ENV, DB_USERNAME_ENV, HIVE_PORT, HIVE_PORT_NAME, HIVE_SITE_XML,
JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT, METRICS_PORT_NAME, STACKABLE_CONFIG_DIR,
APP_NAME, CORE_SITE_XML, Container, DB_PASSWORD_ENV, DB_USERNAME_ENV, HIVE_PORT,
HIVE_PORT_NAME, HIVE_SITE_XML, HiveClusterStatus, HiveRole, JVM_SECURITY_PROPERTIES_FILE,
METRICS_PORT, METRICS_PORT_NAME, MetaStoreConfig, 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,
STACKABLE_LOG_DIR_NAME, v1alpha1,
},
discovery,
kerberos::{
Expand All @@ -94,7 +95,6 @@ use crate::{
},
operations::{graceful_shutdown::add_graceful_shutdown_config, pdb::add_pdbs},
product_logging::{extend_role_group_config_map, resolve_vector_aggregator_address},
OPERATOR_NAME,
};

pub const HIVE_CONTROLLER_NAME: &str = "hivecluster";
Expand Down Expand Up @@ -872,7 +872,9 @@ fn build_metastore_rolegroup_statefulset(
//
// TODO: Once we drop support for HMS 3.1.x we can remove this condition and very likely get rid of the
// "bin/start-metastore" script.
format!("bin/start-metastore --config {STACKABLE_CONFIG_DIR} --db-type {db_type} --hive-bin-dir bin &")
format!(
"bin/start-metastore --config {STACKABLE_CONFIG_DIR} --db-type {db_type} --hive-bin-dir bin &"
)
} else {
// schematool versions 4.0.x (and above) support the `-initOrUpgradeSchema`, which is exactly what we need :)
// Some docs for the schemaTool can be found here: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=34835119
Expand Down
69 changes: 33 additions & 36 deletions rust/operator-binary/src/crd/affinity.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use stackable_operator::{
commons::affinity::{affinity_between_role_pods, StackableAffinityFragment},
commons::affinity::{StackableAffinityFragment, affinity_between_role_pods},
k8s_openapi::api::core::v1::PodAntiAffinity,
};

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

pub fn get_affinity(cluster_name: &str, role: &HiveRole) -> StackableAffinityFragment {
StackableAffinityFragment {
Expand Down Expand Up @@ -61,39 +61,36 @@ mod tests {
.merged_config(&role, &role.rolegroup_ref(&hive, "default"))
.unwrap();

assert_eq!(
merged_config.affinity,
StackableAffinity {
pod_affinity: None,
pod_anti_affinity: Some(PodAntiAffinity {
preferred_during_scheduling_ignored_during_execution: Some(vec![
WeightedPodAffinityTerm {
pod_affinity_term: PodAffinityTerm {
label_selector: Some(LabelSelector {
match_labels: Some(BTreeMap::from([
("app.kubernetes.io/name".to_string(), "hive".to_string(),),
(
"app.kubernetes.io/instance".to_string(),
"simple-hive".to_string(),
),
(
"app.kubernetes.io/component".to_string(),
"metastore".to_string(),
)
])),
..LabelSelector::default()
}),
topology_key: "kubernetes.io/hostname".to_string(),
..PodAffinityTerm::default()
},
weight: 70
}
]),
required_during_scheduling_ignored_during_execution: None,
}),
node_affinity: None,
node_selector: None,
}
);
assert_eq!(merged_config.affinity, StackableAffinity {
pod_affinity: None,
pod_anti_affinity: Some(PodAntiAffinity {
preferred_during_scheduling_ignored_during_execution: Some(vec![
WeightedPodAffinityTerm {
pod_affinity_term: PodAffinityTerm {
label_selector: Some(LabelSelector {
match_labels: Some(BTreeMap::from([
("app.kubernetes.io/name".to_string(), "hive".to_string(),),
(
"app.kubernetes.io/instance".to_string(),
"simple-hive".to_string(),
),
(
"app.kubernetes.io/component".to_string(),
"metastore".to_string(),
)
])),
..LabelSelector::default()
}),
topology_key: "kubernetes.io/hostname".to_string(),
..PodAffinityTerm::default()
},
weight: 70
}
]),
required_during_scheduling_ignored_during_execution: None,
}),
node_affinity: None,
node_selector: None,
});
}
}
10 changes: 5 additions & 5 deletions rust/operator-binary/src/crd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use stackable_operator::{
merge::Merge,
},
k8s_openapi::apimachinery::pkg::api::resource::Quantity,
kube::{runtime::reflector::ObjectRef, CustomResource, ResourceExt},
kube::{CustomResource, ResourceExt, runtime::reflector::ObjectRef},
product_config_utils::{self, Configuration},
product_logging::{self, spec::Logging},
role_utils::{GenericRoleConfig, JavaCommonConfig, Role, RoleGroup, RoleGroupRef},
Expand Down Expand Up @@ -451,20 +451,20 @@ pub struct MetaStoreConfig {
}

impl MetaStoreConfig {
pub const CONNECTION_DRIVER_NAME: &'static str = "javax.jdo.option.ConnectionDriverName";
pub const CONNECTION_PASSWORD: &'static str = "javax.jdo.option.ConnectionPassword";
// metastore
pub const CONNECTION_URL: &'static str = "javax.jdo.option.ConnectionURL";
pub const CONNECTION_DRIVER_NAME: &'static str = "javax.jdo.option.ConnectionDriverName";
pub const CONNECTION_USER_NAME: &'static str = "javax.jdo.option.ConnectionUserName";
pub const CONNECTION_PASSWORD: &'static str = "javax.jdo.option.ConnectionPassword";
pub const METASTORE_METRICS_ENABLED: &'static str = "hive.metastore.metrics.enabled";
pub const METASTORE_WAREHOUSE_DIR: &'static str = "hive.metastore.warehouse.dir";
pub const S3_ACCESS_KEY: &'static str = "fs.s3a.access.key";
// S3
pub const S3_ENDPOINT: &'static str = "fs.s3a.endpoint";
pub const S3_PATH_STYLE_ACCESS: &'static str = "fs.s3a.path.style.access";
pub const S3_REGION_NAME: &'static str = "fs.s3a.endpoint.region";
pub const S3_ACCESS_KEY: &'static str = "fs.s3a.access.key";
pub const S3_SECRET_KEY: &'static str = "fs.s3a.secret.key";
pub const S3_SSL_ENABLED: &'static str = "fs.s3a.connection.ssl.enabled";
pub const S3_PATH_STYLE_ACCESS: &'static str = "fs.s3a.path.style.access";

fn default_config(cluster_name: &str, role: &HiveRole) -> MetaStoreConfigFragment {
MetaStoreConfigFragment {
Expand Down
4 changes: 2 additions & 2 deletions rust/operator-binary/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use stackable_operator::{
builder::{configmap::ConfigMapBuilder, meta::ObjectMetaBuilder},
commons::product_image_selection::ResolvedProductImage,
k8s_openapi::api::core::v1::{ConfigMap, Endpoints, Service, ServiceSpec},
kube::{runtime::reflector::ObjectRef, Resource},
kube::{Resource, runtime::reflector::ObjectRef},
};

use crate::{
controller::build_recommended_labels,
crd::{v1alpha1, HiveRole, ServiceType, HIVE_PORT, HIVE_PORT_NAME},
crd::{HIVE_PORT, HIVE_PORT_NAME, HiveRole, ServiceType, v1alpha1},
};

#[derive(Snafu, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions rust/operator-binary/src/kerberos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ use stackable_operator::{
builder::{
self,
pod::{
PodBuilder,
container::ContainerBuilder,
volume::{
SecretOperatorVolumeSourceBuilder, SecretOperatorVolumeSourceBuilderError,
VolumeBuilder,
},
PodBuilder,
},
},
kube::ResourceExt,
utils::cluster_info::KubernetesClusterInfo,
};

use crate::crd::{v1alpha1, HiveRole, HIVE_SITE_XML, STACKABLE_CONFIG_DIR};
use crate::crd::{HIVE_SITE_XML, HiveRole, STACKABLE_CONFIG_DIR, v1alpha1};

#[derive(Snafu, Debug)]
#[allow(clippy::enum_variant_names)] // all variants have the same prefix: `Add`
Expand Down
Loading
Loading