From 3fea5ab313137c0a7b22c56a1c366ed3950a0274 Mon Sep 17 00:00:00 2001 From: Techassi Date: Thu, 2 Nov 2023 13:52:59 +0100 Subject: [PATCH] Use updated product-config --- Cargo.lock | 184 +++++++++++++++++-- Cargo.toml | 9 +- rust/crd/src/authentication.rs | 4 +- rust/crd/src/lib.rs | 23 ++- rust/crd/src/security.rs | 6 +- rust/crd/src/tls.rs | 1 + rust/operator-binary/Cargo.toml | 1 + rust/operator-binary/src/discovery.rs | 17 +- rust/operator-binary/src/main.rs | 23 +-- rust/operator-binary/src/product_logging.rs | 4 + rust/operator-binary/src/utils.rs | 3 +- rust/operator-binary/src/zk_controller.rs | 66 +++++-- rust/operator-binary/src/znode_controller.rs | 25 ++- 13 files changed, 297 insertions(+), 69 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a68669ec..23e335d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,6 +195,15 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "built" version = "0.6.1" @@ -347,6 +356,15 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "cpufeatures" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +dependencies = [ + "libc", +] + [[package]] name = "crossbeam-channel" version = "0.5.8" @@ -366,6 +384,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "darling" version = "0.14.4" @@ -447,12 +475,36 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "doc-comment" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "dockerfile-parser" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75799314f5fa405629a365a1f97d80f81edd17f22a0fc9c8ddb3ad191ad8dc08" +dependencies = [ + "enquote", + "lazy_static", + "pest", + "pest_derive", + "regex", + "snafu 0.6.10", +] + [[package]] name = "dyn-clone" version = "1.0.14" @@ -474,6 +526,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "enquote" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c36cb11dbde389f4096111698d8b567c0720e3452fd5ac3e6b4e47e1939932" +dependencies = [ + "thiserror", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -629,6 +690,16 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.10" @@ -1324,6 +1395,51 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +[[package]] +name = "pest" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "pest_meta" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + [[package]] name = "pin-project" version = "1.1.3" @@ -1379,8 +1495,8 @@ dependencies = [ [[package]] name = "product-config" -version = "0.5.0" -source = "git+https://github.com/stackabletech/product-config.git?tag=0.5.0#439869d9e6a72fb6d912f6e494649a2f74f41d25" +version = "0.6.0" +source = "git+https://github.com/stackabletech/product-config.git?tag=0.6.0#ad2c3ea6a291e415d978eb4271fb309e75861ef0" dependencies = [ "fancy-regex", "java-properties", @@ -1389,7 +1505,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "thiserror", + "snafu 0.7.5", "xml-rs", ] @@ -1771,6 +1887,17 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.4" @@ -1810,6 +1937,16 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +[[package]] +name = "snafu" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7" +dependencies = [ + "doc-comment", + "snafu-derive 0.6.10", +] + [[package]] name = "snafu" version = "0.7.5" @@ -1817,7 +1954,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" dependencies = [ "doc-comment", - "snafu-derive", + "snafu-derive 0.7.5", +] + +[[package]] +name = "snafu-derive" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -1860,13 +2008,14 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "stackable-operator" -version = "0.55.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.55.0#bfbc23d3819f815413cb4135e0835acd76aecf97" +version = "0.56.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.56.0#1acaac4dacf302cc068b4294c8a1d4c2928977c0" dependencies = [ "chrono", "clap", "const_format", "derivative", + "dockerfile-parser", "either", "futures 0.3.28", "json-patch", @@ -1882,7 +2031,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "snafu", + "snafu 0.7.5", "stackable-operator-derive", "strum", "thiserror", @@ -1894,8 +2043,8 @@ dependencies = [ [[package]] name = "stackable-operator-derive" -version = "0.55.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.55.0#bfbc23d3819f815413cb4135e0835acd76aecf97" +version = "0.56.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.56.0#1acaac4dacf302cc068b4294c8a1d4c2928977c0" dependencies = [ "darling 0.20.3", "proc-macro2", @@ -1910,7 +2059,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "snafu", + "snafu 0.7.5", "stackable-operator", "strum", "tracing", @@ -1927,10 +2076,11 @@ dependencies = [ "fnv", "futures 0.3.28", "pin-project", + "product-config", "rstest", "semver", "serde", - "snafu", + "snafu 0.7.5", "stackable-operator", "stackable-zookeeper-crd", "strum", @@ -2338,6 +2488,18 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + [[package]] name = "unicode-bidi" version = "0.3.13" diff --git a/Cargo.toml b/Cargo.toml index f1971cae..ec653773 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,5 @@ [workspace] -members = [ - "rust/crd", "rust/operator-binary" -] +members = ["rust/crd", "rust/operator-binary"] [workspace.package] version = "0.0.0-dev" @@ -12,7 +10,7 @@ repository = "https://github.com/stackabletech/zookeeper-operator" [workspace.dependencies] anyhow = "1.0" -built = { version = "0.6", features = ["chrono", "git2"] } +built = { version = "0.6", features = ["chrono", "git2"] } clap = "4.3" failure = "0.1" fnv = "1.0" @@ -24,7 +22,8 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_yaml = "0.9" snafu = "0.7" -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.55.0" } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.56.0" } +product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.6.0" } strum = { version = "0.25", features = ["derive"] } tokio = { version = "1.29", features = ["full"] } tokio-zookeeper = "0.2" diff --git a/rust/crd/src/authentication.rs b/rust/crd/src/authentication.rs index 387c7fd4..19657e37 100644 --- a/rust/crd/src/authentication.rs +++ b/rust/crd/src/authentication.rs @@ -1,5 +1,3 @@ -use crate::ObjectRef; - use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use stackable_operator::commons::authentication::AuthenticationClassProvider; @@ -9,6 +7,8 @@ use stackable_operator::{ schemars::{self, JsonSchema}, }; +use crate::ObjectRef; + const SUPPORTED_AUTHENTICATION_CLASS: [&str; 1] = ["TLS"]; #[derive(Snafu, Debug)] diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index 0420907b..a7516ff4 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -1,12 +1,5 @@ -pub mod affinity; -pub mod authentication; -pub mod security; -pub mod tls; - -use crate::authentication::ZookeeperAuthentication; -use crate::tls::ZookeeperTls; +use std::{collections::BTreeMap, str::FromStr}; -use affinity::get_affinity; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{ @@ -33,9 +26,15 @@ use stackable_operator::{ schemars::{self, JsonSchema}, status::condition::{ClusterCondition, HasStatusCondition}, }; -use std::{collections::BTreeMap, str::FromStr}; use strum::{Display, EnumIter, EnumString, IntoEnumIterator}; +use crate::{affinity::get_affinity, authentication::ZookeeperAuthentication, tls::ZookeeperTls}; + +pub mod affinity; +pub mod authentication; +pub mod security; +pub mod tls; + pub const APP_NAME: &str = "zookeeper"; pub const OPERATOR_NAME: &str = "zookeeper.stackable.tech"; @@ -76,20 +75,26 @@ mod built_info { pub enum Error { #[snafu(display("object has no namespace associated"))] NoNamespace, + #[snafu(display("unknown role {role}. Should be one of {roles:?}"))] UnknownZookeeperRole { source: strum::ParseError, role: String, roles: Vec, }, + #[snafu(display("the role {role} is not defined"))] CannotRetrieveZookeeperRole { role: String }, + #[snafu(display("the role group {role_group} is not defined"))] CannotRetrieveZookeeperRoleGroup { role_group: String }, + #[snafu(display("fragment validation failure"))] FragmentValidationFailure { source: ValidationError }, + #[snafu(display("invalid java heap config - missing default or value in crd?"))] InvalidJavaHeapConfig, + #[snafu(display("failed to convert java heap config to unit [{unit}]"))] FailedToConvertJavaHeap { source: stackable_operator::error::Error, diff --git a/rust/crd/src/security.rs b/rust/crd/src/security.rs index 5899439e..ca7e5b80 100644 --- a/rust/crd/src/security.rs +++ b/rust/crd/src/security.rs @@ -4,8 +4,7 @@ //! and helper functions //! //! This is required due to overlaps between TLS encryption and e.g. mTLS authentication or Kerberos - -use crate::{authentication, authentication::ResolvedAuthenticationClasses, tls, ZookeeperCluster}; +use std::collections::BTreeMap; use snafu::{ResultExt, Snafu}; use stackable_operator::{ @@ -17,7 +16,8 @@ use stackable_operator::{ commons::authentication::AuthenticationClassProvider, k8s_openapi::api::core::v1::Volume, }; -use std::collections::BTreeMap; + +use crate::{authentication, authentication::ResolvedAuthenticationClasses, tls, ZookeeperCluster}; #[derive(Snafu, Debug)] pub enum Error { diff --git a/rust/crd/src/tls.rs b/rust/crd/src/tls.rs index 22e9a9e8..05021236 100644 --- a/rust/crd/src/tls.rs +++ b/rust/crd/src/tls.rs @@ -14,6 +14,7 @@ pub struct ZookeeperTls { /// Defaults to `tls` #[serde(default = "quorum_tls_default")] pub quorum_secret_class: String, + /// The to use for /// client connections. This setting controls: /// - If TLS encryption is used at all diff --git a/rust/operator-binary/Cargo.toml b/rust/operator-binary/Cargo.toml index fde120dd..2f0ea986 100644 --- a/rust/operator-binary/Cargo.toml +++ b/rust/operator-binary/Cargo.toml @@ -26,6 +26,7 @@ tokio-zookeeper.workspace = true tracing.workspace = true pin-project.workspace = true stackable-operator.workspace = true +product-config.workspace = true [dev-dependencies] rstest.workspace = true diff --git a/rust/operator-binary/src/discovery.rs b/rust/operator-binary/src/discovery.rs index 4688934c..eaa669a4 100644 --- a/rust/operator-binary/src/discovery.rs +++ b/rust/operator-binary/src/discovery.rs @@ -1,4 +1,4 @@ -use crate::utils::build_recommended_labels; +use std::{collections::BTreeSet, num::TryFromIntError}; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{ @@ -7,9 +7,9 @@ use stackable_operator::{ k8s_openapi::api::core::v1::{ConfigMap, Endpoints, Service}, kube::{runtime::reflector::ObjectRef, Resource, ResourceExt}, }; -use stackable_zookeeper_crd::security::ZookeeperSecurity; -use stackable_zookeeper_crd::{ZookeeperCluster, ZookeeperRole}; -use std::{collections::BTreeSet, num::TryFromIntError}; +use stackable_zookeeper_crd::{security::ZookeeperSecurity, ZookeeperCluster, ZookeeperRole}; + +use crate::utils::build_recommended_labels; #[derive(Snafu, Debug)] pub enum Error { @@ -18,27 +18,36 @@ pub enum Error { source: stackable_operator::error::Error, zk: ObjectRef, }, + #[snafu(display("chroot path {} was relative (must be absolute)", chroot))] RelativeChroot { chroot: String }, + #[snafu(display("object has no name associated"))] NoName, + #[snafu(display("object has no namespace associated"))] NoNamespace, + #[snafu(display("failed to list expected pods"))] ExpectedPods { source: stackable_zookeeper_crd::Error, }, + #[snafu(display("could not find service port with name {}", port_name))] NoServicePort { port_name: String }, + #[snafu(display("service port with name {} does not have a nodePort", port_name))] NoNodePort { port_name: String }, + #[snafu(display("could not find Endpoints for {}", svc))] FindEndpoints { source: stackable_operator::error::Error, svc: ObjectRef, }, + #[snafu(display("nodePort was out of range"))] InvalidNodePort { source: TryFromIntError }, + #[snafu(display("failed to build ConfigMap"))] BuildConfigMap { source: stackable_operator::error::Error, diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index 0b8ffb56..369033cd 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -1,13 +1,4 @@ -mod command; -mod discovery; -mod operations; -mod product_logging; -mod utils; -mod zk_controller; -mod znode_controller; - -use crate::zk_controller::ZK_CONTROLLER_NAME; -use crate::znode_controller::ZNODE_CONTROLLER_NAME; +use std::sync::Arc; use clap::{crate_description, crate_version, Parser}; use futures::StreamExt; @@ -22,7 +13,17 @@ use stackable_operator::{ CustomResourceExt, }; use stackable_zookeeper_crd::{ZookeeperCluster, ZookeeperZnode, APP_NAME, OPERATOR_NAME}; -use std::sync::Arc; + +use crate::zk_controller::ZK_CONTROLLER_NAME; +use crate::znode_controller::ZNODE_CONTROLLER_NAME; + +mod command; +mod discovery; +mod operations; +mod product_logging; +mod utils; +mod zk_controller; +mod znode_controller; mod built_info { include!(concat!(env!("OUT_DIR"), "/built.rs")); diff --git a/rust/operator-binary/src/product_logging.rs b/rust/operator-binary/src/product_logging.rs index 9202f830..2922f96c 100644 --- a/rust/operator-binary/src/product_logging.rs +++ b/rust/operator-binary/src/product_logging.rs @@ -20,20 +20,24 @@ use stackable_zookeeper_crd::{ pub enum Error { #[snafu(display("object has no namespace"))] ObjectHasNoNamespace, + #[snafu(display("failed to retrieve the ConfigMap {cm_name}"))] ConfigMapNotFound { source: stackable_operator::error::Error, cm_name: String, }, + #[snafu(display("failed to retrieve the entry {entry} for ConfigMap {cm_name}"))] MissingConfigMapEntry { entry: &'static str, cm_name: String, }, + #[snafu(display("crd validation failure"))] CrdValidationFailure { source: stackable_zookeeper_crd::Error, }, + #[snafu(display("vectorAggregatorConfigMapName must be set"))] MissingVectorAggregatorAddress, } diff --git a/rust/operator-binary/src/utils.rs b/rust/operator-binary/src/utils.rs index 9a02644f..e2a27a05 100644 --- a/rust/operator-binary/src/utils.rs +++ b/rust/operator-binary/src/utils.rs @@ -1,6 +1,7 @@ -use crate::{APP_NAME, OPERATOR_NAME}; use stackable_operator::labels::ObjectLabels; +use crate::{APP_NAME, OPERATOR_NAME}; + /// Creates recommended `ObjectLabels` to be used in deployed resources pub fn build_recommended_labels<'a, T>( owner: &'a T, diff --git a/rust/operator-binary/src/zk_controller.rs b/rust/operator-binary/src/zk_controller.rs index 95afa479..4940fff2 100644 --- a/rust/operator-binary/src/zk_controller.rs +++ b/rust/operator-binary/src/zk_controller.rs @@ -1,14 +1,18 @@ //! Ensures that `Pod`s are configured and running for each [`ZookeeperCluster`] -use crate::{ - command::create_init_container_command_args, - discovery::{self, build_discovery_configmaps}, - operations::pdb::add_pdbs, - product_logging::{extend_role_group_config_map, resolve_vector_aggregator_address}, - utils::build_recommended_labels, - ObjectRef, APP_NAME, OPERATOR_NAME, +use std::{ + borrow::Cow, + collections::{BTreeMap, HashMap}, + hash::Hasher, + str::FromStr, + sync::Arc, }; use fnv::FnvHasher; +use product_config::{ + types::PropertyNameKind, + writer::{to_java_properties_string, PropertiesWriterError}, + ProductConfigManager, +}; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{ builder::{ @@ -35,9 +39,6 @@ use stackable_operator::{ kube::{api::DynamicObject, runtime::controller, Resource}, labels::{role_group_selector_labels, role_selector_labels}, logging::controller::ReconcilerError, - product_config::{ - types::PropertyNameKind, writer::to_java_properties_string, ProductConfigManager, - }, product_config_utils::{transform_all_roles_to_config, validate_all_roles_and_groups_config}, product_logging::{ self, @@ -60,15 +61,17 @@ use stackable_zookeeper_crd::{ STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_DIR, STACKABLE_RW_CONFIG_DIR, ZOOKEEPER_PROPERTIES_FILE, }; -use std::{ - borrow::Cow, - collections::{BTreeMap, HashMap}, - hash::Hasher, - str::FromStr, - sync::Arc, -}; use strum::{EnumDiscriminants, IntoStaticStr}; +use crate::{ + command::create_init_container_command_args, + discovery::{self, build_discovery_configmaps}, + operations::pdb::add_pdbs, + product_logging::{extend_role_group_config_map, resolve_vector_aggregator_address}, + utils::build_recommended_labels, + ObjectRef, APP_NAME, OPERATOR_NAME, +}; + pub const ZK_CONTROLLER_NAME: &str = "zookeepercluster"; pub const ZK_UID: i64 = 1000; pub struct Ctx { @@ -84,111 +87,138 @@ pub enum Error { CrdValidationFailure { source: stackable_zookeeper_crd::Error, }, + #[snafu(display("object defines no server role"))] NoServerRole, + #[snafu(display("could not parse role [{role}]"))] RoleParseFailure { source: strum::ParseError, role: String, }, + #[snafu(display("internal operator failure"))] InternalOperatorFailure { source: stackable_zookeeper_crd::Error, }, + #[snafu(display("failed to calculate global service name"))] GlobalServiceNameNotFound, + #[snafu(display("failed to calculate service name for role {}", rolegroup))] RoleGroupServiceNameNotFound { rolegroup: RoleGroupRef, }, + #[snafu(display("failed to apply global Service"))] ApplyRoleService { source: stackable_operator::error::Error, }, + #[snafu(display("failed to apply Service for {}", rolegroup))] ApplyRoleGroupService { source: stackable_operator::error::Error, rolegroup: RoleGroupRef, }, + #[snafu(display("failed to build ConfigMap for {}", rolegroup))] BuildRoleGroupConfig { source: stackable_operator::error::Error, rolegroup: RoleGroupRef, }, + #[snafu(display("failed to apply ConfigMap for {}", rolegroup))] ApplyRoleGroupConfig { source: stackable_operator::error::Error, rolegroup: RoleGroupRef, }, + #[snafu(display("failed to apply StatefulSet for {}", rolegroup))] ApplyRoleGroupStatefulSet { source: stackable_operator::error::Error, rolegroup: RoleGroupRef, }, + #[snafu(display("failed to generate product config"))] GenerateProductConfig { source: stackable_operator::product_config_utils::ConfigError, }, + #[snafu(display("invalid product config"))] InvalidProductConfig { source: stackable_operator::error::Error, }, + #[snafu(display("failed to serialize [{ZOOKEEPER_PROPERTIES_FILE}] for {}", rolegroup))] SerializeZooCfg { - source: stackable_operator::product_config::writer::PropertiesWriterError, + source: PropertiesWriterError, rolegroup: RoleGroupRef, }, + #[snafu(display("object is missing metadata to build owner reference"))] ObjectMissingMetadataForOwnerRef { source: stackable_operator::error::Error, }, + #[snafu(display("failed to build discovery ConfigMap"))] BuildDiscoveryConfig { source: discovery::Error }, + #[snafu(display("failed to apply discovery ConfigMap"))] ApplyDiscoveryConfig { source: stackable_operator::error::Error, }, + #[snafu(display("failed to update status"))] ApplyStatus { source: stackable_operator::error::Error, }, + #[snafu(display("invalid java heap config"))] InvalidJavaHeapConfig { source: stackable_zookeeper_crd::Error, }, + #[snafu(display("failed to create RBAC service account"))] ApplyServiceAccount { source: stackable_operator::error::Error, }, + #[snafu(display("failed to create RBAC role binding"))] ApplyRoleBinding { source: stackable_operator::error::Error, }, + #[snafu(display("failed to build RBAC resources"))] BuildRbacResources { source: stackable_operator::error::Error, }, + #[snafu(display("failed to delete orphaned resources"))] DeleteOrphans { source: stackable_operator::error::Error, }, + #[snafu(display("failed to resolve the Vector aggregator address"))] ResolveVectorAggregatorAddress { source: crate::product_logging::Error, }, + #[snafu(display("failed to add the logging configuration to the ConfigMap {cm_name}"))] InvalidLoggingConfig { source: crate::product_logging::Error, cm_name: String, }, + #[snafu(display("failed to initialize security context"))] FailedToInitializeSecurityContext { source: stackable_zookeeper_crd::security::Error, }, + #[snafu(display("failed to resolve and merge config for role and role group"))] FailedToResolveConfig { source: stackable_zookeeper_crd::Error, }, + #[snafu(display("failed to create PodDisruptionBudget"))] FailedToCreatePdb { source: crate::operations::pdb::Error, diff --git a/rust/operator-binary/src/znode_controller.rs b/rust/operator-binary/src/znode_controller.rs index 898a82c8..be7b4d29 100644 --- a/rust/operator-binary/src/znode_controller.rs +++ b/rust/operator-binary/src/znode_controller.rs @@ -1,13 +1,8 @@ //! Reconciles state for ZooKeeper znodes between Kubernetes [`ZookeeperZnode`] objects and the ZooKeeper cluster //! //! See [`ZookeeperZnode`] for more details. - use std::{convert::Infallible, sync::Arc}; -use crate::{ - discovery::{self, build_discovery_configmaps}, - APP_NAME, OPERATOR_NAME, -}; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{ cluster_resources::{ClusterResourceApplyStrategy, ClusterResources}, @@ -28,6 +23,11 @@ use stackable_zookeeper_crd::{ }; use strum::{EnumDiscriminants, IntoStaticStr}; +use crate::{ + discovery::{self, build_discovery_configmaps}, + APP_NAME, OPERATOR_NAME, +}; + pub const ZNODE_CONTROLLER_NAME: &str = "znode"; pub struct Ctx { @@ -42,59 +42,74 @@ pub enum Error { "object is missing metadata that should be created by the Kubernetes cluster", ))] ObjectMissingMetadata, + #[snafu(display("object does not refer to ZookeeperCluster"))] InvalidZkReference, + #[snafu(display("could not find {}", zk))] FindZk { source: stackable_operator::error::Error, zk: ObjectRef, }, + ZkDoesNotExist { source: stackable_operator::error::Error, zk: ObjectRef, }, + #[snafu(display("could not find server role service name for {}", zk))] NoZkSvcName { zk: ObjectRef }, + #[snafu(display("could not find server role service for {}", zk))] FindZkSvc { source: stackable_operator::error::Error, zk: ObjectRef, }, + #[snafu(display("failed to calculate FQDN for {}", zk))] NoZkFqdn { zk: ObjectRef }, + #[snafu(display("failed to ensure that ZNode {} exists in {}", znode_path, zk))] EnsureZnode { source: znode_mgmt::Error, zk: ObjectRef, znode_path: String, }, + #[snafu(display("failed to ensure that ZNode {} is missing from {}", znode_path, zk))] EnsureZnodeMissing { source: znode_mgmt::Error, zk: ObjectRef, znode_path: String, }, + #[snafu(display("failed to build discovery information"))] BuildDiscoveryConfigMap { source: discovery::Error }, + #[snafu(display("failed to save discovery information to {}", cm))] ApplyDiscoveryConfigMap { source: stackable_operator::error::Error, cm: ObjectRef, }, + #[snafu(display("error managing finalizer"))] Finalizer { source: finalizer::Error, }, + #[snafu(display("object is missing metadata to build owner reference"))] ObjectMissingMetadataForOwnerRef { source: stackable_operator::error::Error, }, + #[snafu(display("failed to delete orphaned resources"))] DeleteOrphans { source: stackable_operator::error::Error, }, + #[snafu(display("object has no namespace"))] ObjectHasNoNamespace, + #[snafu(display("failed to initialize security context"))] FailedToInitializeSecurityContext { source: stackable_zookeeper_crd::security::Error,