Skip to content

Commit 404a335

Browse files
committed
chore: regenerate und linters
1 parent 9d94d08 commit 404a335

9 files changed

Lines changed: 375 additions & 279 deletions

File tree

Cargo.nix

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

crate-hashes.json

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

extra/crds.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,23 +798,25 @@ spec:
798798
properties:
799799
hive-site.xml:
800800
additionalProperties:
801+
nullable: true
801802
type: string
803+
default: {}
802804
description: |-
803805
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
804806
805807
This is backwards-compatible with the existing flat key-value YAML format
806808
used by `HashMap<String, String>`.
807-
nullable: true
808809
type: object
809810
security.properties:
810811
additionalProperties:
812+
nullable: true
811813
type: string
814+
default: {}
812815
description: |-
813816
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
814817
815818
This is backwards-compatible with the existing flat key-value YAML format
816819
used by `HashMap<String, String>`.
817-
nullable: true
818820
type: object
819821
type: object
820822
envOverrides:
@@ -1255,23 +1257,25 @@ spec:
12551257
properties:
12561258
hive-site.xml:
12571259
additionalProperties:
1260+
nullable: true
12581261
type: string
1262+
default: {}
12591263
description: |-
12601264
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
12611265
12621266
This is backwards-compatible with the existing flat key-value YAML format
12631267
used by `HashMap<String, String>`.
1264-
nullable: true
12651268
type: object
12661269
security.properties:
12671270
additionalProperties:
1271+
nullable: true
12681272
type: string
1273+
default: {}
12691274
description: |-
12701275
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
12711276
12721277
This is backwards-compatible with the existing flat key-value YAML format
12731278
used by `HashMap<String, String>`.
1274-
nullable: true
12751279
type: object
12761280
type: object
12771281
envOverrides:

