Skip to content
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"
6 changes: 3 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,8 @@ use stackable_operator::{
};

use crate::crd::{
v1alpha1, AnyServiceConfig, HbaseRole, CONFIG_DIR_NAME, JVM_SECURITY_PROPERTIES_FILE,
METRICS_PORT,
AnyServiceConfig, CONFIG_DIR_NAME, HbaseRole, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT,
v1alpha1,
};

const JAVA_HEAP_FACTOR: f32 = 0.8;
Expand Down Expand Up @@ -144,7 +144,7 @@ fn is_heap_jvm_argument(jvm_argument: &str) -> bool {
#[cfg(test)]
mod tests {
use super::*;
use crate::crd::{v1alpha1, HbaseRole};
use crate::crd::{HbaseRole, v1alpha1};

#[test]
fn test_construct_jvm_arguments_defaults() {
Expand Down
78 changes: 36 additions & 42 deletions rust/operator-binary/src/crd/affinity.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use stackable_operator::{
commons::affinity::{
affinity_between_cluster_pods, affinity_between_role_pods, StackableAffinityFragment,
StackableAffinityFragment, affinity_between_cluster_pods, affinity_between_role_pods,
},
k8s_openapi::api::core::v1::{PodAffinity, PodAntiAffinity},
};

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

pub fn get_affinity(
cluster_name: &str,
Expand Down Expand Up @@ -186,45 +186,39 @@ mod tests {
HbaseRole::RestServer => (),
};

assert_eq!(
affinity,
StackableAffinity {
pod_affinity: Some(PodAffinity {
preferred_during_scheduling_ignored_during_execution: Some(expected_affinities),
required_during_scheduling_ignored_during_execution: None,
}),
pod_anti_affinity: Some(PodAntiAffinity {
preferred_during_scheduling_ignored_during_execution: Some(vec![
WeightedPodAffinityTerm {
pod_affinity_term: PodAffinityTerm {
label_selector: Some(LabelSelector {
match_expressions: None,
match_labels: Some(BTreeMap::from([
("app.kubernetes.io/name".to_string(), "hbase".to_string(),),
(
"app.kubernetes.io/instance".to_string(),
"simple-hbase".to_string(),
),
(
"app.kubernetes.io/component".to_string(),
role.to_string(),
)
]))
}),
match_label_keys: None,
mismatch_label_keys: None,
namespace_selector: None,
namespaces: None,
topology_key: "kubernetes.io/hostname".to_string(),
},
weight: 70
}
]),
required_during_scheduling_ignored_during_execution: None,
}),
node_affinity: None,
node_selector: None,
}
);
assert_eq!(affinity, StackableAffinity {
pod_affinity: Some(PodAffinity {
preferred_during_scheduling_ignored_during_execution: Some(expected_affinities),
required_during_scheduling_ignored_during_execution: None,
}),
pod_anti_affinity: Some(PodAntiAffinity {
preferred_during_scheduling_ignored_during_execution: Some(vec![
WeightedPodAffinityTerm {
pod_affinity_term: PodAffinityTerm {
label_selector: Some(LabelSelector {
match_expressions: None,
match_labels: Some(BTreeMap::from([
("app.kubernetes.io/name".to_string(), "hbase".to_string(),),
(
"app.kubernetes.io/instance".to_string(),
"simple-hbase".to_string(),
),
("app.kubernetes.io/component".to_string(), role.to_string(),)
]))
}),
match_label_keys: None,
mismatch_label_keys: None,
namespace_selector: None,
namespaces: None,
topology_key: "kubernetes.io/hostname".to_string(),
},
weight: 70
}
]),
required_during_scheduling_ignored_during_execution: None,
}),
node_affinity: None,
node_selector: None,
});
}
}
19 changes: 11 additions & 8 deletions rust/operator-binary/src/crd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use stackable_operator::{
merge::{Atomic, Merge},
},
k8s_openapi::{
DeepMerge,
api::core::v1::{EnvVar, PodTemplateSpec},
apimachinery::pkg::api::resource::Quantity,
DeepMerge,
},
kube::{runtime::reflector::ObjectRef, CustomResource, ResourceExt},
kube::{CustomResource, ResourceExt, runtime::reflector::ObjectRef},
product_config_utils::Configuration,
product_logging::{self, spec::Logging},
role_utils::{GenericRoleConfig, JavaCommonConfig, Role, RoleGroupRef},
Expand Down Expand Up @@ -640,15 +640,14 @@ pub enum HbaseRole {

impl HbaseRole {
const DEFAULT_MASTER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration = Duration::from_minutes_unchecked(20);
const DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
Duration::from_minutes_unchecked(60);
const DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
Duration::from_minutes_unchecked(5);

// Auto TLS certificate lifetime
const DEFAULT_MASTER_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(1);
const DEFAULT_REGION_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(1);
const DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
Duration::from_minutes_unchecked(60);
const DEFAULT_REST_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(1);
const DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT: Duration =
Duration::from_minutes_unchecked(5);

pub fn default_config(
&self,
Expand Down Expand Up @@ -1153,27 +1152,31 @@ impl AnyServiceConfig {
AnyServiceConfig::RestServer(config) => &config.resources,
}
}

pub fn logging(&self) -> &Logging<Container> {
match self {
AnyServiceConfig::Master(config) => &config.logging,
AnyServiceConfig::RegionServer(config) => &config.logging,
AnyServiceConfig::RestServer(config) => &config.logging,
}
}

pub fn affinity(&self) -> &StackableAffinity {
match self {
AnyServiceConfig::Master(config) => &config.affinity,
AnyServiceConfig::RegionServer(config) => &config.affinity,
AnyServiceConfig::RestServer(config) => &config.affinity,
}
}

pub fn graceful_shutdown_timeout(&self) -> &Option<Duration> {
match self {
AnyServiceConfig::Master(config) => &config.graceful_shutdown_timeout,
AnyServiceConfig::RegionServer(config) => &config.graceful_shutdown_timeout,
AnyServiceConfig::RestServer(config) => &config.graceful_shutdown_timeout,
}
}

pub fn requested_secret_lifetime(&self) -> Option<Duration> {
match self {
AnyServiceConfig::Master(config) => config.requested_secret_lifetime,
Expand Down Expand Up @@ -1243,7 +1246,7 @@ mod tests {
use std::collections::{BTreeMap, HashMap};

use indoc::indoc;
use product_config::{types::PropertyNameKind, ProductConfigManager};
use product_config::{ProductConfigManager, types::PropertyNameKind};
use rstest::rstest;
use stackable_operator::product_config_utils::{
transform_all_roles_to_config, validate_all_roles_and_groups_config,
Expand Down
2 changes: 1 addition & 1 deletion rust/operator-binary/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use stackable_operator::{
};

use crate::{
crd::{v1alpha1, HbaseRole, HBASE_SITE_XML},
crd::{HBASE_SITE_XML, HbaseRole, v1alpha1},
hbase_controller::build_recommended_labels,
kerberos::{self, kerberos_discovery_config_properties},
zookeeper::ZookeeperConnectionInformation,
Expand Down
24 changes: 12 additions & 12 deletions rust/operator-binary/src/hbase_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::{

use const_format::concatcp;
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 @@ -20,8 +20,8 @@ use stackable_operator::{
configmap::ConfigMapBuilder,
meta::ObjectMetaBuilder,
pod::{
container::ContainerBuilder, resources::ResourceRequirementsBuilder,
security::PodSecurityContextBuilder, PodBuilder,
PodBuilder, container::ContainerBuilder, resources::ResourceRequirementsBuilder,
security::PodSecurityContextBuilder,
},
},
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
Expand All @@ -37,9 +37,9 @@ use stackable_operator::{
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
},
kube::{
core::{error_boundary, DeserializeGuard},
runtime::controller::Action,
Resource, ResourceExt,
core::{DeserializeGuard, error_boundary},
runtime::controller::Action,
},
kvp::{Label, LabelError, Labels, ObjectLabels},
logging::controller::ReconcilerError,
Expand All @@ -64,14 +64,15 @@ use stackable_operator::{
use strum::{EnumDiscriminants, IntoStaticStr, ParseError};

use crate::{
OPERATOR_NAME,
config::jvm::{
construct_global_jvm_args, construct_hbase_heapsize_env,
construct_role_specific_non_heap_jvm_args,
},
crd::{
merged_env, v1alpha1, AnyServiceConfig, Container, HbaseClusterStatus, HbaseRole, APP_NAME,
HBASE_ENV_SH, HBASE_REST_PORT_NAME_HTTP, HBASE_REST_PORT_NAME_HTTPS, HBASE_SITE_XML,
JVM_SECURITY_PROPERTIES_FILE, SSL_CLIENT_XML, SSL_SERVER_XML,
APP_NAME, AnyServiceConfig, Container, HBASE_ENV_SH, HBASE_REST_PORT_NAME_HTTP,
HBASE_REST_PORT_NAME_HTTPS, HBASE_SITE_XML, HbaseClusterStatus, HbaseRole,
JVM_SECURITY_PROPERTIES_FILE, SSL_CLIENT_XML, SSL_SERVER_XML, merged_env, v1alpha1,
},
discovery::build_discovery_configmap,
kerberos::{
Expand All @@ -80,12 +81,11 @@ use crate::{
},
operations::{graceful_shutdown::add_graceful_shutdown_config, pdb::add_pdbs},
product_logging::{
extend_role_group_config_map, resolve_vector_aggregator_address,
CONTAINERDEBUG_LOG_DIRECTORY, STACKABLE_LOG_DIR,
CONTAINERDEBUG_LOG_DIRECTORY, STACKABLE_LOG_DIR, extend_role_group_config_map,
resolve_vector_aggregator_address,
},
security::{self, opa::HbaseOpaConfig},
zookeeper::{self, ZookeeperConnectionInformation},
OPERATOR_NAME,
};

pub const HBASE_CONTROLLER_NAME: &str = "hbasecluster";
Expand Down
6 changes: 3 additions & 3 deletions rust/operator-binary/src/kerberos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ use stackable_operator::{
builder::{
self,
pod::{
PodBuilder,
container::ContainerBuilder,
volume::{SecretFormat, SecretOperatorVolumeSourceBuilder, VolumeBuilder},
PodBuilder,
},
},
kube::{runtime::reflector::ObjectRef, ResourceExt},
kube::{ResourceExt, runtime::reflector::ObjectRef},
time::Duration,
utils::cluster_info::KubernetesClusterInfo,
};

use crate::crd::{v1alpha1, TLS_STORE_DIR, TLS_STORE_PASSWORD, TLS_STORE_VOLUME_NAME};
use crate::crd::{TLS_STORE_DIR, TLS_STORE_PASSWORD, TLS_STORE_VOLUME_NAME, v1alpha1};

#[derive(Snafu, Debug)]
pub enum Error {
Expand Down
18 changes: 8 additions & 10 deletions rust/operator-binary/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ use clap::Parser;
use futures::StreamExt;
use hbase_controller::FULL_HBASE_CONTROLLER_NAME;
use stackable_operator::{
YamlSchema,
cli::{Command, ProductOperatorRun},
k8s_openapi::api::{apps::v1::StatefulSet, core::v1::Service},
kube::{
core::DeserializeGuard,
runtime::{
Controller,
events::{Recorder, Reporter},
watcher, Controller,
watcher,
},
},
logging::controller::report_controller_reconciled,
shared::yaml::SerializeOptions,
YamlSchema,
};

use crate::crd::{v1alpha1, HbaseCluster, APP_NAME};
use crate::crd::{APP_NAME, HbaseCluster, v1alpha1};

mod config;
mod crd;
Expand Down Expand Up @@ -80,13 +81,10 @@ async fn main() -> anyhow::Result<()> {
)
.await?;

let event_recorder = Arc::new(Recorder::new(
client.as_kube_client(),
Reporter {
controller: FULL_HBASE_CONTROLLER_NAME.to_string(),
instance: None,
},
));
let event_recorder = Arc::new(Recorder::new(client.as_kube_client(), Reporter {
controller: FULL_HBASE_CONTROLLER_NAME.to_string(),
instance: None,
}));

Controller::new(
watch_namespace.get_api::<DeserializeGuard<v1alpha1::HbaseCluster>>(&client),
Expand Down
4 changes: 2 additions & 2 deletions rust/operator-binary/src/operations/pdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use stackable_operator::{
};

use crate::{
crd::{v1alpha1, HbaseRole, APP_NAME},
hbase_controller::HBASE_CONTROLLER_NAME,
OPERATOR_NAME,
crd::{APP_NAME, HbaseRole, v1alpha1},
hbase_controller::HBASE_CONTROLLER_NAME,
};

#[derive(Snafu, Debug)]
Expand Down
Loading
Loading