Skip to content

chore: Update templated files (f1f1a9e) #929

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"
22 changes: 14 additions & 8 deletions rust/operator-binary/src/config/jvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use stackable_operator::{
};

use crate::crd::{
v1alpha1::{ZookeeperCluster, ZookeeperConfig, ZookeeperConfigFragment},
LoggingFramework, JVM_SECURITY_PROPERTIES_FILE, LOG4J_CONFIG_FILE, LOGBACK_CONFIG_FILE,
JVM_SECURITY_PROPERTIES_FILE, LOG4J_CONFIG_FILE, LOGBACK_CONFIG_FILE, LoggingFramework,
METRICS_PORT, STACKABLE_CONFIG_DIR, STACKABLE_LOG_CONFIG_DIR,
v1alpha1::{ZookeeperCluster, ZookeeperConfig, ZookeeperConfigFragment},
};

const JAVA_HEAP_FACTOR: f32 = 0.8;
Expand Down Expand Up @@ -35,11 +35,17 @@ fn construct_jvm_args(
let logging_framework = zk.logging_framework();

let 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/server.yaml"),
match logging_framework {
LoggingFramework::LOG4J => format!("-Dlog4j.configuration=file:{STACKABLE_LOG_CONFIG_DIR}/{LOG4J_CONFIG_FILE}"),
LoggingFramework::LOGBACK => format!("-Dlogback.configurationFile={STACKABLE_LOG_CONFIG_DIR}/{LOGBACK_CONFIG_FILE}"),
format!("-Djava.security.properties={STACKABLE_CONFIG_DIR}/{JVM_SECURITY_PROPERTIES_FILE}"),
format!(
"-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar={METRICS_PORT}:/stackable/jmx/server.yaml"
),
match logging_framework {
LoggingFramework::LOG4J => {
format!("-Dlog4j.configuration=file:{STACKABLE_LOG_CONFIG_DIR}/{LOG4J_CONFIG_FILE}")
}
LoggingFramework::LOGBACK => format!(
"-Dlogback.configurationFile={STACKABLE_LOG_CONFIG_DIR}/{LOGBACK_CONFIG_FILE}"
),
},
];

Expand Down Expand Up @@ -93,7 +99,7 @@ fn is_heap_jvm_argument(jvm_argument: &str) -> bool {
#[cfg(test)]
mod tests {
use super::*;
use crate::crd::{v1alpha1::ZookeeperConfig, ZookeeperRole};
use crate::crd::{ZookeeperRole, v1alpha1::ZookeeperConfig};

#[test]
fn test_construct_jvm_arguments_defaults() {
Expand Down
4 changes: 2 additions & 2 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::{ZookeeperRole, APP_NAME};
use crate::crd::{APP_NAME, ZookeeperRole};

pub fn get_affinity(cluster_name: &str, role: &ZookeeperRole) -> StackableAffinityFragment {
let affinity_between_role_pods =
Expand Down
6 changes: 4 additions & 2 deletions rust/operator-binary/src/crd/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub enum Error {
authentication_class: ObjectRef<AuthenticationClass>,
},
// TODO: Adapt message if multiple authentication classes are supported
#[snafu(display("only one authentication class is currently supported. Possible Authentication classes are {SUPPORTED_AUTHENTICATION_CLASS:?}"))]
#[snafu(display(
"only one authentication class is currently supported. Possible Authentication classes are {SUPPORTED_AUTHENTICATION_CLASS:?}"
))]
MultipleAuthenticationClassesProvided,
#[snafu(display(
"failed to use authentication method [{method}] for authentication class [{authentication_class}] - supported mechanisms: {SUPPORTED_AUTHENTICATION_CLASS:?}",
Expand Down Expand Up @@ -81,7 +83,7 @@ impl ResolvedAuthenticationClasses {
return Err(Error::AuthenticationMethodNotSupported {
authentication_class: ObjectRef::from_obj(auth_class),
method: auth_class.spec.provider.to_string(),
})
});
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions rust/operator-binary/src/crd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use stackable_operator::{
api::core::v1::{PersistentVolumeClaim, ResourceRequirements},
apimachinery::pkg::api::resource::Quantity,
},
kube::{runtime::reflector::ObjectRef, CustomResource, ResourceExt},
kube::{CustomResource, ResourceExt, runtime::reflector::ObjectRef},
memory::{BinaryMultiple, MemoryQuantity},
product_config_utils::{self, Configuration},
product_logging::{self, spec::Logging},
Expand Down Expand Up @@ -368,14 +368,12 @@ impl v1alpha1::CurrentlySupportedListenerClasses {
}

impl v1alpha1::ZookeeperConfig {
pub const DATA_DIR: &'static str = "dataDir";
const DEFAULT_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(1);
pub const INIT_LIMIT: &'static str = "initLimit";
pub const MYID_OFFSET: &'static str = "MYID_OFFSET";
pub const SYNC_LIMIT: &'static str = "syncLimit";
pub const TICK_TIME: &'static str = "tickTime";
pub const DATA_DIR: &'static str = "dataDir";

pub const MYID_OFFSET: &'static str = "MYID_OFFSET";

const DEFAULT_SECRET_LIFETIME: Duration = Duration::from_days_unchecked(1);

fn default_server_config(
cluster_name: &str,
Expand Down
24 changes: 12 additions & 12 deletions rust/operator-binary/src/crd/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use stackable_operator::{
builder::{
self,
pod::{
PodBuilder,
container::ContainerBuilder,
volume::{
SecretFormat, SecretOperatorVolumeSourceBuilder,
SecretOperatorVolumeSourceBuilderError, VolumeBuilder,
},
PodBuilder,
},
},
client::Client,
Expand Down Expand Up @@ -60,14 +60,21 @@ impl ZookeeperSecurity {
// ports
pub const CLIENT_PORT: u16 = 2181;
pub const CLIENT_PORT_NAME: &'static str = "clientPort";
pub const SECURE_CLIENT_PORT: u16 = 2282;
pub const SECURE_CLIENT_PORT_NAME: &'static str = "secureClientPort";
// directories
pub const QUORUM_TLS_DIR: &'static str = "/stackable/quorum_tls";
pub const QUORUM_TLS_MOUNT_DIR: &'static str = "/stackable/quorum_tls_mount";
pub const SECURE_CLIENT_PORT: u16 = 2282;
pub const SECURE_CLIENT_PORT_NAME: &'static str = "secureClientPort";
pub const SERVER_CNXN_FACTORY: &'static str = "serverCnxnFactory";
pub const SERVER_TLS_DIR: &'static str = "/stackable/server_tls";
pub const SERVER_TLS_MOUNT_DIR: &'static str = "/stackable/server_tls_mount";
pub const SYSTEM_TRUST_STORE_DIR: &'static str = "/etc/pki/java/cacerts";
// Common TLS
pub const SSL_AUTH_PROVIDER_X509: &'static str = "authProvider.x509";
// Client TLS
pub const SSL_CLIENT_AUTH: &'static str = "ssl.clientAuth";
pub const SSL_HOST_NAME_VERIFICATION: &'static str = "ssl.hostnameVerification";
pub const SSL_KEY_STORE_LOCATION: &'static str = "ssl.keyStore.location";
pub const SSL_KEY_STORE_PASSWORD: &'static str = "ssl.keyStore.password";
// Quorum TLS
pub const SSL_QUORUM: &'static str = "sslQuorum";
pub const SSL_QUORUM_CLIENT_AUTH: &'static str = "ssl.quorum.clientAuth";
Expand All @@ -76,18 +83,11 @@ impl ZookeeperSecurity {
pub const SSL_QUORUM_KEY_STORE_PASSWORD: &'static str = "ssl.quorum.keyStore.password";
pub const SSL_QUORUM_TRUST_STORE_LOCATION: &'static str = "ssl.quorum.trustStore.location";
pub const SSL_QUORUM_TRUST_STORE_PASSWORD: &'static str = "ssl.quorum.trustStore.password";
// Client TLS
pub const SSL_CLIENT_AUTH: &'static str = "ssl.clientAuth";
pub const SSL_HOST_NAME_VERIFICATION: &'static str = "ssl.hostnameVerification";
pub const SSL_KEY_STORE_LOCATION: &'static str = "ssl.keyStore.location";
pub const SSL_KEY_STORE_PASSWORD: &'static str = "ssl.keyStore.password";
pub const SSL_TRUST_STORE_LOCATION: &'static str = "ssl.trustStore.location";
pub const SSL_TRUST_STORE_PASSWORD: &'static str = "ssl.trustStore.password";
// Common TLS
pub const SSL_AUTH_PROVIDER_X509: &'static str = "authProvider.x509";
pub const SERVER_CNXN_FACTORY: &'static str = "serverCnxnFactory";
// Mis
pub const STORE_PASSWORD_ENV: &'static str = "STORE_PASSWORD";
pub const SYSTEM_TRUST_STORE_DIR: &'static str = "/etc/pki/java/cacerts";

/// Create a `ZookeeperSecurity` struct from the Zookeeper custom resource and resolve
/// all provided `AuthenticationClass` references.
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},
kube::{runtime::reflector::ObjectRef, Resource, ResourceExt},
kube::{Resource, ResourceExt, runtime::reflector::ObjectRef},
utils::cluster_info::KubernetesClusterInfo,
};

use crate::{
crd::{security::ZookeeperSecurity, v1alpha1, ZookeeperRole},
crd::{ZookeeperRole, security::ZookeeperSecurity, v1alpha1},
utils::build_recommended_labels,
};

Expand Down
35 changes: 15 additions & 20 deletions rust/operator-binary/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
use std::sync::Arc;

use clap::{crate_description, crate_version, Parser};
use crd::{v1alpha1, ZookeeperCluster, ZookeeperZnode, APP_NAME, OPERATOR_NAME};
use futures::{pin_mut, StreamExt};
use clap::{Parser, crate_description, crate_version};
use crd::{APP_NAME, OPERATOR_NAME, ZookeeperCluster, ZookeeperZnode, v1alpha1};
use futures::{StreamExt, pin_mut};
use stackable_operator::{
YamlSchema,
cli::{Command, ProductOperatorRun},
k8s_openapi::api::{
apps::v1::StatefulSet,
core::v1::{ConfigMap, Endpoints, Service},
},
kube::{
Resource,
core::DeserializeGuard,
runtime::{
Controller,
events::{Recorder, Reporter},
reflector::ObjectRef,
watcher, Controller,
watcher,
},
Resource,
},
logging::controller::report_controller_reconciled,
shared::yaml::SerializeOptions,
YamlSchema,
};

use crate::{zk_controller::ZK_FULL_CONTROLLER_NAME, znode_controller::ZNODE_FULL_CONTROLLER_NAME};
Expand Down Expand Up @@ -92,13 +93,10 @@ async fn main() -> anyhow::Result<()> {
watcher::Config::default(),
);

let zk_event_recorder = Arc::new(Recorder::new(
client.as_kube_client(),
Reporter {
controller: ZK_FULL_CONTROLLER_NAME.to_string(),
instance: None,
},
));
let zk_event_recorder = Arc::new(Recorder::new(client.as_kube_client(), Reporter {
controller: ZK_FULL_CONTROLLER_NAME.to_string(),
instance: None,
}));
let zk_store = zk_controller.store();
let zk_controller = zk_controller
.owns(
Expand Down Expand Up @@ -162,13 +160,10 @@ async fn main() -> anyhow::Result<()> {
watch_namespace.get_api::<DeserializeGuard<v1alpha1::ZookeeperZnode>>(&client),
watcher::Config::default(),
);
let znode_event_recorder = Arc::new(Recorder::new(
client.as_kube_client(),
Reporter {
controller: ZNODE_FULL_CONTROLLER_NAME.to_string(),
instance: None,
},
));
let znode_event_recorder = Arc::new(Recorder::new(client.as_kube_client(), Reporter {
controller: ZNODE_FULL_CONTROLLER_NAME.to_string(),
instance: None,
}));

let znode_store = znode_controller.store();
let znode_controller = znode_controller
Expand Down
2 changes: 1 addition & 1 deletion rust/operator-binary/src/operations/pdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use stackable_operator::{
};

use crate::{
crd::{v1alpha1, ZookeeperRole, APP_NAME, OPERATOR_NAME},
crd::{APP_NAME, OPERATOR_NAME, ZookeeperRole, v1alpha1},
zk_controller::ZK_CONTROLLER_NAME,
};

Expand Down
4 changes: 2 additions & 2 deletions rust/operator-binary/src/product_logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use stackable_operator::{
};

use crate::crd::{
v1alpha1, LoggingFramework, ZookeeperRole, LOG4J_CONFIG_FILE, LOGBACK_CONFIG_FILE,
MAX_ZK_LOG_FILES_SIZE, STACKABLE_LOG_DIR, ZOOKEEPER_LOG_FILE,
LOG4J_CONFIG_FILE, LOGBACK_CONFIG_FILE, LoggingFramework, MAX_ZK_LOG_FILES_SIZE,
STACKABLE_LOG_DIR, ZOOKEEPER_LOG_FILE, ZookeeperRole, v1alpha1,
};

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