rust/operator-binary/src/controller.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ use crate::{
8282
jvm::{construct_hadoop_heapsize_env, construct_non_heap_jvm_args},
8383
opa::{HiveOpaConfig, OPA_TLS_VOLUME_NAME},
8484
},
85+
controller::build::discovery,
8586
crd::{
8687
APP_NAME, Container, HIVE_PORT, HIVE_PORT_NAME, HiveClusterStatus, HiveRole, METRICS_PORT,
8788
METRICS_PORT_NAME, MetaStoreConfig, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME,
8889
STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_CONFIG_MOUNT_DIR_NAME,
8990
STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_DIR,
9091
STACKABLE_LOG_DIR_NAME, v1alpha1,
9192
},
92-
discovery::{self},
9393
kerberos::{self, add_kerberos_pod_config, kerberos_container_start_commands},
9494
listener::{LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, build_role_listener},
9595
operations::{graceful_shutdown::add_graceful_shutdown_config, pdb::add_pdbs},
@@ -189,12 +189,6 @@ pub enum Error {
189189
#[snafu(display("vector agent is enabled but vector aggregator ConfigMap is missing"))]
190190
VectorAggregatorConfigMapMissing,
191191

192-
#[snafu(display("failed to add the logging configuration to the ConfigMap [{cm_name}]"))]
193-
InvalidLoggingConfig {
194-
source: crate::product_logging::Error,
195-
cm_name: String,
196-
},
197-
198192
#[snafu(display("failed to patch service account"))]
199193
ApplyServiceAccount {
200194
source: stackable_operator::cluster_resources::Error,

rust/operator-binary/src/controller/build/config_map.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@ use snafu::{OptionExt, ResultExt, Snafu};
44
use stackable_operator::{
55
builder::{configmap::ConfigMapBuilder, meta::ObjectMetaBuilder},
66
k8s_openapi::api::core::v1::ConfigMap,
7+
product_logging::framework::VECTOR_CONFIG_FILE,
78
role_utils::RoleGroupRef,
89
};
910

1011
use crate::{
1112
controller::{
1213
ValidatedCluster,
13-
build::properties::{core_site, hive_site, resolved_overrides, security_properties},
14+
build::properties::{
15+
core_site, hive_site, logging, resolved_overrides, security_properties,
16+
},
1417
build_recommended_labels,
1518
},
16-
crd::{CORE_SITE_XML, HIVE_SITE_XML, HiveRole, JVM_SECURITY_PROPERTIES_FILE, v1alpha1},
19+
crd::{
20+
CORE_SITE_XML, HIVE_METASTORE_LOG4J2_PROPERTIES, HIVE_SITE_XML, HiveRole,
21+
JVM_SECURITY_PROPERTIES_FILE, v1alpha1,
22+
},
1723
framework::writer::{to_hadoop_xml, to_java_properties_string},
18-
product_logging::extend_role_group_config_map,
1924
};
2025

2126
#[derive(Debug, Snafu)]
@@ -41,12 +46,6 @@ pub enum Error {
4146
source: stackable_operator::builder::meta::Error,
4247
},
4348

44-
#[snafu(display("failed to add the logging configuration to the ConfigMap {cm_name}"))]
45-
InvalidLoggingConfig {
46-
source: crate::product_logging::Error,
47-
cm_name: String,
48-
},
49-
5049
#[snafu(display("failed to assemble ConfigMap for {rolegroup}"))]
5150
Assemble {
5251
source: stackable_operator::builder::configmap::Error,
@@ -114,11 +113,12 @@ pub fn build_metastore_rolegroup_config_map(
114113
cm_builder.add_data(CORE_SITE_XML, to_hadoop_xml(core_site_data.iter()));
115114
}
116115

117-
extend_role_group_config_map(rolegroup, &rg.config.logging, &mut cm_builder).context(
118-
InvalidLoggingConfigSnafu {
119-
cm_name: rolegroup.object_name(),
120-
},
121-
)?;
116+
if let Some(log4j2_properties) = logging::build_log4j2(&rg.config.logging) {
117+
cm_builder.add_data(HIVE_METASTORE_LOG4J2_PROPERTIES, log4j2_properties);
118+
}
119+
if let Some(vector_config) = logging::build_vector_config(rolegroup, &rg.config.logging) {
120+
cm_builder.add_data(VECTOR_CONFIG_FILE, vector_config);
121+
}
122122

123123
cm_builder.build().with_context(|_| AssembleSnafu {
124124
rolegroup: rolegroup.clone(),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Builders that turn a `ValidatedCluster` into Kubernetes resources.
22
33
pub mod config_map;
4+
pub mod discovery;
45
pub mod properties;
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//! Renders the logging config files (`log4j2.properties` and the Vector agent
2+
//! config) assembled into the rolegroup `ConfigMap`.
3+
4+
use stackable_operator::{
5+
memory::BinaryMultiple,
6+
product_logging::{
7+
self,
8+
spec::{
9+
AutomaticContainerLogConfig, ContainerLogConfig, ContainerLogConfigChoice, Logging,
10+
},
11+
},
12+
role_utils::RoleGroupRef,
13+
};
14+
15+
use crate::{
16+
controller::MAX_HIVE_LOG_FILES_SIZE,
17+
crd::{Container, STACKABLE_LOG_DIR, v1alpha1},
18+
};
19+
20+
const CONSOLE_CONVERSION_PATTERN: &str = "%d{ISO8601} %5p [%t] %c{2}: %m%n";
21+
const HIVE_LOG_FILE: &str = "hive.log4j2.xml";
22+
23+
/// Renders `log4j2.properties` for the Hive metastore container.
24+
///
25+
/// Returns `None` when the Hive container does not use the operator's automatic logging
26+
/// configuration (e.g. a custom log ConfigMap is referenced instead), in which case no
27+
/// `log4j2.properties` should be added to the rolegroup `ConfigMap`.
28+
pub fn build_log4j2(logging: &Logging<Container>) -> Option<String> {
29+
match logging.containers.get(&Container::Hive) {
30+
Some(ContainerLogConfig {
31+
choice: Some(ContainerLogConfigChoice::Automatic(log_config)),
32+
}) => Some(log4j2_config(log_config)),
33+
_ => None,
34+
}
35+
}
36+
37+
/// Renders the Vector agent config (`vector.yaml`).
38+
///
39+
/// Returns `None` when the Vector agent is disabled for this role group.
40+
pub fn build_vector_config(
41+
rolegroup: &RoleGroupRef<v1alpha1::HiveCluster>,
42+
logging: &Logging<Container>,
43+
) -> Option<String> {
44+
if !logging.enable_vector_agent {
45+
return None;
46+
}
47+
48+
let vector_log_config = match logging.containers.get(&Container::Vector) {
49+
Some(ContainerLogConfig {
50+
choice: Some(ContainerLogConfigChoice::Automatic(log_config)),
51+
}) => Some(log_config),
52+
_ => None,
53+
};
54+
55+
Some(product_logging::framework::create_vector_config(
56+
rolegroup,
57+
vector_log_config,
58+
))
59+
}
60+
61+
fn log4j2_config(log_config: &AutomaticContainerLogConfig) -> String {
62+
product_logging::framework::create_log4j2_config(
63+
&format!(
64+
"{STACKABLE_LOG_DIR}/{container}",
65+
container = Container::Hive
66+
),
67+
HIVE_LOG_FILE,
68+
MAX_HIVE_LOG_FILES_SIZE
69+
.scale_to(BinaryMultiple::Mebi)
70+
.floor()
71+
.value as u32,
72+
CONSOLE_CONVERSION_PATTERN,
73+
log_config,
74+
)
75+
}

rust/operator-binary/src/controller/build/properties/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use stackable_operator::v2::config_overrides::KeyValueConfigOverrides;
66

77
pub mod core_site;
88
pub mod hive_site;
9+
pub mod logging;
910
pub mod security_properties;
1011

1112
/// Resolve user-provided key/value overrides into `(key, value)` pairs, dropping

rust/operator-binary/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ mod command;
4141
mod config;
4242
mod controller;
4343
mod crd;
44-
mod discovery;
4544
mod framework;
4645
mod kerberos;
4746
mod listener;
4847
mod operations;
49-
mod product_logging;
5048
mod service;
5149
mod webhooks;
5250

0 commit comments

Comments
 (0)