From f04c4dba707971671b8e85c6bfc06ba464b9b3eb Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 8 Feb 2023 17:42:50 +0100 Subject: [PATCH 01/33] wip - started logging --- deploy/helm/trino-operator/crds/crds.yaml | 320 +++++++++++++++++++- rust/crd/src/lib.rs | 57 +++- rust/operator-binary/src/command.rs | 4 +- rust/operator-binary/src/controller.rs | 215 ++++++++++--- rust/operator-binary/src/main.rs | 1 + rust/operator-binary/src/product_logging.rs | 148 +++++++++ 6 files changed, 685 insertions(+), 60 deletions(-) create mode 100644 rust/operator-binary/src/product_logging.rs diff --git a/deploy/helm/trino-operator/crds/crds.yaml b/deploy/helm/trino-operator/crds/crds.yaml index b100159a..e5a2b991 100644 --- a/deploy/helm/trino-operator/crds/crds.yaml +++ b/deploy/helm/trino-operator/crds/crds.yaml @@ -135,9 +135,82 @@ spec: config: default: {} properties: - logLevel: - nullable: true - type: string + logging: + default: + enableVectorAgent: null + containers: {} + properties: + containers: + additionalProperties: + anyOf: + - required: + - custom + - {} + description: Fragment derived from `ContainerLogConfigChoice` + properties: + console: + nullable: true + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + custom: + description: Custom log configuration provided in a ConfigMap + properties: + configMap: + nullable: true + type: string + type: object + file: + nullable: true + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + loggers: + additionalProperties: + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + default: {} + type: object + type: object + type: object + enableVectorAgent: + nullable: true + type: boolean + type: object queryMaxMemory: nullable: true type: string @@ -250,9 +323,82 @@ spec: config: default: {} properties: - logLevel: - nullable: true - type: string + logging: + default: + enableVectorAgent: null + containers: {} + properties: + containers: + additionalProperties: + anyOf: + - required: + - custom + - {} + description: Fragment derived from `ContainerLogConfigChoice` + properties: + console: + nullable: true + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + custom: + description: Custom log configuration provided in a ConfigMap + properties: + configMap: + nullable: true + type: string + type: object + file: + nullable: true + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + loggers: + additionalProperties: + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + default: {} + type: object + type: object + type: object + enableVectorAgent: + nullable: true + type: boolean + type: object queryMaxMemory: nullable: true type: string @@ -461,6 +607,10 @@ spec: description: Emergency stop button, if `true` then all pods are stopped without affecting configuration (as setting `replicas` to `0` would). nullable: true type: boolean + vectorAggregatorConfigMapName: + description: Name of the Vector aggregator discovery ConfigMap. It must contain the key `ADDRESS` with the address of the Vector aggregator. + nullable: true + type: string workers: description: Settings for the Worker Role/Process. nullable: true @@ -473,9 +623,82 @@ spec: config: default: {} properties: - logLevel: - nullable: true - type: string + logging: + default: + enableVectorAgent: null + containers: {} + properties: + containers: + additionalProperties: + anyOf: + - required: + - custom + - {} + description: Fragment derived from `ContainerLogConfigChoice` + properties: + console: + nullable: true + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + custom: + description: Custom log configuration provided in a ConfigMap + properties: + configMap: + nullable: true + type: string + type: object + file: + nullable: true + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + loggers: + additionalProperties: + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + default: {} + type: object + type: object + type: object + enableVectorAgent: + nullable: true + type: boolean + type: object queryMaxMemory: nullable: true type: string @@ -588,9 +811,82 @@ spec: config: default: {} properties: - logLevel: - nullable: true - type: string + logging: + default: + enableVectorAgent: null + containers: {} + properties: + containers: + additionalProperties: + anyOf: + - required: + - custom + - {} + description: Fragment derived from `ContainerLogConfigChoice` + properties: + console: + nullable: true + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + custom: + description: Custom log configuration provided in a ConfigMap + properties: + configMap: + nullable: true + type: string + type: object + file: + nullable: true + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + loggers: + additionalProperties: + properties: + level: + description: Log levels + enum: + - TRACE + - DEBUG + - INFO + - WARN + - ERROR + - FATAL + - NONE + nullable: true + type: string + type: object + default: {} + type: object + type: object + type: object + enableVectorAgent: + nullable: true + type: boolean + type: object queryMaxMemory: nullable: true type: string diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index cca12228..e133964a 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -2,16 +2,17 @@ pub mod authentication; pub mod catalog; pub mod discovery; -use crate::authentication::TrinoAuthenticationMethod; -use crate::{authentication::TrinoAuthentication, discovery::TrinoPodRef}; +use crate::{ + authentication::{TrinoAuthentication, TrinoAuthenticationMethod}, + discovery::TrinoPodRef, +}; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt, Snafu}; -use stackable_operator::commons::product_image_selection::ProductImage; -use stackable_operator::role_utils::RoleGroup; use stackable_operator::{ commons::{ opa::OpaConfig, + product_image_selection::ProductImage, resources::{ CpuLimitsFragment, MemoryLimitsFragment, NoRuntimeLimits, NoRuntimeLimitsFragment, PvcConfig, PvcConfigFragment, Resources, ResourcesFragment, @@ -25,11 +26,11 @@ use stackable_operator::{ k8s_openapi::apimachinery::pkg::{api::resource::Quantity, apis::meta::v1::LabelSelector}, kube::{runtime::reflector::ObjectRef, CustomResource, ResourceExt}, product_config_utils::{ConfigError, Configuration}, - role_utils::{Role, RoleGroupRef}, + product_logging::spec::{Logging, LoggingFragment}, + role_utils::{Role, RoleGroup, RoleGroupRef}, schemars::{self, JsonSchema}, }; -use std::collections::BTreeMap; -use std::str::FromStr; +use std::{collections::BTreeMap, str::FromStr}; use strum::{Display, EnumIter, EnumString, IntoEnumIterator}; pub const APP_NAME: &str = "trino"; @@ -193,6 +194,10 @@ pub struct TrinoClusterSpec { /// Use with caution. #[serde(default, skip_serializing_if = "Option::is_none")] pub service_type: Option, + /// Name of the Vector aggregator discovery ConfigMap. + /// It must contain the key `ADDRESS` with the address of the Vector aggregator. + #[serde(skip_serializing_if = "Option::is_none")] + pub vector_aggregator_config_map_name: Option, } // TODO: Temporary solution until listener-operator is finished @@ -322,6 +327,27 @@ pub struct TrinoStorageConfig { pub data: PvcConfig, } +#[derive( + Clone, + Debug, + Deserialize, + Display, + Eq, + EnumIter, + JsonSchema, + Ord, + PartialEq, + PartialOrd, + Serialize, +)] +#[serde(rename_all = "kebab-case")] +#[strum(serialize_all = "kebab-case")] +pub enum Container { + Prepare, + Vector, + Trino, +} + #[derive(Clone, Debug, Default, Fragment, JsonSchema, PartialEq)] #[fragment_attrs( derive( @@ -340,8 +366,8 @@ pub struct TrinoConfig { // config.properties pub query_max_memory: Option, pub query_max_memory_per_node: Option, - // log.properties - pub log_level: Option, + #[fragment_attrs(serde(default))] + pub logging: Logging, #[fragment_attrs(serde(default))] pub resources: Resources, } @@ -349,6 +375,12 @@ pub struct TrinoConfig { impl TrinoConfig { fn default_config() -> TrinoConfigFragment { TrinoConfigFragment { + // we can not use product_logging::spec::default_logging() here because it will + // add ROOT loggers that we do not want / need. + logging: LoggingFragment:: { + enable_vector_agent: Some(false), + containers: BTreeMap::new(), + }, resources: ResourcesFragment { cpu: CpuLimitsFragment { min: Some(Quantity("200m".to_owned())), @@ -537,9 +569,10 @@ impl Configuration for TrinoConfigFragment { // of the AuthenticationClass } LOG_PROPERTIES => { - if let Some(log_level) = &self.log_level { - result.insert(IO_TRINO.to_string(), Some(log_level.to_string())); - } + // TODO: set loglevels + // if let Some(log_level) = &self.log_level { + // result.insert(IO_TRINO.to_string(), Some(log_level.to_string())); + // } } _ => {} } diff --git a/rust/operator-binary/src/command.rs b/rust/operator-binary/src/command.rs index 4a625079..4000930a 100644 --- a/rust/operator-binary/src/command.rs +++ b/rust/operator-binary/src/command.rs @@ -50,7 +50,7 @@ pub fn container_prepare_args(trino: &TrinoCluster, catalogs: &[CatalogConfig]) args.extend_from_slice(&catalog.init_container_extra_start_commands); }); - vec![args.join(" && ")] + args } pub fn container_trino_args( @@ -80,7 +80,7 @@ pub fn container_trino_args( .collect::>() .join("\n"); - // FIXME: When we switch to AuthencationClass static we need to fix this to not have credentials in the Pod manifest (for now they are hashes). + // FIXME: When we switch to AuthenticationClass static we need to fix this to not have credentials in the Pod manifest (for now they are hashes). args.push(format!( "echo '{data}' > {path}/{db}", data = user_data, diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index ca7cb2f1..008d699e 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -5,8 +5,12 @@ use crate::{ config::password_authenticator_properties, }; +use crate::product_logging::{ + get_log_properties, get_vector_toml, resolve_vector_aggregator_address, +}; use indoc::formatdoc; use snafu::{OptionExt, ResultExt, Snafu}; +use stackable_operator::product_logging::spec::{ConfigMapLogConfig, CustomContainerLogConfig}; use stackable_operator::{ builder::{ ConfigMapBuilder, ContainerBuilder, ObjectMetaBuilder, PodBuilder, @@ -19,12 +23,14 @@ use stackable_operator::{ api::{ apps::v1::{StatefulSet, StatefulSetSpec}, core::v1::{ - ConfigMap, ConfigMapVolumeSource, ContainerPort, EnvVar, EnvVarSource, - PodSecurityContext, Probe, Secret, SecretKeySelector, Service, ServicePort, - ServiceSpec, TCPSocketAction, Volume, + ConfigMap, ConfigMapVolumeSource, ContainerPort, EmptyDirVolumeSource, EnvVar, + EnvVarSource, PodSecurityContext, Probe, Secret, SecretKeySelector, Service, + ServicePort, ServiceSpec, TCPSocketAction, Volume, }, }, - apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString}, + apimachinery::pkg::{ + api::resource::Quantity, apis::meta::v1::LabelSelector, util::intstr::IntOrString, + }, }, kube::{ runtime::{controller::Action, reflector::ObjectRef}, @@ -39,6 +45,10 @@ use stackable_operator::{ transform_all_roles_to_config, validate_all_roles_and_groups_config, ValidatedRoleConfigByPropertyKind, }, + product_logging::{ + self, + spec::{ContainerLogConfig, ContainerLogConfigChoice}, + }, role_utils::RoleGroupRef, }; use stackable_trino_crd::{ @@ -46,10 +56,10 @@ use stackable_trino_crd::{ authentication::TrinoAuthenticationConfig, catalog::TrinoCatalog, discovery::{TrinoDiscovery, TrinoDiscoveryProtocol, TrinoPodRef}, - TlsSecretClass, TrinoCluster, TrinoConfig, TrinoRole, ACCESS_CONTROL_PROPERTIES, APP_NAME, - CONFIG_DIR_NAME, CONFIG_PROPERTIES, DATA_DIR_NAME, DISCOVERY_URI, ENV_INTERNAL_SECRET, - HTTPS_PORT, HTTPS_PORT_NAME, HTTP_PORT, HTTP_PORT_NAME, JVM_CONFIG, JVM_HEAP_FACTOR, - LOG_PROPERTIES, METRICS_PORT, METRICS_PORT_NAME, NODE_PROPERTIES, + Container, TlsSecretClass, TrinoCluster, TrinoConfig, TrinoRole, ACCESS_CONTROL_PROPERTIES, + APP_NAME, CONFIG_DIR_NAME, CONFIG_PROPERTIES, DATA_DIR_NAME, DISCOVERY_URI, + ENV_INTERNAL_SECRET, HTTPS_PORT, HTTPS_PORT_NAME, HTTP_PORT, HTTP_PORT_NAME, JVM_CONFIG, + JVM_HEAP_FACTOR, LOG_PROPERTIES, METRICS_PORT, METRICS_PORT_NAME, NODE_PROPERTIES, PASSWORD_AUTHENTICATOR_PROPERTIES, PASSWORD_DB, RW_CONFIG_DIR_NAME, STACKABLE_CLIENT_TLS_DIR, STACKABLE_INTERNAL_TLS_DIR, STACKABLE_MOUNT_INTERNAL_TLS_DIR, STACKABLE_MOUNT_SERVER_TLS_DIR, STACKABLE_SERVER_TLS_DIR, STACKABLE_TLS_STORE_PASSWORD, USER_PASSWORD_DATA_DIR_NAME, @@ -71,6 +81,16 @@ pub struct Ctx { pub const OPERATOR_NAME: &str = "trino.stackable.tech"; pub const CONTROLLER_NAME: &str = "trinocluster"; +pub const STACKABLE_LOG_DIR: &str = "/stackable/log"; +pub const STACKABLE_LOG_CONFIG_DIR: &str = "/stackable/log_config"; + +pub const MAX_TRINO_LOG_FILES_SIZE_IN_MIB: u32 = 10; +const MAX_PREPARE_LOG_FILE_SIZE_IN_MIB: u32 = 1; +// Additional buffer space is not needed, as the `prepare` container already has sufficient buffer +// space and all containers share a single volume. +pub const LOG_VOLUME_SIZE_IN_MIB: u32 = + MAX_TRINO_LOG_FILES_SIZE_IN_MIB + MAX_PREPARE_LOG_FILE_SIZE_IN_MIB; + const DOCKER_IMAGE_BASE_NAME: &str = "trino"; #[derive(Snafu, Debug, EnumDiscriminants)] @@ -183,6 +203,15 @@ pub enum Error { }, #[snafu(display("failed to resolve and merge config for role and role group"))] FailedToResolveConfig { source: stackable_trino_crd::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, + }, } type Result = std::result::Result; @@ -270,6 +299,10 @@ pub async fn reconcile_trino(trino: Arc, ctx: Arc) -> Result< create_shared_internal_secret(&trino, client).await?; + let vector_aggregator_address = resolve_vector_aggregator_address(&trino, client) + .await + .context(ResolveVectorAggregatorAddressSnafu)?; + for (role, role_config) in validated_config { let trino_role = TrinoRole::from_str(&role).context(FailedToParseRoleSnafu)?; for (role_group, config) in role_config { @@ -289,6 +322,7 @@ pub async fn reconcile_trino(trino: Arc, ctx: Arc) -> Result< &merged_config, authentication_config.as_ref(), opa_connect_string.as_deref(), + vector_aggregator_address.as_deref(), )?; let rg_catalog_configmap = build_rolegroup_catalog_config_map( &trino, @@ -396,6 +430,7 @@ fn build_rolegroup_config_map( merged_config: &TrinoConfig, authentication_config: Option<&TrinoAuthenticationConfig>, opa_connect_string: Option<&str>, + vector_aggregator_address: Option<&str>, ) -> Result { let mut cm_conf_data = BTreeMap::new(); @@ -451,7 +486,12 @@ fn build_rolegroup_config_map( .context(MissingCoordinatorPodsSnafu)?; for (property_name_kind, config) in config { - let mut transformed_config: BTreeMap> = config + // We used this temporary map to add all dynamically resolved (e.g. discovery config maps) + // properties. This will be extended with the merged role group properties (transformed_config) + // to respect all possible override settings. + let mut dynamic_resolved_config = BTreeMap::>::new(); + + let transformed_config: BTreeMap> = config .iter() .map(|(k, v)| (k.clone(), Some(v.clone()))) .collect(); @@ -465,29 +505,65 @@ fn build_rolegroup_config_map( }; let discovery = TrinoDiscovery::new(&coordinator_ref, protocol); - transformed_config + dynamic_resolved_config .insert(DISCOVERY_URI.to_string(), Some(discovery.discovery_uri())); - let config_properties = - product_config::writer::to_java_properties_string(transformed_config.iter()) - .context(FailedToWriteJavaPropertiesSnafu)?; + dynamic_resolved_config.insert("log.format".to_string(), Some("json".to_string())); + // The path to the log file used by Trino + dynamic_resolved_config.insert( + "log.path".to_string(), + Some(format!("{STACKABLE_LOG_DIR}/server.log")), + ); + // The maximum number of general application log files to use, before log rotation replaces old content. + dynamic_resolved_config + .insert("log.max-history".to_string(), Some("2".to_string())); + // The maximum file size for the general application log file. + dynamic_resolved_config.insert( + "log.max-size".to_string(), + Some(MAX_TRINO_LOG_FILES_SIZE_IN_MIB.to_string()), + ); + + // Add static properties and overrides + dynamic_resolved_config.extend(transformed_config); + + let config_properties = product_config::writer::to_java_properties_string( + dynamic_resolved_config.iter(), + ) + .context(FailedToWriteJavaPropertiesSnafu)?; cm_conf_data.insert(file_name.to_string(), config_properties); } PropertyNameKind::File(file_name) if file_name == NODE_PROPERTIES => { - let node_properties = - product_config::writer::to_java_properties_string(transformed_config.iter()) - .context(FailedToWriteJavaPropertiesSnafu)?; + // Add static properties and overrides + dynamic_resolved_config.extend(transformed_config); + + let node_properties = product_config::writer::to_java_properties_string( + dynamic_resolved_config.iter(), + ) + .context(FailedToWriteJavaPropertiesSnafu)?; cm_conf_data.insert(file_name.to_string(), node_properties); } PropertyNameKind::File(file_name) if file_name == LOG_PROPERTIES => { - let log_properties = - product_config::writer::to_java_properties_string(transformed_config.iter()) - .context(FailedToWriteJavaPropertiesSnafu)?; + // No overrides required here, all settings can be set via logging options + if let Some(log_properties) = get_log_properties(&merged_config.logging) { + cm_conf_data.insert(file_name.to_string(), log_properties); + } - cm_conf_data.insert(file_name.to_string(), log_properties); + if let Some(vector_toml) = get_vector_toml( + rolegroup_ref, + vector_aggregator_address, + &merged_config.logging, + ) + .context(InvalidLoggingConfigSnafu { + cm_name: rolegroup_ref.object_name(), + })? { + cm_conf_data.insert( + product_logging::framework::VECTOR_CONFIG_FILE.to_string(), + vector_toml, + ); + } } // authentication is coordinator only PropertyNameKind::File(file_name) @@ -496,13 +572,18 @@ fn build_rolegroup_config_map( { // depending on authentication we need to add more properties if let Some(auth) = authentication_config { - password_authenticator_properties(&mut transformed_config, auth) + password_authenticator_properties(&mut dynamic_resolved_config, auth) .context(InvalidTrinoConfigSnafu)?; } + // Add static properties and overrides + dynamic_resolved_config.extend(transformed_config); + let pw_authenticator_properties = - product_config::writer::to_java_properties_string(transformed_config.iter()) - .context(FailedToWriteJavaPropertiesSnafu)?; + product_config::writer::to_java_properties_string( + dynamic_resolved_config.iter(), + ) + .context(FailedToWriteJavaPropertiesSnafu)?; cm_conf_data.insert(file_name.to_string(), pw_authenticator_properties); } @@ -622,16 +703,19 @@ fn build_rolegroup_statefulset( .rolegroup(rolegroup_ref) .context(InternalOperatorFailureSnafu)?; - let mut cb_trino = - ContainerBuilder::new(APP_NAME).with_context(|_| IllegalContainerNameSnafu { - container_name: APP_NAME.to_string(), - })?; - let mut cb_prepare = - ContainerBuilder::new("prepare").with_context(|_| IllegalContainerNameSnafu { - container_name: "prepare".to_string(), - })?; + let trino_container_name = Container::Trino.to_string(); + let mut cb_trino = ContainerBuilder::new(&trino_container_name).with_context(|_| { + IllegalContainerNameSnafu { + container_name: trino_container_name.clone(), + } + })?; + let prepare_container_name = Container::Prepare.to_string(); + let mut cb_prepare = ContainerBuilder::new(&prepare_container_name).with_context(|_| { + IllegalContainerNameSnafu { + container_name: prepare_container_name.clone(), + } + })?; let mut pod_builder = PodBuilder::new(); - pod_builder.node_selector_opt(rolegroup.selector.clone()); let mut env = config .get(&PropertyNameKind::Env) @@ -678,12 +762,27 @@ fn build_rolegroup_statefulset( catalogs, )?; + let mut prepare_args = vec![]; + if let Some(ContainerLogConfig { + choice: Some(ContainerLogConfigChoice::Automatic(log_config)), + }) = merged_config.logging.containers.get(&Container::Prepare) + { + prepare_args.push(product_logging::framework::capture_shell_output( + STACKABLE_LOG_DIR, + &prepare_container_name, + log_config, + )); + } + + prepare_args.extend(command::container_prepare_args(trino, catalogs)); + let container_prepare = cb_prepare .image_from_product_image(resolved_product_image) .command(vec!["/bin/bash".to_string(), "-c".to_string()]) - .args(command::container_prepare_args(trino, catalogs)) + .args(vec![prepare_args.join(" && ")]) .add_volume_mount("data", DATA_DIR_NAME) .add_volume_mount("rwconfig", RW_CONFIG_DIR_NAME) + .add_volume_mount("log", STACKABLE_LOG_DIR) .build(); let container_trino = cb_trino @@ -698,12 +797,52 @@ fn build_rolegroup_statefulset( .add_volume_mount("config", CONFIG_DIR_NAME) .add_volume_mount("rwconfig", RW_CONFIG_DIR_NAME) .add_volume_mount("catalog", format!("{}/catalog", CONFIG_DIR_NAME)) + .add_volume_mount("log-config", STACKABLE_LOG_CONFIG_DIR) + .add_volume_mount("log", STACKABLE_LOG_DIR) .add_container_ports(container_ports(trino)) .resources(merged_config.resources.clone().into()) .readiness_probe(readiness_probe(trino)) .liveness_probe(liveness_probe(trino)) .build(); + // add trino container first to better default into that container (e.g. instead of vector) + pod_builder.add_container(container_trino); + + if let Some(ContainerLogConfig { + choice: + Some(ContainerLogConfigChoice::Custom(CustomContainerLogConfig { + custom: ConfigMapLogConfig { config_map }, + })), + }) = merged_config.logging.containers.get(&Container::Trino) + { + pod_builder.add_volume(Volume { + name: "log-config".to_string(), + config_map: Some(ConfigMapVolumeSource { + name: Some(config_map.into()), + ..ConfigMapVolumeSource::default() + }), + ..Volume::default() + }); + } else { + pod_builder.add_volume(Volume { + name: "log-config".to_string(), + config_map: Some(ConfigMapVolumeSource { + name: Some(rolegroup_ref.object_name()), + ..ConfigMapVolumeSource::default() + }), + ..Volume::default() + }); + } + + if merged_config.logging.enable_vector_agent { + pod_builder.add_container(product_logging::framework::vector_container( + resolved_product_image, + "config", + "log", + merged_config.logging.containers.get(&Container::Vector), + )); + } + pod_builder .metadata_builder(|m| { m.with_recommended_labels(build_recommended_labels( @@ -714,8 +853,8 @@ fn build_rolegroup_statefulset( )) }) .image_pull_secrets_from_product_image(resolved_product_image) + .node_selector_opt(rolegroup.selector.clone()) .add_init_container(container_prepare) - .add_container(container_trino) .add_volume(Volume { name: "config".to_string(), config_map: Some(ConfigMapVolumeSource { @@ -733,6 +872,14 @@ fn build_rolegroup_statefulset( }), ..Volume::default() }) + .add_volume(Volume { + name: "log".to_string(), + empty_dir: Some(EmptyDirVolumeSource { + medium: None, + size_limit: Some(Quantity(format!("{LOG_VOLUME_SIZE_IN_MIB}Mi"))), + }), + ..Volume::default() + }) .security_context(PodSecurityContext { run_as_user: Some(1000), run_as_group: Some(1000), diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index e216d383..1bcac188 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -2,6 +2,7 @@ mod catalog; mod command; mod config; mod controller; +mod product_logging; use crate::controller::{CONTROLLER_NAME, OPERATOR_NAME}; diff --git a/rust/operator-binary/src/product_logging.rs b/rust/operator-binary/src/product_logging.rs new file mode 100644 index 00000000..33706ba1 --- /dev/null +++ b/rust/operator-binary/src/product_logging.rs @@ -0,0 +1,148 @@ +use snafu::{OptionExt, ResultExt, Snafu}; +use stackable_operator::product_logging::framework::create_vector_config; +use stackable_operator::{ + client::Client, + k8s_openapi::api::core::v1::ConfigMap, + kube::ResourceExt, + product_logging::spec::{ + AutomaticContainerLogConfig, ContainerLogConfig, ContainerLogConfigChoice, LogLevel, + Logging, + }, + role_utils::RoleGroupRef, +}; +use stackable_trino_crd::{Container, TrinoCluster}; +use strum::Display; + +#[derive(Snafu, Debug)] +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_trino_crd::Error }, + #[snafu(display("vectorAggregatorConfigMapName must be set"))] + MissingVectorAggregatorAddress, +} + +type Result = std::result::Result; + +const VECTOR_AGGREGATOR_CM_ENTRY: &str = "ADDRESS"; + +#[derive(Display)] +#[strum(serialize_all = "kebab-case")] +pub enum TrinoLogLevel { + Debug, + Info, + Warn, + Error, +} + +impl From for TrinoLogLevel { + fn from(level: LogLevel) -> Self { + match level { + LogLevel::TRACE | LogLevel::DEBUG => Self::Debug, + LogLevel::INFO => Self::Info, + LogLevel::WARN => Self::Warn, + LogLevel::ERROR | LogLevel::FATAL | LogLevel::NONE => Self::Error, + } + } +} + +/// Return the address of the Vector aggregator if the corresponding ConfigMap name is given in the +/// cluster spec +pub async fn resolve_vector_aggregator_address( + trino: &TrinoCluster, + client: &Client, +) -> Result> { + let vector_aggregator_address = if let Some(vector_aggregator_config_map_name) = + &trino.spec.vector_aggregator_config_map_name.as_ref() + { + let vector_aggregator_address = client + .get::( + vector_aggregator_config_map_name, + trino + .namespace() + .as_deref() + .context(ObjectHasNoNamespaceSnafu)?, + ) + .await + .context(ConfigMapNotFoundSnafu { + cm_name: vector_aggregator_config_map_name.to_string(), + })? + .data + .and_then(|mut data| data.remove(VECTOR_AGGREGATOR_CM_ENTRY)) + .context(MissingConfigMapEntrySnafu { + entry: VECTOR_AGGREGATOR_CM_ENTRY, + cm_name: vector_aggregator_config_map_name.to_string(), + })?; + Some(vector_aggregator_address) + } else { + None + }; + + Ok(vector_aggregator_address) +} + +/// Return the `log.properties` configuration +pub fn get_log_properties(logging: &Logging) -> Option { + if let Some(ContainerLogConfig { + choice: Some(ContainerLogConfigChoice::Automatic(log_config)), + }) = logging.containers.get(&Container::Trino) + { + Some(create_trino_log_properties(log_config)) + } else { + None + } +} + +/// Return the vector toml configuration +pub fn get_vector_toml( + rolegroup: &RoleGroupRef, + vector_aggregator_address: Option<&str>, + logging: &Logging, +) -> Result> { + let vector_log_config = if let Some(ContainerLogConfig { + choice: Some(ContainerLogConfigChoice::Automatic(log_config)), + }) = logging.containers.get(&Container::Vector) + { + Some(log_config) + } else { + None + }; + + if logging.enable_vector_agent { + Ok(Some(create_vector_config( + rolegroup, + vector_aggregator_address.context(MissingVectorAggregatorAddressSnafu)?, + vector_log_config, + ))) + } else { + Ok(None) + } +} + +/// Create trino `log.properties` containing loggers and their respective log levels. +/// The operator-rs framework `LogLevel` offers more choices which are parsed to the available +/// `TrinoLogLevel`. +/// +/// The `log.properties` will adhere to the example format: +/// ``` +/// io.trino=DEBUG +/// io.trino.server=INFO +/// ``` +fn create_trino_log_properties(automatic_container_config: &AutomaticContainerLogConfig) -> String { + automatic_container_config + .loggers + .iter() + .map(|(logger, config)| format!("{}={}\n", logger, TrinoLogLevel::from(config.level))) + .collect::() +} From 47bdf0b438c47179917adfede3579acfc2ff5222 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Thu, 9 Feb 2023 12:02:40 +0100 Subject: [PATCH 02/33] logified tests --- tests/templates/kuttl/ldap/00-assert.yaml.j2 | 10 ++ ...tor-aggregator-discovery-configmap.yaml.j2 | 9 ++ tests/templates/kuttl/ldap/01-assert.yaml | 12 +- ...openldap.yaml => 01-install-openldap.yaml} | 0 tests/templates/kuttl/ldap/02-assert.yaml | 12 +- ...dap-user.yaml => 02-create-ldap-user.yaml} | 0 .../ldap/{00-assert.yaml => 03-assert.yaml} | 2 +- ...-trino.yaml => 03-install-test-trino.yaml} | 0 .../kuttl/ldap/12-install-trino.yaml.j2 | 9 ++ .../templates/kuttl/logging/00-assert.yaml.j2 | 10 ++ ...tor-aggregator-discovery-configmap.yaml.j2 | 9 ++ .../04-assert.yaml => logging/01-assert.yaml} | 2 +- .../01-install-trino-vector-aggregator.yaml | 17 +++ tests/templates/kuttl/logging/02-assert.yaml | 36 ++++++ .../kuttl/logging/02-install-trino.yaml.j2 | 80 ++++++++++++++ tests/templates/kuttl/logging/03-assert.yaml | 12 ++ .../logging/03-install-trino-test-runner.yaml | 22 ++++ tests/templates/kuttl/logging/04-assert.yaml | 7 ++ .../logging/04-test-log-aggregation.yaml | 6 + .../kuttl/logging/test_log_aggregation.py | 41 +++++++ .../trino-vector-aggregator-values.yaml.j2 | 103 ++++++++++++++++++ .../orphaned-resources/00-assert.yaml.j2 | 10 ++ ...tor-aggregator-discovery-configmap.yaml.j2 | 9 ++ .../1-install-trino.yaml.j2 | 9 ++ .../kuttl/resources/00-assert.yaml.j2 | 10 ++ ...tor-aggregator-discovery-configmap.yaml.j2 | 9 ++ .../{10-assert.yaml => 10-assert.yaml.j2} | 6 + .../kuttl/resources/10-install-trino.yaml.j2 | 8 ++ tests/templates/kuttl/smoke/00-assert.yaml.j2 | 10 ++ ...tor-aggregator-discovery-configmap.yaml.j2 | 9 ++ ... => 01-install-minio-certificates.yaml.j2} | 0 ...minio.yaml.j2 => 02-install-minio.yaml.j2} | 0 .../smoke/{02-assert.yaml => 03-assert.yaml} | 0 ...ainer.yaml => 03-s3-upload-container.yaml} | 0 ...cket.yaml.j2 => 04-prepare-bucket.yaml.j2} | 0 tests/templates/kuttl/smoke/05-assert.yaml | 18 +-- ...r.yaml.j2 => 05-install-zookeeper.yaml.j2} | 8 ++ tests/templates/kuttl/smoke/06-assert.yaml | 18 ++- ...l-hdfs.yaml.j2 => 06-install-hdfs.yaml.j2} | 12 ++ tests/templates/kuttl/smoke/07-assert.yaml | 8 +- ...postgres.yaml => 07-install-postgres.yaml} | 0 tests/templates/kuttl/smoke/08-assert.yaml | 12 +- ...l-hive.yaml.j2 => 08-install-hive.yaml.j2} | 6 + tests/templates/kuttl/smoke/09-assert.yaml | 6 + ...all-opa.yaml.j2 => 09-install-opa.yaml.j2} | 0 .../kuttl/smoke/10-install-trino.yaml.j2 | 9 ++ tests/templates/kuttl/tls/00-assert.yaml.j2 | 10 ++ ...tor-aggregator-discovery-configmap.yaml.j2 | 9 ++ .../kuttl/tls/10-install-trino.yaml.j2 | 11 +- 49 files changed, 565 insertions(+), 41 deletions(-) create mode 100644 tests/templates/kuttl/ldap/00-assert.yaml.j2 create mode 100644 tests/templates/kuttl/ldap/00-install-vector-aggregator-discovery-configmap.yaml.j2 rename tests/templates/kuttl/ldap/{00-install-openldap.yaml => 01-install-openldap.yaml} (100%) rename tests/templates/kuttl/ldap/{01-create-ldap-user.yaml => 02-create-ldap-user.yaml} (100%) rename tests/templates/kuttl/ldap/{00-assert.yaml => 03-assert.yaml} (89%) rename tests/templates/kuttl/ldap/{02-install-test-trino.yaml => 03-install-test-trino.yaml} (100%) create mode 100644 tests/templates/kuttl/logging/00-assert.yaml.j2 create mode 100644 tests/templates/kuttl/logging/00-install-vector-aggregator-discovery-configmap.yaml.j2 rename tests/templates/kuttl/{smoke/04-assert.yaml => logging/01-assert.yaml} (82%) create mode 100644 tests/templates/kuttl/logging/01-install-trino-vector-aggregator.yaml create mode 100644 tests/templates/kuttl/logging/02-assert.yaml create mode 100644 tests/templates/kuttl/logging/02-install-trino.yaml.j2 create mode 100644 tests/templates/kuttl/logging/03-assert.yaml create mode 100644 tests/templates/kuttl/logging/03-install-trino-test-runner.yaml create mode 100644 tests/templates/kuttl/logging/04-assert.yaml create mode 100644 tests/templates/kuttl/logging/04-test-log-aggregation.yaml create mode 100755 tests/templates/kuttl/logging/test_log_aggregation.py create mode 100644 tests/templates/kuttl/logging/trino-vector-aggregator-values.yaml.j2 create mode 100644 tests/templates/kuttl/orphaned-resources/00-assert.yaml.j2 create mode 100644 tests/templates/kuttl/orphaned-resources/00-install-vector-aggregator-discovery-configmap.yaml.j2 create mode 100644 tests/templates/kuttl/resources/00-assert.yaml.j2 create mode 100644 tests/templates/kuttl/resources/00-install-vector-aggregator-discovery-configmap.yaml.j2 rename tests/templates/kuttl/resources/{10-assert.yaml => 10-assert.yaml.j2} (92%) create mode 100644 tests/templates/kuttl/smoke/00-assert.yaml.j2 create mode 100644 tests/templates/kuttl/smoke/00-install-vector-aggregator-discovery-configmap.yaml.j2 rename tests/templates/kuttl/smoke/{00-install-minio-certificates.yaml.j2 => 01-install-minio-certificates.yaml.j2} (100%) rename tests/templates/kuttl/smoke/{01-install-minio.yaml.j2 => 02-install-minio.yaml.j2} (100%) rename tests/templates/kuttl/smoke/{02-assert.yaml => 03-assert.yaml} (100%) rename tests/templates/kuttl/smoke/{02-s3-upload-container.yaml => 03-s3-upload-container.yaml} (100%) rename tests/templates/kuttl/smoke/{03-prepare-bucket.yaml.j2 => 04-prepare-bucket.yaml.j2} (100%) rename tests/templates/kuttl/smoke/{04-install-zookeeper.yaml.j2 => 05-install-zookeeper.yaml.j2} (57%) rename tests/templates/kuttl/smoke/{05-install-hdfs.yaml.j2 => 06-install-hdfs.yaml.j2} (60%) rename tests/templates/kuttl/smoke/{06-install-postgres.yaml => 07-install-postgres.yaml} (100%) rename tests/templates/kuttl/smoke/{07-install-hive.yaml.j2 => 08-install-hive.yaml.j2} (79%) create mode 100644 tests/templates/kuttl/smoke/09-assert.yaml rename tests/templates/kuttl/smoke/{08-install-opa.yaml.j2 => 09-install-opa.yaml.j2} (100%) create mode 100644 tests/templates/kuttl/tls/00-assert.yaml.j2 create mode 100644 tests/templates/kuttl/tls/00-install-vector-aggregator-discovery-configmap.yaml.j2 diff --git a/tests/templates/kuttl/ldap/00-assert.yaml.j2 b/tests/templates/kuttl/ldap/00-assert.yaml.j2 new file mode 100644 index 00000000..50b1d4c3 --- /dev/null +++ b/tests/templates/kuttl/ldap/00-assert.yaml.j2 @@ -0,0 +1,10 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +{% endif %} diff --git a/tests/templates/kuttl/ldap/00-install-vector-aggregator-discovery-configmap.yaml.j2 b/tests/templates/kuttl/ldap/00-install-vector-aggregator-discovery-configmap.yaml.j2 new file mode 100644 index 00000000..2d6a0df5 --- /dev/null +++ b/tests/templates/kuttl/ldap/00-install-vector-aggregator-discovery-configmap.yaml.j2 @@ -0,0 +1,9 @@ +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +data: + ADDRESS: {{ lookup('env', 'VECTOR_AGGREGATOR') }} +{% endif %} diff --git a/tests/templates/kuttl/ldap/01-assert.yaml b/tests/templates/kuttl/ldap/01-assert.yaml index 87d35778..9bcbc0e0 100644 --- a/tests/templates/kuttl/ldap/01-assert.yaml +++ b/tests/templates/kuttl/ldap/01-assert.yaml @@ -1,6 +1,12 @@ --- apiVersion: kuttl.dev/v1beta1 kind: TestAssert -commands: - - script: kubectl exec -n $NAMESPACE openldap-0 -- ldapsearch -H ldap://localhost:1389 -D cn=integrationtest,ou=users,dc=example,dc=org -w integrationtest -b ou=users,dc=example,dc=org > /dev/null - - script: kubectl exec -n $NAMESPACE openldap-0 -- bash -c LDAPTLS_CACERT=/tls/ca.crt ldapsearch -Z -H ldaps://localhost:1636 -D cn=integrationtest,ou=users,dc=example,dc=org -w integrationtest -b ou=users,dc=example,dc=org > /dev/null +timeout: 300 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: openldap +status: + readyReplicas: 1 + replicas: 1 diff --git a/tests/templates/kuttl/ldap/00-install-openldap.yaml b/tests/templates/kuttl/ldap/01-install-openldap.yaml similarity index 100% rename from tests/templates/kuttl/ldap/00-install-openldap.yaml rename to tests/templates/kuttl/ldap/01-install-openldap.yaml diff --git a/tests/templates/kuttl/ldap/02-assert.yaml b/tests/templates/kuttl/ldap/02-assert.yaml index 1257ec56..87d35778 100644 --- a/tests/templates/kuttl/ldap/02-assert.yaml +++ b/tests/templates/kuttl/ldap/02-assert.yaml @@ -1,12 +1,6 @@ --- apiVersion: kuttl.dev/v1beta1 kind: TestAssert -timeout: 300 ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: test-trino -status: - readyReplicas: 1 - replicas: 1 +commands: + - script: kubectl exec -n $NAMESPACE openldap-0 -- ldapsearch -H ldap://localhost:1389 -D cn=integrationtest,ou=users,dc=example,dc=org -w integrationtest -b ou=users,dc=example,dc=org > /dev/null + - script: kubectl exec -n $NAMESPACE openldap-0 -- bash -c LDAPTLS_CACERT=/tls/ca.crt ldapsearch -Z -H ldaps://localhost:1636 -D cn=integrationtest,ou=users,dc=example,dc=org -w integrationtest -b ou=users,dc=example,dc=org > /dev/null diff --git a/tests/templates/kuttl/ldap/01-create-ldap-user.yaml b/tests/templates/kuttl/ldap/02-create-ldap-user.yaml similarity index 100% rename from tests/templates/kuttl/ldap/01-create-ldap-user.yaml rename to tests/templates/kuttl/ldap/02-create-ldap-user.yaml diff --git a/tests/templates/kuttl/ldap/00-assert.yaml b/tests/templates/kuttl/ldap/03-assert.yaml similarity index 89% rename from tests/templates/kuttl/ldap/00-assert.yaml rename to tests/templates/kuttl/ldap/03-assert.yaml index 9bcbc0e0..1257ec56 100644 --- a/tests/templates/kuttl/ldap/00-assert.yaml +++ b/tests/templates/kuttl/ldap/03-assert.yaml @@ -6,7 +6,7 @@ timeout: 300 apiVersion: apps/v1 kind: StatefulSet metadata: - name: openldap + name: test-trino status: readyReplicas: 1 replicas: 1 diff --git a/tests/templates/kuttl/ldap/02-install-test-trino.yaml b/tests/templates/kuttl/ldap/03-install-test-trino.yaml similarity index 100% rename from tests/templates/kuttl/ldap/02-install-test-trino.yaml rename to tests/templates/kuttl/ldap/03-install-test-trino.yaml diff --git a/tests/templates/kuttl/ldap/12-install-trino.yaml.j2 b/tests/templates/kuttl/ldap/12-install-trino.yaml.j2 index 491d80ed..d7d77157 100644 --- a/tests/templates/kuttl/ldap/12-install-trino.yaml.j2 +++ b/tests/templates/kuttl/ldap/12-install-trino.yaml.j2 @@ -18,6 +18,9 @@ spec: productVersion: "{{ test_scenario['values']['trino-latest'].split('-stackable')[0] }}" stackableVersion: "{{ test_scenario['values']['trino-latest'].split('-stackable')[1] }}" catalogLabelSelector: {} +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + vectorAggregatorConfigMapName: vector-aggregator-discovery +{% endif %} authentication: method: {% if test_scenario['values']['ldap-use-tls'] == 'false' %} @@ -28,10 +31,16 @@ spec: authenticationClass: ldap-with-tls {% endif %} coordinators: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 workers: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 diff --git a/tests/templates/kuttl/logging/00-assert.yaml.j2 b/tests/templates/kuttl/logging/00-assert.yaml.j2 new file mode 100644 index 00000000..50b1d4c3 --- /dev/null +++ b/tests/templates/kuttl/logging/00-assert.yaml.j2 @@ -0,0 +1,10 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +{% endif %} diff --git a/tests/templates/kuttl/logging/00-install-vector-aggregator-discovery-configmap.yaml.j2 b/tests/templates/kuttl/logging/00-install-vector-aggregator-discovery-configmap.yaml.j2 new file mode 100644 index 00000000..2d6a0df5 --- /dev/null +++ b/tests/templates/kuttl/logging/00-install-vector-aggregator-discovery-configmap.yaml.j2 @@ -0,0 +1,9 @@ +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +data: + ADDRESS: {{ lookup('env', 'VECTOR_AGGREGATOR') }} +{% endif %} diff --git a/tests/templates/kuttl/smoke/04-assert.yaml b/tests/templates/kuttl/logging/01-assert.yaml similarity index 82% rename from tests/templates/kuttl/smoke/04-assert.yaml rename to tests/templates/kuttl/logging/01-assert.yaml index 49ba7437..2cc77be9 100644 --- a/tests/templates/kuttl/smoke/04-assert.yaml +++ b/tests/templates/kuttl/logging/01-assert.yaml @@ -6,7 +6,7 @@ timeout: 600 apiVersion: apps/v1 kind: StatefulSet metadata: - name: zookeeper-server-default + name: trino-vector-aggregator status: readyReplicas: 1 replicas: 1 diff --git a/tests/templates/kuttl/logging/01-install-trino-vector-aggregator.yaml b/tests/templates/kuttl/logging/01-install-trino-vector-aggregator.yaml new file mode 100644 index 00000000..07f01864 --- /dev/null +++ b/tests/templates/kuttl/logging/01-install-trino-vector-aggregator.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: >- + helm install trino-vector-aggregator vector + --namespace $NAMESPACE + --version 0.19.0 + --repo https://helm.vector.dev + --values trino-vector-aggregator-values.yaml +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +data: + ADDRESS: trino-vector-aggregator:6123 diff --git a/tests/templates/kuttl/logging/02-assert.yaml b/tests/templates/kuttl/logging/02-assert.yaml new file mode 100644 index 00000000..b0e91611 --- /dev/null +++ b/tests/templates/kuttl/logging/02-assert.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 600 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-trino-coordinator-automatic-log-config +status: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-trino-worker-automatic-log-config +status: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-trino-coordinator-custom-log-config +status: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-trino-worker-custom-log-config +status: + readyReplicas: 1 + replicas: 1 diff --git a/tests/templates/kuttl/logging/02-install-trino.yaml.j2 b/tests/templates/kuttl/logging/02-install-trino.yaml.j2 new file mode 100644 index 00000000..2c38d770 --- /dev/null +++ b/tests/templates/kuttl/logging/02-install-trino.yaml.j2 @@ -0,0 +1,80 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: trino-log-config +data: + logback.xml: | + io.trino=info + io.trino.server=debug +--- +apiVersion: trino.stackable.tech/v1alpha1 +kind: TrinoCluster +metadata: + name: test-trino +spec: + image: + productVersion: "{{ test_scenario['values']['trino'].split('-stackable')[0] }}" + stackableVersion: "{{ test_scenario['values']['trino'].split('-stackable')[1] }}" + catalogLabelSelector: {} +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + vectorAggregatorConfigMapName: vector-aggregator-discovery +{% endif %} + coordinators: + roleGroups: + automatic-log-config: + replicas: 1 + config: + logging: + enableVectorAgent: true + containers: + trino: + loggers: + io.trino: + level: INFO + vector: + console: + level: INFO + file: + level: INFO + loggers: + ROOT: + level: INFO + custom-log-config: + replicas: 1 + config: + logging: + enableVectorAgent: true + containers: + trino: + custom: + configMap: trino-log-config + workers: + roleGroups: + automatic-log-config: + replicas: 1 + config: + logging: + enableVectorAgent: true + containers: + trino: + loggers: + io.trino: + level: INFO + vector: + console: + level: INFO + file: + level: INFO + loggers: + ROOT: + level: INFO + custom-log-config: + replicas: 1 + config: + logging: + enableVectorAgent: true + containers: + trino: + custom: + configMap: trino-log-config diff --git a/tests/templates/kuttl/logging/03-assert.yaml b/tests/templates/kuttl/logging/03-assert.yaml new file mode 100644 index 00000000..d7bc9254 --- /dev/null +++ b/tests/templates/kuttl/logging/03-assert.yaml @@ -0,0 +1,12 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 300 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: trino-test-runner +status: + readyReplicas: 1 + replicas: 1 diff --git a/tests/templates/kuttl/logging/03-install-trino-test-runner.yaml b/tests/templates/kuttl/logging/03-install-trino-test-runner.yaml new file mode 100644 index 00000000..6a2c1614 --- /dev/null +++ b/tests/templates/kuttl/logging/03-install-trino-test-runner.yaml @@ -0,0 +1,22 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: trino-test-runner + labels: + app: trino-test-runner +spec: + replicas: 1 + selector: + matchLabels: + app: trino-test-runner + template: + metadata: + labels: + app: trino-test-runner + spec: + containers: + - name: trino-test-runner + image: docker.stackable.tech/stackable/testing-tools:0.1.0-stackable0.1.0 + stdin: true + tty: true diff --git a/tests/templates/kuttl/logging/04-assert.yaml b/tests/templates/kuttl/logging/04-assert.yaml new file mode 100644 index 00000000..d8105fe0 --- /dev/null +++ b/tests/templates/kuttl/logging/04-assert.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: >- + kubectl exec --namespace=$NAMESPACE trino-test-runner-0 -- + python /tmp/test_log_aggregation.py -n $NAMESPACE diff --git a/tests/templates/kuttl/logging/04-test-log-aggregation.yaml b/tests/templates/kuttl/logging/04-test-log-aggregation.yaml new file mode 100644 index 00000000..5ddac91f --- /dev/null +++ b/tests/templates/kuttl/logging/04-test-log-aggregation.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + kubectl cp ./test_log_aggregation.py $NAMESPACE/trino-test-runner-0:/tmp diff --git a/tests/templates/kuttl/logging/test_log_aggregation.py b/tests/templates/kuttl/logging/test_log_aggregation.py new file mode 100755 index 00000000..7077bb97 --- /dev/null +++ b/tests/templates/kuttl/logging/test_log_aggregation.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +import requests + + +def check_processed_events(): + response = requests.post( + 'http://trino-vector-aggregator:8686/graphql', + json={ + 'query': """ + { + transforms(first:100) { + nodes { + componentId + metrics { + processedEventsTotal { + processedEventsTotal + } + } + } + } + } + """ + } + ) + + assert response.status_code == 200, \ + 'Cannot access the API of the vector aggregator.' + + result = response.json() + + transforms = result['data']['transforms']['nodes'] + for transform in transforms: + processedEvents = transform['metrics']['processedEventsTotal']['processedEventsTotal'] + componentId = transform['componentId'] + assert processedEvents > 0, \ + f'No events were processed in "{componentId}".' + + +if __name__ == '__main__': + check_processed_events() + print('Test successful!') diff --git a/tests/templates/kuttl/logging/trino-vector-aggregator-values.yaml.j2 b/tests/templates/kuttl/logging/trino-vector-aggregator-values.yaml.j2 new file mode 100644 index 00000000..8a14e644 --- /dev/null +++ b/tests/templates/kuttl/logging/trino-vector-aggregator-values.yaml.j2 @@ -0,0 +1,103 @@ +--- +role: Aggregator +service: + ports: + - name: api + port: 8686 + protocol: TCP + targetPort: 8686 + - name: vector + port: 6123 + protocol: TCP + targetPort: 6000 +customConfig: + api: + address: 0.0.0.0:8686 + enabled: true + sources: + vector: + address: 0.0.0.0:6000 + type: vector + version: "2" + transforms: + automaticLogConfigCoordinatorTrino: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-coordinator-automatic-log-config-0" && + .container == "trino" + automaticLogConfigCoordinatorVector: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-coordinator-automatic-log-config-0" && + .container == "vector" + automaticLogConfigCoordinatorPrepare: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-coordinator-automatic-log-config-0" && + .container == "prepare" + automaticLogConfigWorkerTrino: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-worker-automatic-log-config-0" && + .container == "trino" + automaticLogConfigWorkerVector: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-worker-automatic-log-config-0" && + .container == "vector" + automaticLogConfigWorkerPrepare: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-worker-automatic-log-config-0" && + .container == "prepare" + customLogConfigCoordinatorTrino: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-coordinator-custom-log-config-0" && + .container == "trino" + customLogConfigCoordinatorVector: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-coordinator-custom-log-config-0" && + .container == "vector" + customLogConfigCoordinatorPrepare: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-coordinator-custom-log-config-0" && + .container == "prepare" + customLogConfigWorkerTrino: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-worker-custom-log-config-0" && + .container == "trino" + customLogConfigWorkerVector: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-worker-custom-log-config-0" && + .container == "vector" + customLogConfigWorkerPrepare: + type: filter + inputs: [vector] + condition: >- + .pod == "test-trino-worker-custom-log-config-0" && + .container == "prepare" + sinks: + out: + inputs: [automaticLogConfig*, customLogConfig*] +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + type: vector + address: {{ lookup('env', 'VECTOR_AGGREGATOR') }} +{% else %} + type: blackhole +{% endif %} diff --git a/tests/templates/kuttl/orphaned-resources/00-assert.yaml.j2 b/tests/templates/kuttl/orphaned-resources/00-assert.yaml.j2 new file mode 100644 index 00000000..50b1d4c3 --- /dev/null +++ b/tests/templates/kuttl/orphaned-resources/00-assert.yaml.j2 @@ -0,0 +1,10 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +{% endif %} diff --git a/tests/templates/kuttl/orphaned-resources/00-install-vector-aggregator-discovery-configmap.yaml.j2 b/tests/templates/kuttl/orphaned-resources/00-install-vector-aggregator-discovery-configmap.yaml.j2 new file mode 100644 index 00000000..2d6a0df5 --- /dev/null +++ b/tests/templates/kuttl/orphaned-resources/00-install-vector-aggregator-discovery-configmap.yaml.j2 @@ -0,0 +1,9 @@ +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +data: + ADDRESS: {{ lookup('env', 'VECTOR_AGGREGATOR') }} +{% endif %} diff --git a/tests/templates/kuttl/orphaned-resources/1-install-trino.yaml.j2 b/tests/templates/kuttl/orphaned-resources/1-install-trino.yaml.j2 index 5fc60815..570b1baf 100644 --- a/tests/templates/kuttl/orphaned-resources/1-install-trino.yaml.j2 +++ b/tests/templates/kuttl/orphaned-resources/1-install-trino.yaml.j2 @@ -8,13 +8,22 @@ spec: productVersion: "{{ test_scenario['values']['trino-latest'].split('-stackable')[0] }}" stackableVersion: "{{ test_scenario['values']['trino-latest'].split('-stackable')[1] }}" catalogLabelSelector: {} +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + vectorAggregatorConfigMapName: vector-aggregator-discovery +{% endif %} coordinators: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 remove: replicas: 1 workers: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 diff --git a/tests/templates/kuttl/resources/00-assert.yaml.j2 b/tests/templates/kuttl/resources/00-assert.yaml.j2 new file mode 100644 index 00000000..50b1d4c3 --- /dev/null +++ b/tests/templates/kuttl/resources/00-assert.yaml.j2 @@ -0,0 +1,10 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +{% endif %} diff --git a/tests/templates/kuttl/resources/00-install-vector-aggregator-discovery-configmap.yaml.j2 b/tests/templates/kuttl/resources/00-install-vector-aggregator-discovery-configmap.yaml.j2 new file mode 100644 index 00000000..2d6a0df5 --- /dev/null +++ b/tests/templates/kuttl/resources/00-install-vector-aggregator-discovery-configmap.yaml.j2 @@ -0,0 +1,9 @@ +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +data: + ADDRESS: {{ lookup('env', 'VECTOR_AGGREGATOR') }} +{% endif %} diff --git a/tests/templates/kuttl/resources/10-assert.yaml b/tests/templates/kuttl/resources/10-assert.yaml.j2 similarity index 92% rename from tests/templates/kuttl/resources/10-assert.yaml rename to tests/templates/kuttl/resources/10-assert.yaml.j2 index b9401ac0..2d806810 100644 --- a/tests/templates/kuttl/resources/10-assert.yaml +++ b/tests/templates/kuttl/resources/10-assert.yaml.j2 @@ -19,6 +19,9 @@ spec: limits: cpu: "4" memory: 2Gi +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + - name: vector +{% endif %} status: readyReplicas: 1 replicas: 1 @@ -56,6 +59,9 @@ spec: limits: cpu: 600m memory: 3Gi +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + - name: vector +{% endif %} status: readyReplicas: 1 replicas: 1 diff --git a/tests/templates/kuttl/resources/10-install-trino.yaml.j2 b/tests/templates/kuttl/resources/10-install-trino.yaml.j2 index f84daf2f..669821bd 100644 --- a/tests/templates/kuttl/resources/10-install-trino.yaml.j2 +++ b/tests/templates/kuttl/resources/10-install-trino.yaml.j2 @@ -8,12 +8,20 @@ spec: productVersion: "{{ test_scenario['values']['trino-latest'].split('-stackable')[0] }}" stackableVersion: "{{ test_scenario['values']['trino-latest'].split('-stackable')[1] }}" catalogLabelSelector: {} +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + vectorAggregatorConfigMapName: vector-aggregator-discovery +{% endif %} coordinators: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: resources-default: replicas: 1 workers: config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} resources: storage: data: diff --git a/tests/templates/kuttl/smoke/00-assert.yaml.j2 b/tests/templates/kuttl/smoke/00-assert.yaml.j2 new file mode 100644 index 00000000..50b1d4c3 --- /dev/null +++ b/tests/templates/kuttl/smoke/00-assert.yaml.j2 @@ -0,0 +1,10 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +{% endif %} diff --git a/tests/templates/kuttl/smoke/00-install-vector-aggregator-discovery-configmap.yaml.j2 b/tests/templates/kuttl/smoke/00-install-vector-aggregator-discovery-configmap.yaml.j2 new file mode 100644 index 00000000..2d6a0df5 --- /dev/null +++ b/tests/templates/kuttl/smoke/00-install-vector-aggregator-discovery-configmap.yaml.j2 @@ -0,0 +1,9 @@ +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +data: + ADDRESS: {{ lookup('env', 'VECTOR_AGGREGATOR') }} +{% endif %} diff --git a/tests/templates/kuttl/smoke/00-install-minio-certificates.yaml.j2 b/tests/templates/kuttl/smoke/01-install-minio-certificates.yaml.j2 similarity index 100% rename from tests/templates/kuttl/smoke/00-install-minio-certificates.yaml.j2 rename to tests/templates/kuttl/smoke/01-install-minio-certificates.yaml.j2 diff --git a/tests/templates/kuttl/smoke/01-install-minio.yaml.j2 b/tests/templates/kuttl/smoke/02-install-minio.yaml.j2 similarity index 100% rename from tests/templates/kuttl/smoke/01-install-minio.yaml.j2 rename to tests/templates/kuttl/smoke/02-install-minio.yaml.j2 diff --git a/tests/templates/kuttl/smoke/02-assert.yaml b/tests/templates/kuttl/smoke/03-assert.yaml similarity index 100% rename from tests/templates/kuttl/smoke/02-assert.yaml rename to tests/templates/kuttl/smoke/03-assert.yaml diff --git a/tests/templates/kuttl/smoke/02-s3-upload-container.yaml b/tests/templates/kuttl/smoke/03-s3-upload-container.yaml similarity index 100% rename from tests/templates/kuttl/smoke/02-s3-upload-container.yaml rename to tests/templates/kuttl/smoke/03-s3-upload-container.yaml diff --git a/tests/templates/kuttl/smoke/03-prepare-bucket.yaml.j2 b/tests/templates/kuttl/smoke/04-prepare-bucket.yaml.j2 similarity index 100% rename from tests/templates/kuttl/smoke/03-prepare-bucket.yaml.j2 rename to tests/templates/kuttl/smoke/04-prepare-bucket.yaml.j2 diff --git a/tests/templates/kuttl/smoke/05-assert.yaml b/tests/templates/kuttl/smoke/05-assert.yaml index 619a15ed..49ba7437 100644 --- a/tests/templates/kuttl/smoke/05-assert.yaml +++ b/tests/templates/kuttl/smoke/05-assert.yaml @@ -6,23 +6,7 @@ timeout: 600 apiVersion: apps/v1 kind: StatefulSet metadata: - name: hdfs-namenode-default -status: - readyReplicas: 2 - replicas: 2 ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: hdfs-journalnode-default -status: - readyReplicas: 1 - replicas: 1 ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: hdfs-datanode-default + name: zookeeper-server-default status: readyReplicas: 1 replicas: 1 diff --git a/tests/templates/kuttl/smoke/04-install-zookeeper.yaml.j2 b/tests/templates/kuttl/smoke/05-install-zookeeper.yaml.j2 similarity index 57% rename from tests/templates/kuttl/smoke/04-install-zookeeper.yaml.j2 rename to tests/templates/kuttl/smoke/05-install-zookeeper.yaml.j2 index 2aa98204..93d42569 100644 --- a/tests/templates/kuttl/smoke/04-install-zookeeper.yaml.j2 +++ b/tests/templates/kuttl/smoke/05-install-zookeeper.yaml.j2 @@ -7,7 +7,15 @@ spec: image: productVersion: "{{ test_scenario['values']['zookeeper'].split('-stackable')[0] }}" stackableVersion: "{{ test_scenario['values']['zookeeper'].split('-stackable')[1] }}" +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + clusterConfig: + logging: + vectorAggregatorConfigMapName: vector-aggregator-discovery +{% endif %} servers: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 diff --git a/tests/templates/kuttl/smoke/06-assert.yaml b/tests/templates/kuttl/smoke/06-assert.yaml index 1ac12423..619a15ed 100644 --- a/tests/templates/kuttl/smoke/06-assert.yaml +++ b/tests/templates/kuttl/smoke/06-assert.yaml @@ -6,7 +6,23 @@ timeout: 600 apiVersion: apps/v1 kind: StatefulSet metadata: - name: postgresql + name: hdfs-namenode-default +status: + readyReplicas: 2 + replicas: 2 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: hdfs-journalnode-default +status: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: hdfs-datanode-default status: readyReplicas: 1 replicas: 1 diff --git a/tests/templates/kuttl/smoke/05-install-hdfs.yaml.j2 b/tests/templates/kuttl/smoke/06-install-hdfs.yaml.j2 similarity index 60% rename from tests/templates/kuttl/smoke/05-install-hdfs.yaml.j2 rename to tests/templates/kuttl/smoke/06-install-hdfs.yaml.j2 index 28585962..d7773160 100644 --- a/tests/templates/kuttl/smoke/05-install-hdfs.yaml.j2 +++ b/tests/templates/kuttl/smoke/06-install-hdfs.yaml.j2 @@ -7,17 +7,29 @@ spec: image: productVersion: "{{ test_scenario['values']['hdfs'].split('-stackable')[0] }}" stackableVersion: "{{ test_scenario['values']['hdfs'].split('-stackable')[1] }}" +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + vectorAggregatorConfigMapName: vector-aggregator-discovery +{% endif %} zookeeperConfigMapName: hdfs-znode dfsReplication: 1 nameNodes: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 2 dataNodes: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 journalNodes: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 diff --git a/tests/templates/kuttl/smoke/07-assert.yaml b/tests/templates/kuttl/smoke/07-assert.yaml index b893d15b..1ac12423 100644 --- a/tests/templates/kuttl/smoke/07-assert.yaml +++ b/tests/templates/kuttl/smoke/07-assert.yaml @@ -1,12 +1,12 @@ --- apiVersion: kuttl.dev/v1beta1 kind: TestAssert -timeout: 900 +timeout: 600 --- apiVersion: apps/v1 kind: StatefulSet metadata: - name: hive-metastore-default + name: postgresql status: - readyReplicas: 2 - replicas: 2 + readyReplicas: 1 + replicas: 1 diff --git a/tests/templates/kuttl/smoke/06-install-postgres.yaml b/tests/templates/kuttl/smoke/07-install-postgres.yaml similarity index 100% rename from tests/templates/kuttl/smoke/06-install-postgres.yaml rename to tests/templates/kuttl/smoke/07-install-postgres.yaml diff --git a/tests/templates/kuttl/smoke/08-assert.yaml b/tests/templates/kuttl/smoke/08-assert.yaml index e868cdaf..b893d15b 100644 --- a/tests/templates/kuttl/smoke/08-assert.yaml +++ b/tests/templates/kuttl/smoke/08-assert.yaml @@ -1,6 +1,12 @@ --- apiVersion: kuttl.dev/v1beta1 kind: TestAssert -timeout: 300 -commands: - - script: kubectl -n $NAMESPACE rollout status daemonset opa-server-default --timeout 300s +timeout: 900 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: hive-metastore-default +status: + readyReplicas: 2 + replicas: 2 diff --git a/tests/templates/kuttl/smoke/07-install-hive.yaml.j2 b/tests/templates/kuttl/smoke/08-install-hive.yaml.j2 similarity index 79% rename from tests/templates/kuttl/smoke/07-install-hive.yaml.j2 rename to tests/templates/kuttl/smoke/08-install-hive.yaml.j2 index dac9df57..471aa321 100644 --- a/tests/templates/kuttl/smoke/07-install-hive.yaml.j2 +++ b/tests/templates/kuttl/smoke/08-install-hive.yaml.j2 @@ -37,7 +37,13 @@ spec: configMap: hdfs s3: reference: minio +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + vectorAggregatorConfigMapName: vector-aggregator-discovery +{% endif %} metastore: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 2 diff --git a/tests/templates/kuttl/smoke/09-assert.yaml b/tests/templates/kuttl/smoke/09-assert.yaml new file mode 100644 index 00000000..e868cdaf --- /dev/null +++ b/tests/templates/kuttl/smoke/09-assert.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 300 +commands: + - script: kubectl -n $NAMESPACE rollout status daemonset opa-server-default --timeout 300s diff --git a/tests/templates/kuttl/smoke/08-install-opa.yaml.j2 b/tests/templates/kuttl/smoke/09-install-opa.yaml.j2 similarity index 100% rename from tests/templates/kuttl/smoke/08-install-opa.yaml.j2 rename to tests/templates/kuttl/smoke/09-install-opa.yaml.j2 diff --git a/tests/templates/kuttl/smoke/10-install-trino.yaml.j2 b/tests/templates/kuttl/smoke/10-install-trino.yaml.j2 index 1ce27dd6..c67f4643 100644 --- a/tests/templates/kuttl/smoke/10-install-trino.yaml.j2 +++ b/tests/templates/kuttl/smoke/10-install-trino.yaml.j2 @@ -13,17 +13,26 @@ spec: opa: configMapName: opa package: trino +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + vectorAggregatorConfigMapName: vector-aggregator-discovery +{% endif %} authentication: method: multiUser: userCredentialsSecret: name: trino-users coordinators: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 config: {} workers: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 diff --git a/tests/templates/kuttl/tls/00-assert.yaml.j2 b/tests/templates/kuttl/tls/00-assert.yaml.j2 new file mode 100644 index 00000000..50b1d4c3 --- /dev/null +++ b/tests/templates/kuttl/tls/00-assert.yaml.j2 @@ -0,0 +1,10 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +{% endif %} diff --git a/tests/templates/kuttl/tls/00-install-vector-aggregator-discovery-configmap.yaml.j2 b/tests/templates/kuttl/tls/00-install-vector-aggregator-discovery-configmap.yaml.j2 new file mode 100644 index 00000000..2d6a0df5 --- /dev/null +++ b/tests/templates/kuttl/tls/00-install-vector-aggregator-discovery-configmap.yaml.j2 @@ -0,0 +1,9 @@ +{% if lookup('env', 'VECTOR_AGGREGATOR') %} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vector-aggregator-discovery +data: + ADDRESS: {{ lookup('env', 'VECTOR_AGGREGATOR') }} +{% endif %} diff --git a/tests/templates/kuttl/tls/10-install-trino.yaml.j2 b/tests/templates/kuttl/tls/10-install-trino.yaml.j2 index 044b35e8..9dec48e1 100644 --- a/tests/templates/kuttl/tls/10-install-trino.yaml.j2 +++ b/tests/templates/kuttl/tls/10-install-trino.yaml.j2 @@ -49,6 +49,9 @@ spec: productVersion: "{{ test_scenario['values']['trino-latest'].split('-stackable')[0] }}" stackableVersion: "{{ test_scenario['values']['trino-latest'].split('-stackable')[1] }}" catalogLabelSelector: {} +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + vectorAggregatorConfigMapName: vector-aggregator-discovery +{% endif %} config: {% if test_scenario['values']['use-tls'] == 'true' %} tls: @@ -70,12 +73,16 @@ spec: name: trino-users {% endif %} coordinators: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 - config: {} workers: + config: + logging: + enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} roleGroups: default: replicas: 1 - config: {} From a924d5095bab71c6bedcb0bbc6080c3e7933318e Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Thu, 9 Feb 2023 12:03:42 +0100 Subject: [PATCH 03/33] added logging test to test definition --- tests/test-definition.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test-definition.yaml b/tests/test-definition.yaml index fd13a1c3..f0907ad2 100644 --- a/tests/test-definition.yaml +++ b/tests/test-definition.yaml @@ -68,3 +68,6 @@ tests: - name: orphaned-resources dimensions: - trino-latest + - name: logging + dimensions: + - trino From f671e2d3422da65addcd173fdcce4fb2fdf49145 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Thu, 9 Feb 2023 12:03:53 +0100 Subject: [PATCH 04/33] added basic docs --- docs/modules/usage_guide/nav.adoc | 1 + .../usage_guide/pages/log-aggregation.adoc | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 docs/modules/usage_guide/pages/log-aggregation.adoc diff --git a/docs/modules/usage_guide/nav.adoc b/docs/modules/usage_guide/nav.adoc index 780d4491..7d3092ac 100644 --- a/docs/modules/usage_guide/nav.adoc +++ b/docs/modules/usage_guide/nav.adoc @@ -3,6 +3,7 @@ ** xref:configuration.adoc[] ** xref:security.adoc[] ** xref:monitoring.adoc[] +** xref:log-aggregation.adoc[] ** xref:query.adoc[] ** xref:catalogs/index.adoc[] *** xref:catalogs/black-hole.adoc[] diff --git a/docs/modules/usage_guide/pages/log-aggregation.adoc b/docs/modules/usage_guide/pages/log-aggregation.adoc new file mode 100644 index 00000000..ab2ddce5 --- /dev/null +++ b/docs/modules/usage_guide/pages/log-aggregation.adoc @@ -0,0 +1,18 @@ += Log aggregation + +The logs can be forwarded to a Vector log aggregator by providing a discovery +ConfigMap for the aggregator and by enabling the log agent: + +[source,yaml] +---- +spec: + clusterConfig: + vectorAggregatorConfigMapName: vector-aggregator-discovery + coordinators: + config: + logging: + enableVectorAgent: true +---- + +Further information on how to configure logging, can be found in +xref:home:concepts:logging.adoc[]. \ No newline at end of file From 75185680d19d4ba1de22a19437651203e18cad07 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Thu, 9 Feb 2023 12:36:07 +0100 Subject: [PATCH 05/33] wip --- rust/crd/src/lib.rs | 11 +++++++---- rust/operator-binary/src/controller.rs | 7 ++++--- .../templates/kuttl/logging/02-install-trino.yaml.j2 | 4 +--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index e133964a..206b6682 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -26,6 +26,7 @@ use stackable_operator::{ k8s_openapi::apimachinery::pkg::{api::resource::Quantity, apis::meta::v1::LabelSelector}, kube::{runtime::reflector::ObjectRef, CustomResource, ResourceExt}, product_config_utils::{ConfigError, Configuration}, + product_logging, product_logging::spec::{Logging, LoggingFragment}, role_utils::{Role, RoleGroup, RoleGroupRef}, schemars::{self, JsonSchema}, @@ -377,10 +378,12 @@ impl TrinoConfig { TrinoConfigFragment { // we can not use product_logging::spec::default_logging() here because it will // add ROOT loggers that we do not want / need. - logging: LoggingFragment:: { - enable_vector_agent: Some(false), - containers: BTreeMap::new(), - }, + // logging: LoggingFragment:: { + // enable_vector_agent: Some(false), + // containers: BTreeMap::new(), + // }, + // TODO: replace with correct defaults + logging: product_logging::spec::default_logging(), resources: ResourcesFragment { cpu: CpuLimitsFragment { min: Some(Quantity("200m".to_owned())), diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 008d699e..efc2b161 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -520,7 +520,7 @@ fn build_rolegroup_config_map( // The maximum file size for the general application log file. dynamic_resolved_config.insert( "log.max-size".to_string(), - Some(MAX_TRINO_LOG_FILES_SIZE_IN_MIB.to_string()), + Some(format!("{MAX_TRINO_LOG_FILES_SIZE_IN_MIB}MB")), ); // Add static properties and overrides @@ -762,6 +762,7 @@ fn build_rolegroup_statefulset( catalogs, )?; + // TODO: prepare default missing!!! let mut prepare_args = vec![]; if let Some(ContainerLogConfig { choice: Some(ContainerLogConfigChoice::Automatic(log_config)), @@ -1015,8 +1016,8 @@ fn env_var_from_secret(secret_name: &str, secret_key: Option<&str>, env_var: &st /// The roles and their configs are then validated and complemented by the product config. /// /// # Arguments -/// * `resource` - The NifiCluster containing the role definitions. -/// * `version` - The NifiCluster version. +/// * `resource` - The TrinoCluster containing the role definitions. +/// * `version` - The TrinoCluster version. /// * `product_config` - The product config to validate and complement the user config. /// fn validated_product_config( diff --git a/tests/templates/kuttl/logging/02-install-trino.yaml.j2 b/tests/templates/kuttl/logging/02-install-trino.yaml.j2 index 2c38d770..e8795da0 100644 --- a/tests/templates/kuttl/logging/02-install-trino.yaml.j2 +++ b/tests/templates/kuttl/logging/02-install-trino.yaml.j2 @@ -4,7 +4,7 @@ kind: ConfigMap metadata: name: trino-log-config data: - logback.xml: | + log.properties: | io.trino=info io.trino.server=debug --- @@ -17,9 +17,7 @@ spec: productVersion: "{{ test_scenario['values']['trino'].split('-stackable')[0] }}" stackableVersion: "{{ test_scenario['values']['trino'].split('-stackable')[1] }}" catalogLabelSelector: {} -{% if lookup('env', 'VECTOR_AGGREGATOR') %} vectorAggregatorConfigMapName: vector-aggregator-discovery -{% endif %} coordinators: roleGroups: automatic-log-config: From 7cb6fae429ea87acd57b4b382db98762e84d7543 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Thu, 9 Feb 2023 12:37:21 +0100 Subject: [PATCH 06/33] change trino logging directory --- rust/operator-binary/src/controller.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index efc2b161..97bd4cfa 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -512,7 +512,10 @@ fn build_rolegroup_config_map( // The path to the log file used by Trino dynamic_resolved_config.insert( "log.path".to_string(), - Some(format!("{STACKABLE_LOG_DIR}/server.log")), + Some(format!( + "{STACKABLE_LOG_DIR}/{container}/server.log", + container = Container::Trino.to_string() + )), ); // The maximum number of general application log files to use, before log rotation replaces old content. dynamic_resolved_config From 637e2d496341ec730232b4a79e766c5829104853 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Thu, 9 Feb 2023 12:44:50 +0100 Subject: [PATCH 07/33] move http-request log to /stackable/log --- rust/operator-binary/src/controller.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 97bd4cfa..49630e50 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -85,11 +85,13 @@ pub const STACKABLE_LOG_DIR: &str = "/stackable/log"; pub const STACKABLE_LOG_CONFIG_DIR: &str = "/stackable/log_config"; pub const MAX_TRINO_LOG_FILES_SIZE_IN_MIB: u32 = 10; +pub const MAX_TRINO_HTTP_SERVER_LOG_FILES_SIZE_IN_MIB: u32 = 10; const MAX_PREPARE_LOG_FILE_SIZE_IN_MIB: u32 = 1; // Additional buffer space is not needed, as the `prepare` container already has sufficient buffer // space and all containers share a single volume. -pub const LOG_VOLUME_SIZE_IN_MIB: u32 = - MAX_TRINO_LOG_FILES_SIZE_IN_MIB + MAX_PREPARE_LOG_FILE_SIZE_IN_MIB; +pub const LOG_VOLUME_SIZE_IN_MIB: u32 = MAX_TRINO_LOG_FILES_SIZE_IN_MIB + + MAX_PREPARE_LOG_FILE_SIZE_IN_MIB + + MAX_TRINO_HTTP_SERVER_LOG_FILES_SIZE_IN_MIB; const DOCKER_IMAGE_BASE_NAME: &str = "trino"; @@ -526,6 +528,24 @@ fn build_rolegroup_config_map( Some(format!("{MAX_TRINO_LOG_FILES_SIZE_IN_MIB}MB")), ); + dynamic_resolved_config.insert( + "http-server.log.path".to_string(), + Some(format!( + "{STACKABLE_LOG_DIR}/{container}/http-request.log", + container = Container::Trino.to_string() + )), + ); + // The maximum number of log files for the HTTP server to use, before log rotation replaces old content. + dynamic_resolved_config.insert( + "http-server.log.max-history".to_string(), + Some("2".to_string()), + ); + // The maximum file size for the log file of the HTTP server. + dynamic_resolved_config.insert( + "http-server.log.max-size".to_string(), + Some(format!("{MAX_TRINO_HTTP_SERVER_LOG_FILES_SIZE_IN_MIB}MB")), + ); + // Add static properties and overrides dynamic_resolved_config.extend(transformed_config); From 387ecf7b061dd101c8e1d7f36eb2af359ea0cdc2 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 10 Feb 2023 16:37:29 +0100 Subject: [PATCH 08/33] disabled http-request.log renamed server.log to server.airlift.json --- rust/crd/src/lib.rs | 43 +++++++++++++++++--------- rust/operator-binary/src/controller.rs | 24 ++------------ 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index 206b6682..6be5247b 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -27,7 +27,10 @@ use stackable_operator::{ kube::{runtime::reflector::ObjectRef, CustomResource, ResourceExt}, product_config_utils::{ConfigError, Configuration}, product_logging, - product_logging::spec::{Logging, LoggingFragment}, + product_logging::spec::{ + AutomaticContainerLogConfigFragment, ContainerLogConfigChoiceFragment, + ContainerLogConfigFragment, Logging, LoggingFragment, + }, role_utils::{Role, RoleGroup, RoleGroupRef}, schemars::{self, JsonSchema}, }; @@ -375,15 +378,23 @@ pub struct TrinoConfig { impl TrinoConfig { fn default_config() -> TrinoConfigFragment { + // We remove the default ROOT_LOGGER config from the trino container + // It is not required + let mut default_logging: LoggingFragment = + product_logging::spec::default_logging(); + if let Some(ContainerLogConfigFragment { + choice: + Some(ContainerLogConfigChoiceFragment::Automatic(AutomaticContainerLogConfigFragment { + loggers: config, + .. + })), + }) = default_logging.containers.get_mut(&Container::Trino) + { + config.clear(); + } + TrinoConfigFragment { - // we can not use product_logging::spec::default_logging() here because it will - // add ROOT loggers that we do not want / need. - // logging: LoggingFragment:: { - // enable_vector_agent: Some(false), - // containers: BTreeMap::new(), - // }, - // TODO: replace with correct defaults - logging: product_logging::spec::default_logging(), + logging: default_logging, resources: ResourcesFragment { cpu: CpuLimitsFragment { min: Some(Quantity("200m".to_owned())), @@ -464,6 +475,13 @@ impl Configuration for TrinoConfigFragment { Some(query_max_memory_per_node.to_string()), ); } + + // disable http-request logs + result.insert( + "http-server.log.enabled".to_string(), + Some("false".to_string()), + ); + // Always use the internal secret (base64) result.insert( INTERNAL_COMMUNICATION_SHARED_SECRET.to_string(), @@ -571,12 +589,7 @@ impl Configuration for TrinoConfigFragment { // This is filled in rust/operator-binary/src/config.rs due to required resolving // of the AuthenticationClass } - LOG_PROPERTIES => { - // TODO: set loglevels - // if let Some(log_level) = &self.log_level { - // result.insert(IO_TRINO.to_string(), Some(log_level.to_string())); - // } - } + LOG_PROPERTIES => {} _ => {} } diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 49630e50..80e9e592 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -85,13 +85,11 @@ pub const STACKABLE_LOG_DIR: &str = "/stackable/log"; pub const STACKABLE_LOG_CONFIG_DIR: &str = "/stackable/log_config"; pub const MAX_TRINO_LOG_FILES_SIZE_IN_MIB: u32 = 10; -pub const MAX_TRINO_HTTP_SERVER_LOG_FILES_SIZE_IN_MIB: u32 = 10; const MAX_PREPARE_LOG_FILE_SIZE_IN_MIB: u32 = 1; // Additional buffer space is not needed, as the `prepare` container already has sufficient buffer // space and all containers share a single volume. pub const LOG_VOLUME_SIZE_IN_MIB: u32 = MAX_TRINO_LOG_FILES_SIZE_IN_MIB - + MAX_PREPARE_LOG_FILE_SIZE_IN_MIB - + MAX_TRINO_HTTP_SERVER_LOG_FILES_SIZE_IN_MIB; + + MAX_PREPARE_LOG_FILE_SIZE_IN_MIB; const DOCKER_IMAGE_BASE_NAME: &str = "trino"; @@ -515,7 +513,7 @@ fn build_rolegroup_config_map( dynamic_resolved_config.insert( "log.path".to_string(), Some(format!( - "{STACKABLE_LOG_DIR}/{container}/server.log", + "{STACKABLE_LOG_DIR}/{container}/server.airlift.json", container = Container::Trino.to_string() )), ); @@ -528,24 +526,6 @@ fn build_rolegroup_config_map( Some(format!("{MAX_TRINO_LOG_FILES_SIZE_IN_MIB}MB")), ); - dynamic_resolved_config.insert( - "http-server.log.path".to_string(), - Some(format!( - "{STACKABLE_LOG_DIR}/{container}/http-request.log", - container = Container::Trino.to_string() - )), - ); - // The maximum number of log files for the HTTP server to use, before log rotation replaces old content. - dynamic_resolved_config.insert( - "http-server.log.max-history".to_string(), - Some("2".to_string()), - ); - // The maximum file size for the log file of the HTTP server. - dynamic_resolved_config.insert( - "http-server.log.max-size".to_string(), - Some(format!("{MAX_TRINO_HTTP_SERVER_LOG_FILES_SIZE_IN_MIB}MB")), - ); - // Add static properties and overrides dynamic_resolved_config.extend(transformed_config); From 2ccac4de47856980ee130818fecd26cc8ba48d32 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 10 Feb 2023 17:17:35 +0100 Subject: [PATCH 09/33] adapted changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f61deef6..ba5dcccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,15 @@ All notable changes to this project will be documented in this file. - `operator-rs` `0.31.0` -> `0.33.0` ([#378]). - Bumped stackable image versions to "23.4.0-rc1" ([#378]). - Fragmented `TrinoConfig` ([#379]). +- Enabled logging and log aggregation ([#380]). + +### Removed + +- [BREAKING]: Removed `log_level` from `TrinoConfig` which is now set via the logging framework struct ([#380]). [#378]: https://github.com/stackabletech/trino-operator/pull/378 [#379]: https://github.com/stackabletech/trino-operator/pull/379 +[#380]: https://github.com/stackabletech/trino-operator/pull/380 ## [23.1.0] - 2023-01-23 From 3b377397b1d3fc429efa1dea9f2a8fc7cc0b6773 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 10 Feb 2023 17:19:44 +0100 Subject: [PATCH 10/33] updated test definitions --- tests/test-definition.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test-definition.yaml b/tests/test-definition.yaml index f0907ad2..63f187c6 100644 --- a/tests/test-definition.yaml +++ b/tests/test-definition.yaml @@ -2,14 +2,14 @@ dimensions: - name: trino values: - - 377-stackable23.4.0-rc1 - - 387-stackable23.4.0-rc1 - - 395-stackable23.4.0-rc1 - - 396-stackable23.4.0-rc1 - - 403-stackable23.4.0-rc1 + - 377-stackable23.4.0-rc2 + - 387-stackable23.4.0-rc2 + - 395-stackable23.4.0-rc2 + - 396-stackable23.4.0-rc2 + - 403-stackable23.4.0-rc2 - name: trino-latest values: - - 403-stackable23.4.0-rc1 + - 403-stackable23.4.0-rc2 - name: hive values: - 2.3.9-stackable23.4.0-rc1 From 48475b2a17cfb61ccebfb13d213e6c7e083820cd Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Fri, 10 Feb 2023 17:37:03 +0100 Subject: [PATCH 11/33] switch to stackable version "23.4.0-rc2" --- .../getting_started/examples/code/trino.yaml | 2 +- .../usage_guide/examples/code/trino-insecure.yaml | 2 +- .../examples/code/trino-secure-internal-tls.yaml | 2 +- .../examples/code/trino-secure-tls-only.yaml | 2 +- .../examples/code/trino-secure-tls.yaml | 2 +- docs/modules/usage_guide/pages/catalogs/index.adoc | 2 +- ...luster-authentication-opa-authorization-s3.yaml | 2 +- examples/simple-trino-cluster-hive-ha-s3.yaml | 2 +- examples/simple-trino-cluster-resource-limits.yaml | 2 +- examples/simple-trino-cluster-s3.yaml | 2 +- examples/simple-trino-cluster.yaml | 2 +- rust/crd/src/lib.rs | 14 +++++++------- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/modules/getting_started/examples/code/trino.yaml b/docs/modules/getting_started/examples/code/trino.yaml index 518984d0..69f624bc 100644 --- a/docs/modules/getting_started/examples/code/trino.yaml +++ b/docs/modules/getting_started/examples/code/trino.yaml @@ -6,7 +6,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: matchLabels: trino: simple-trino diff --git a/docs/modules/usage_guide/examples/code/trino-insecure.yaml b/docs/modules/usage_guide/examples/code/trino-insecure.yaml index 4ef6c95f..8fa3b5a2 100644 --- a/docs/modules/usage_guide/examples/code/trino-insecure.yaml +++ b/docs/modules/usage_guide/examples/code/trino-insecure.yaml @@ -18,7 +18,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: matchLabels: trino: simple-trino diff --git a/docs/modules/usage_guide/examples/code/trino-secure-internal-tls.yaml b/docs/modules/usage_guide/examples/code/trino-secure-internal-tls.yaml index b36ccf55..b2d14501 100644 --- a/docs/modules/usage_guide/examples/code/trino-secure-internal-tls.yaml +++ b/docs/modules/usage_guide/examples/code/trino-secure-internal-tls.yaml @@ -18,7 +18,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" config: internalTls: secretClass: trino-internal-tls # <1> diff --git a/docs/modules/usage_guide/examples/code/trino-secure-tls-only.yaml b/docs/modules/usage_guide/examples/code/trino-secure-tls-only.yaml index a8e91919..1d46c045 100644 --- a/docs/modules/usage_guide/examples/code/trino-secure-tls-only.yaml +++ b/docs/modules/usage_guide/examples/code/trino-secure-tls-only.yaml @@ -18,7 +18,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" config: tls: secretClass: trino-tls # <1> diff --git a/docs/modules/usage_guide/examples/code/trino-secure-tls.yaml b/docs/modules/usage_guide/examples/code/trino-secure-tls.yaml index 33870852..46d4dc05 100644 --- a/docs/modules/usage_guide/examples/code/trino-secure-tls.yaml +++ b/docs/modules/usage_guide/examples/code/trino-secure-tls.yaml @@ -18,7 +18,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" config: tls: secretClass: trino-tls # <1> diff --git a/docs/modules/usage_guide/pages/catalogs/index.adoc b/docs/modules/usage_guide/pages/catalogs/index.adoc index de3263da..64c3b631 100644 --- a/docs/modules/usage_guide/pages/catalogs/index.adoc +++ b/docs/modules/usage_guide/pages/catalogs/index.adoc @@ -71,7 +71,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: matchLabels: trino: simple-trino diff --git a/examples/simple-trino-cluster-authentication-opa-authorization-s3.yaml b/examples/simple-trino-cluster-authentication-opa-authorization-s3.yaml index 62fb171c..9779ae2b 100644 --- a/examples/simple-trino-cluster-authentication-opa-authorization-s3.yaml +++ b/examples/simple-trino-cluster-authentication-opa-authorization-s3.yaml @@ -6,7 +6,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" opa: configMapName: simple-opa package: trino diff --git a/examples/simple-trino-cluster-hive-ha-s3.yaml b/examples/simple-trino-cluster-hive-ha-s3.yaml index b563c6c0..3609a025 100644 --- a/examples/simple-trino-cluster-hive-ha-s3.yaml +++ b/examples/simple-trino-cluster-hive-ha-s3.yaml @@ -10,7 +10,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: matchLabels: trino: simple-trino diff --git a/examples/simple-trino-cluster-resource-limits.yaml b/examples/simple-trino-cluster-resource-limits.yaml index 470122ff..ed533a24 100644 --- a/examples/simple-trino-cluster-resource-limits.yaml +++ b/examples/simple-trino-cluster-resource-limits.yaml @@ -6,7 +6,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: {} coordinators: roleGroups: diff --git a/examples/simple-trino-cluster-s3.yaml b/examples/simple-trino-cluster-s3.yaml index f9a923d8..13caffb7 100644 --- a/examples/simple-trino-cluster-s3.yaml +++ b/examples/simple-trino-cluster-s3.yaml @@ -8,7 +8,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: matchLabels: trino: simple-trino diff --git a/examples/simple-trino-cluster.yaml b/examples/simple-trino-cluster.yaml index 7234643f..8db05dd0 100644 --- a/examples/simple-trino-cluster.yaml +++ b/examples/simple-trino-cluster.yaml @@ -6,7 +6,7 @@ metadata: spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: matchLabels: trino: simple-trino diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index 6be5247b..fdbbb99f 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -756,7 +756,7 @@ mod tests { spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: {} "#; let trino: TrinoCluster = serde_yaml::from_str(input).expect("illegal test input"); @@ -777,7 +777,7 @@ mod tests { spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: {} config: tls: @@ -801,7 +801,7 @@ mod tests { spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: {} config: tls: null @@ -821,7 +821,7 @@ mod tests { spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: {} config: internalTls: @@ -848,7 +848,7 @@ mod tests { spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: {} "#; let trino: TrinoCluster = serde_yaml::from_str(input).expect("illegal test input"); @@ -869,7 +869,7 @@ mod tests { spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: {} config: internalTls: @@ -893,7 +893,7 @@ mod tests { spec: image: productVersion: "396" - stackableVersion: "23.4.0-rc1" + stackableVersion: "23.4.0-rc2" catalogLabelSelector: {} config: tls: From e0027bd2f904a6bbaed4ce916bde3528ed562e5b Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Mon, 13 Feb 2023 10:10:53 +0100 Subject: [PATCH 12/33] documented limitations of logging --- docs/modules/usage_guide/pages/log-aggregation.adoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/modules/usage_guide/pages/log-aggregation.adoc b/docs/modules/usage_guide/pages/log-aggregation.adoc index ab2ddce5..1332afa7 100644 --- a/docs/modules/usage_guide/pages/log-aggregation.adoc +++ b/docs/modules/usage_guide/pages/log-aggregation.adoc @@ -12,7 +12,14 @@ spec: config: logging: enableVectorAgent: true + containers: + trino: + loggers: + io.trino: + level: INFO ---- +Currently, the logs are collected only for `server.log`. Logging for `http-request.log` is disabled by default. + Further information on how to configure logging, can be found in xref:home:concepts:logging.adoc[]. \ No newline at end of file From a490d7d0a8849aee5d802adf05f7544cd4fc01ab Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Mon, 13 Feb 2023 10:42:12 +0100 Subject: [PATCH 13/33] use operator-rs 0.35.0 --- CHANGELOG.md | 4 +- Cargo.lock | 84 ++++++++++++++++----------------- rust/crd/Cargo.toml | 2 +- rust/operator-binary/Cargo.toml | 4 +- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba5dcccf..4421b29c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,8 @@ All notable changes to this project will be documented in this file. ### Changed -- `operator-rs` `0.31.0` -> `0.33.0` ([#378]). -- Bumped stackable image versions to "23.4.0-rc1" ([#378]). +- `operator-rs` `0.31.0` -> `0.35.0` ([#378], [#380]). +- Bumped stackable image versions to `23.4.0-rc1` and `23.4.0-rc2` ([#378], [#380]). - Fragmented `TrinoConfig` ([#379]). - Enabled logging and log aggregation ([#380]). diff --git a/Cargo.lock b/Cargo.lock index aa71885f..5b3d7446 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.32" +version = "4.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" +checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" dependencies = [ "bitflags", "clap_derive", @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.0.21" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" dependencies = [ "heck", "proc-macro-error", @@ -401,9 +401,9 @@ checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "encoding" @@ -538,9 +538,9 @@ checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" [[package]] name = "futures" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" dependencies = [ "futures-channel", "futures-core", @@ -553,9 +553,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" dependencies = [ "futures-core", "futures-sink", @@ -563,15 +563,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" dependencies = [ "futures-core", "futures-task", @@ -580,15 +580,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" dependencies = [ "proc-macro2", "quote", @@ -597,15 +597,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" [[package]] name = "futures-timer" @@ -615,9 +615,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ "futures 0.1.31", "futures-channel", @@ -969,7 +969,7 @@ dependencies = [ "chrono", "dirs-next", "either", - "futures 0.3.25", + "futures 0.3.26", "http", "http-body", "hyper", @@ -1033,7 +1033,7 @@ dependencies = [ "ahash", "backoff", "derivative", - "futures 0.3.25", + "futures 0.3.26", "json-patch", "k8s-openapi", "kube-client", @@ -1261,7 +1261,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e785d273968748578931e4dc3b4f5ec86b26e09d9e0d66b55adda7fce742f7a" dependencies = [ "async-trait", - "futures 0.3.25", + "futures 0.3.26", "futures-executor", "once_cell", "opentelemetry", @@ -1456,9 +1456,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] @@ -1570,7 +1570,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07f2d176c472198ec1e6551dc7da28f1c089652f66a7b722676c2238ebc0edf" dependencies = [ - "futures 0.3.25", + "futures 0.3.26", "futures-timer", "rstest_macros", "rustc_version", @@ -1747,9 +1747,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.16" +version = "0.9.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92b5b431e8907b50339b51223b97d102db8d987ced36f6e4d03621db9316c834" +checksum = "8fb06d4b6cdaef0e0c51fa881acb721bed3c924cfaa71d9c94a3b771dfdf6567" dependencies = [ "indexmap", "itoa", @@ -1825,15 +1825,15 @@ dependencies = [ [[package]] name = "stackable-operator" -version = "0.33.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.33.0#600bc948f2763d070a0f3c354a2b66434cf9f953" +version = "0.35.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.35.0#707b043fceef300416cec2172be18a3e7a45a0e2" dependencies = [ "chrono", "clap", "const_format", "derivative", "either", - "futures 0.3.25", + "futures 0.3.26", "json-patch", "k8s-openapi", "kube", @@ -1846,7 +1846,7 @@ dependencies = [ "schemars", "serde", "serde_json", - "serde_yaml 0.9.16", + "serde_yaml 0.9.17", "snafu", "stackable-operator-derive", "strum", @@ -1859,8 +1859,8 @@ dependencies = [ [[package]] name = "stackable-operator-derive" -version = "0.33.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.33.0#600bc948f2763d070a0f3c354a2b66434cf9f953" +version = "0.35.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.35.0#707b043fceef300416cec2172be18a3e7a45a0e2" dependencies = [ "darling", "proc-macro2", @@ -1877,7 +1877,7 @@ dependencies = [ "semver", "serde", "serde_json", - "serde_yaml 0.9.16", + "serde_yaml 0.9.17", "snafu", "stackable-operator", "strum", @@ -1892,7 +1892,7 @@ dependencies = [ "async-trait", "built", "clap", - "futures 0.3.25", + "futures 0.3.26", "indoc", "openssl", "pin-project", @@ -2032,9 +2032,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.24.1" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d9f76183f91ecfb55e1d7d5602bd1d979e38a3a522fe900241cf195624d67ae" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ "autocfg", "bytes", diff --git a/rust/crd/Cargo.toml b/rust/crd/Cargo.toml index a7b8aaba..e620e015 100644 --- a/rust/crd/Cargo.toml +++ b/rust/crd/Cargo.toml @@ -9,7 +9,7 @@ version = "0.9.0-nightly" publish = false [dependencies] -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.33.0" } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.35.0" } semver = "1.0" serde = { version = "1.0", features = ["derive"] } diff --git a/rust/operator-binary/Cargo.toml b/rust/operator-binary/Cargo.toml index 43272d62..a2747c45 100644 --- a/rust/operator-binary/Cargo.toml +++ b/rust/operator-binary/Cargo.toml @@ -10,7 +10,7 @@ version = "0.9.0-nightly" publish = false [dependencies] -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.33.0" } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.35.0" } stackable-trino-crd = { path = "../crd" } anyhow = "1.0" @@ -28,5 +28,5 @@ tracing = "0.1" [build-dependencies] built = { version = "0.5", features = ["chrono", "git2"] } -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.33.0" } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.35.0" } stackable-trino-crd = { path = "../crd" } From 69cfb24b97a8f359db9d3f9238a0dcab2b656aae Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Mon, 13 Feb 2023 10:47:42 +0100 Subject: [PATCH 14/33] fix linters --- CHANGELOG.md | 2 +- rust/operator-binary/src/controller.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4421b29c..6d77f7b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ All notable changes to this project will be documented in this file. ### Removed -- [BREAKING]: Removed `log_level` from `TrinoConfig` which is now set via the logging framework struct ([#380]). +- [BREAKING]: Removed `log_level` from `TrinoConfig` which is now set via the logging framework struct ([#380]). [#378]: https://github.com/stackabletech/trino-operator/pull/378 [#379]: https://github.com/stackabletech/trino-operator/pull/379 diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 80e9e592..7d639609 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -88,8 +88,8 @@ pub const MAX_TRINO_LOG_FILES_SIZE_IN_MIB: u32 = 10; const MAX_PREPARE_LOG_FILE_SIZE_IN_MIB: u32 = 1; // Additional buffer space is not needed, as the `prepare` container already has sufficient buffer // space and all containers share a single volume. -pub const LOG_VOLUME_SIZE_IN_MIB: u32 = MAX_TRINO_LOG_FILES_SIZE_IN_MIB - + MAX_PREPARE_LOG_FILE_SIZE_IN_MIB; +pub const LOG_VOLUME_SIZE_IN_MIB: u32 = + MAX_TRINO_LOG_FILES_SIZE_IN_MIB + MAX_PREPARE_LOG_FILE_SIZE_IN_MIB; const DOCKER_IMAGE_BASE_NAME: &str = "trino"; From c64898f182b7b7dc6be360b7c0cac6bf3c8829bc Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Mon, 13 Feb 2023 10:57:55 +0100 Subject: [PATCH 15/33] fix clippy --- rust/operator-binary/src/controller.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 7d639609..76637074 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -514,7 +514,7 @@ fn build_rolegroup_config_map( "log.path".to_string(), Some(format!( "{STACKABLE_LOG_DIR}/{container}/server.airlift.json", - container = Container::Trino.to_string() + container = Container::Trino )), ); // The maximum number of general application log files to use, before log rotation replaces old content. From 6d8f45938367b6e7a288e11263e02e353e4c4d47 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Mon, 13 Feb 2023 18:51:32 +0100 Subject: [PATCH 16/33] added log aggregation to usage guide --- docs/modules/trino/pages/usage_guide/index.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/modules/trino/pages/usage_guide/index.adoc b/docs/modules/trino/pages/usage_guide/index.adoc index ba484d23..ee4726b6 100644 --- a/docs/modules/trino/pages/usage_guide/index.adoc +++ b/docs/modules/trino/pages/usage_guide/index.adoc @@ -11,4 +11,5 @@ The following guides are available here: * xref:usage_guide/configuration.adoc[] * xref:usage_guide/security.adoc[] * xref:usage_guide/monitoring.adoc[] +* xref:usage_guide/log-aggregation.adoc[] * xref:usage_guide/query.adoc[] From 6e7926b2a164af4518de0a9f77a94e097348dd3c Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 10:22:54 +0100 Subject: [PATCH 17/33] Update CHANGELOG.md Co-authored-by: Siegfried Weber --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d77f7b6..268012f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file. ### Changed - `operator-rs` `0.31.0` -> `0.35.0` ([#378], [#380]). -- Bumped stackable image versions to `23.4.0-rc1` and `23.4.0-rc2` ([#378], [#380]). +- Bumped stackable image versions to `23.4.0-rc2` ([#378], [#380]). - Fragmented `TrinoConfig` ([#379]). - Enabled logging and log aggregation ([#380]). From 182febcbe186d324cc808d837b5aadb18c0fbbd6 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 10:23:30 +0100 Subject: [PATCH 18/33] removed space from changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 268012f3..505252b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file. ### Changed - `operator-rs` `0.31.0` -> `0.35.0` ([#378], [#380]). -- Bumped stackable image versions to `23.4.0-rc2` ([#378], [#380]). +- Bumped stackable image versions to `23.4.0-rc2` ([#378], [#380]). - Fragmented `TrinoConfig` ([#379]). - Enabled logging and log aggregation ([#380]). From 6557e0165c65502e7796c13bc5ed2d62ae169e74 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 10:24:48 +0100 Subject: [PATCH 19/33] sorted dependencies --- rust/operator-binary/src/controller.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 76637074..770df104 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -10,7 +10,6 @@ use crate::product_logging::{ }; use indoc::formatdoc; use snafu::{OptionExt, ResultExt, Snafu}; -use stackable_operator::product_logging::spec::{ConfigMapLogConfig, CustomContainerLogConfig}; use stackable_operator::{ builder::{ ConfigMapBuilder, ContainerBuilder, ObjectMetaBuilder, PodBuilder, @@ -47,7 +46,10 @@ use stackable_operator::{ }, product_logging::{ self, - spec::{ContainerLogConfig, ContainerLogConfigChoice}, + spec::{ + ConfigMapLogConfig, ContainerLogConfig, ContainerLogConfigChoice, + CustomContainerLogConfig, + }, }, role_utils::RoleGroupRef, }; From c7e49a3329d64842c675a97129ebcf3fe731e9b5 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 10:26:43 +0100 Subject: [PATCH 20/33] removed obsolete error --- rust/operator-binary/src/product_logging.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/rust/operator-binary/src/product_logging.rs b/rust/operator-binary/src/product_logging.rs index 33706ba1..148878c1 100644 --- a/rust/operator-binary/src/product_logging.rs +++ b/rust/operator-binary/src/product_logging.rs @@ -27,8 +27,6 @@ pub enum Error { entry: &'static str, cm_name: String, }, - #[snafu(display("crd validation failure"))] - CrdValidationFailure { source: stackable_trino_crd::Error }, #[snafu(display("vectorAggregatorConfigMapName must be set"))] MissingVectorAggregatorAddress, } From 361534f7f01cc16d2d64f24f8573c2b0b228cdf3 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 10:53:32 +0100 Subject: [PATCH 21/33] added loglevel Off --- rust/operator-binary/src/product_logging.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rust/operator-binary/src/product_logging.rs b/rust/operator-binary/src/product_logging.rs index 148878c1..22a38cbb 100644 --- a/rust/operator-binary/src/product_logging.rs +++ b/rust/operator-binary/src/product_logging.rs @@ -42,6 +42,7 @@ pub enum TrinoLogLevel { Info, Warn, Error, + Off, } impl From for TrinoLogLevel { @@ -50,7 +51,8 @@ impl From for TrinoLogLevel { LogLevel::TRACE | LogLevel::DEBUG => Self::Debug, LogLevel::INFO => Self::Info, LogLevel::WARN => Self::Warn, - LogLevel::ERROR | LogLevel::FATAL | LogLevel::NONE => Self::Error, + LogLevel::ERROR | LogLevel::FATAL => Self::Error, + LogLevel::NONE => Self::Off, } } } @@ -134,8 +136,8 @@ pub fn get_vector_toml( /// /// The `log.properties` will adhere to the example format: /// ``` -/// io.trino=DEBUG -/// io.trino.server=INFO +/// io.trino=debug +/// io.trino.server=info /// ``` fn create_trino_log_properties(automatic_container_config: &AutomaticContainerLogConfig) -> String { automatic_container_config From 9c2730a9a7bf8acf85e5fbcd9ff2e018f8ec9f97 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 12:25:31 +0100 Subject: [PATCH 22/33] removed obsolete vector configmap --- tests/templates/kuttl/logging/00-assert.yaml.j2 | 10 ---------- ...stall-vector-aggregator-discovery-configmap.yaml.j2 | 9 --------- 2 files changed, 19 deletions(-) delete mode 100644 tests/templates/kuttl/logging/00-assert.yaml.j2 delete mode 100644 tests/templates/kuttl/logging/00-install-vector-aggregator-discovery-configmap.yaml.j2 diff --git a/tests/templates/kuttl/logging/00-assert.yaml.j2 b/tests/templates/kuttl/logging/00-assert.yaml.j2 deleted file mode 100644 index 50b1d4c3..00000000 --- a/tests/templates/kuttl/logging/00-assert.yaml.j2 +++ /dev/null @@ -1,10 +0,0 @@ ---- -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -{% if lookup('env', 'VECTOR_AGGREGATOR') %} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: vector-aggregator-discovery -{% endif %} diff --git a/tests/templates/kuttl/logging/00-install-vector-aggregator-discovery-configmap.yaml.j2 b/tests/templates/kuttl/logging/00-install-vector-aggregator-discovery-configmap.yaml.j2 deleted file mode 100644 index 2d6a0df5..00000000 --- a/tests/templates/kuttl/logging/00-install-vector-aggregator-discovery-configmap.yaml.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{% if lookup('env', 'VECTOR_AGGREGATOR') %} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: vector-aggregator-discovery -data: - ADDRESS: {{ lookup('env', 'VECTOR_AGGREGATOR') }} -{% endif %} From 2281c1619a9447a39bdbd5ea586ac22761e3d85e Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 12:26:06 +0100 Subject: [PATCH 23/33] custom log config log.properties now copied to rwconfig --- rust/operator-binary/src/command.rs | 36 +++++++++++++++++---- rust/operator-binary/src/controller.rs | 9 ++++-- rust/operator-binary/src/product_logging.rs | 2 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/rust/operator-binary/src/command.rs b/rust/operator-binary/src/command.rs index 4000930a..497b3102 100644 --- a/rust/operator-binary/src/command.rs +++ b/rust/operator-binary/src/command.rs @@ -1,19 +1,43 @@ use crate::catalog::config::CatalogConfig; +use crate::controller::STACKABLE_LOG_CONFIG_DIR; + +use stackable_operator::product_logging::spec::{ContainerLogConfig, ContainerLogConfigChoice}; use stackable_trino_crd::{ - authentication::TrinoAuthenticationConfig, TrinoCluster, CONFIG_DIR_NAME, DATA_DIR_NAME, - LDAP_PASSWORD_ENV, LDAP_USER_ENV, PASSWORD_DB, RW_CONFIG_DIR_NAME, STACKABLE_CLIENT_TLS_DIR, - STACKABLE_INTERNAL_TLS_DIR, STACKABLE_MOUNT_INTERNAL_TLS_DIR, STACKABLE_MOUNT_SERVER_TLS_DIR, - STACKABLE_SERVER_TLS_DIR, STACKABLE_TLS_STORE_PASSWORD, SYSTEM_TRUST_STORE, - SYSTEM_TRUST_STORE_PASSWORD, USER_PASSWORD_DATA_DIR_NAME, + authentication::TrinoAuthenticationConfig, Container, TrinoCluster, TrinoConfig, + CONFIG_DIR_NAME, DATA_DIR_NAME, LDAP_PASSWORD_ENV, LDAP_USER_ENV, LOG_PROPERTIES, PASSWORD_DB, + RW_CONFIG_DIR_NAME, STACKABLE_CLIENT_TLS_DIR, STACKABLE_INTERNAL_TLS_DIR, + STACKABLE_MOUNT_INTERNAL_TLS_DIR, STACKABLE_MOUNT_SERVER_TLS_DIR, STACKABLE_SERVER_TLS_DIR, + STACKABLE_TLS_STORE_PASSWORD, SYSTEM_TRUST_STORE, SYSTEM_TRUST_STORE_PASSWORD, + USER_PASSWORD_DATA_DIR_NAME, }; pub const STACKABLE_CLIENT_CA_CERT: &str = "stackable-client-ca-cert"; pub const STACKABLE_SERVER_CA_CERT: &str = "stackable-server-ca-cert"; pub const STACKABLE_INTERNAL_CA_CERT: &str = "stackable-internal-ca-cert"; -pub fn container_prepare_args(trino: &TrinoCluster, catalogs: &[CatalogConfig]) -> Vec { +pub fn container_prepare_args( + trino: &TrinoCluster, + catalogs: &[CatalogConfig], + merged_config: &TrinoConfig, +) -> Vec { let mut args = vec![]; + // Copy custom logging provided `log.properties` to rw config + if let Some(ContainerLogConfig { + choice: Some(ContainerLogConfigChoice::Custom(_)), + }) = merged_config.logging.containers.get(&Container::Trino) + { + // copy config files to a writeable empty folder + args.push(format!( + "echo copying {STACKABLE_LOG_CONFIG_DIR}/{LOG_PROPERTIES} {rw_conf}/{LOG_PROPERTIES}", + rw_conf = RW_CONFIG_DIR_NAME + )); + args.push(format!( + "cp -RL {STACKABLE_LOG_CONFIG_DIR}/{LOG_PROPERTIES} {rw_conf}/{LOG_PROPERTIES}", + rw_conf = RW_CONFIG_DIR_NAME + )); + } + // User password data if trino.tls_enabled() { args.extend(create_key_and_trust_store( diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 770df104..d6741334 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -767,7 +767,6 @@ fn build_rolegroup_statefulset( catalogs, )?; - // TODO: prepare default missing!!! let mut prepare_args = vec![]; if let Some(ContainerLogConfig { choice: Some(ContainerLogConfigChoice::Automatic(log_config)), @@ -780,7 +779,11 @@ fn build_rolegroup_statefulset( )); } - prepare_args.extend(command::container_prepare_args(trino, catalogs)); + prepare_args.extend(command::container_prepare_args( + trino, + catalogs, + &merged_config, + )); let container_prepare = cb_prepare .image_from_product_image(resolved_product_image) @@ -788,6 +791,7 @@ fn build_rolegroup_statefulset( .args(vec![prepare_args.join(" && ")]) .add_volume_mount("data", DATA_DIR_NAME) .add_volume_mount("rwconfig", RW_CONFIG_DIR_NAME) + .add_volume_mount("log-config", STACKABLE_LOG_CONFIG_DIR) .add_volume_mount("log", STACKABLE_LOG_DIR) .build(); @@ -803,7 +807,6 @@ fn build_rolegroup_statefulset( .add_volume_mount("config", CONFIG_DIR_NAME) .add_volume_mount("rwconfig", RW_CONFIG_DIR_NAME) .add_volume_mount("catalog", format!("{}/catalog", CONFIG_DIR_NAME)) - .add_volume_mount("log-config", STACKABLE_LOG_CONFIG_DIR) .add_volume_mount("log", STACKABLE_LOG_DIR) .add_container_ports(container_ports(trino)) .resources(merged_config.resources.clone().into()) diff --git a/rust/operator-binary/src/product_logging.rs b/rust/operator-binary/src/product_logging.rs index 22a38cbb..92129043 100644 --- a/rust/operator-binary/src/product_logging.rs +++ b/rust/operator-binary/src/product_logging.rs @@ -36,7 +36,7 @@ type Result = std::result::Result; const VECTOR_AGGREGATOR_CM_ENTRY: &str = "ADDRESS"; #[derive(Display)] -#[strum(serialize_all = "kebab-case")] +#[strum(serialize_all = "lowercase")] pub enum TrinoLogLevel { Debug, Info, From 7110cd7eb20a4c2f6104eb32752492d27d9d6e74 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 12:26:31 +0100 Subject: [PATCH 24/33] setup prepare container logging in tests --- .../kuttl/logging/02-install-trino.yaml.j2 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/templates/kuttl/logging/02-install-trino.yaml.j2 b/tests/templates/kuttl/logging/02-install-trino.yaml.j2 index e8795da0..6c42cb8f 100644 --- a/tests/templates/kuttl/logging/02-install-trino.yaml.j2 +++ b/tests/templates/kuttl/logging/02-install-trino.yaml.j2 @@ -17,7 +17,7 @@ spec: productVersion: "{{ test_scenario['values']['trino'].split('-stackable')[0] }}" stackableVersion: "{{ test_scenario['values']['trino'].split('-stackable')[1] }}" catalogLabelSelector: {} - vectorAggregatorConfigMapName: vector-aggregator-discovery + vectorAggregatorConfigMapName: trino-vector-aggregator-discovery coordinators: roleGroups: automatic-log-config: @@ -38,6 +38,14 @@ spec: loggers: ROOT: level: INFO + prepare: + console: + level: INFO + file: + level: INFO + loggers: + ROOT: + level: INFO custom-log-config: replicas: 1 config: @@ -67,6 +75,14 @@ spec: loggers: ROOT: level: INFO + prepare: + console: + level: INFO + file: + level: INFO + loggers: + ROOT: + level: INFO custom-log-config: replicas: 1 config: From d52d22a40d94fc77492e2449fece5a27028f67e9 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 12:26:48 +0100 Subject: [PATCH 25/33] vector discovery config map now prefixed with trino --- tests/templates/kuttl/logging/01-assert.yaml | 6 ++++++ .../kuttl/logging/01-install-trino-vector-aggregator.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/templates/kuttl/logging/01-assert.yaml b/tests/templates/kuttl/logging/01-assert.yaml index 2cc77be9..3ffb7b54 100644 --- a/tests/templates/kuttl/logging/01-assert.yaml +++ b/tests/templates/kuttl/logging/01-assert.yaml @@ -10,3 +10,9 @@ metadata: status: readyReplicas: 1 replicas: 1 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: trino-vector-aggregator-discovery + diff --git a/tests/templates/kuttl/logging/01-install-trino-vector-aggregator.yaml b/tests/templates/kuttl/logging/01-install-trino-vector-aggregator.yaml index 07f01864..daae7214 100644 --- a/tests/templates/kuttl/logging/01-install-trino-vector-aggregator.yaml +++ b/tests/templates/kuttl/logging/01-install-trino-vector-aggregator.yaml @@ -12,6 +12,6 @@ commands: apiVersion: v1 kind: ConfigMap metadata: - name: vector-aggregator-discovery + name: trino-vector-aggregator-discovery data: ADDRESS: trino-vector-aggregator:6123 From 12e9e3c7a04eec42f187d7de16dce0209dcbf801 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 14:15:43 +0100 Subject: [PATCH 26/33] utilize root logger --- rust/crd/src/lib.rs | 17 +---------------- rust/operator-binary/src/controller.rs | 2 +- rust/operator-binary/src/product_logging.rs | 9 ++++++++- .../kuttl/logging/02-install-trino.yaml.j2 | 2 ++ 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index fdbbb99f..c1d8ae4d 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -378,23 +378,8 @@ pub struct TrinoConfig { impl TrinoConfig { fn default_config() -> TrinoConfigFragment { - // We remove the default ROOT_LOGGER config from the trino container - // It is not required - let mut default_logging: LoggingFragment = - product_logging::spec::default_logging(); - if let Some(ContainerLogConfigFragment { - choice: - Some(ContainerLogConfigChoiceFragment::Automatic(AutomaticContainerLogConfigFragment { - loggers: config, - .. - })), - }) = default_logging.containers.get_mut(&Container::Trino) - { - config.clear(); - } - TrinoConfigFragment { - logging: default_logging, + logging: product_logging::spec::default_logging(), resources: ResourcesFragment { cpu: CpuLimitsFragment { min: Some(Quantity("200m".to_owned())), diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index d6741334..94a7065d 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -782,7 +782,7 @@ fn build_rolegroup_statefulset( prepare_args.extend(command::container_prepare_args( trino, catalogs, - &merged_config, + merged_config, )); let container_prepare = cb_prepare diff --git a/rust/operator-binary/src/product_logging.rs b/rust/operator-binary/src/product_logging.rs index 92129043..da7c3724 100644 --- a/rust/operator-binary/src/product_logging.rs +++ b/rust/operator-binary/src/product_logging.rs @@ -143,6 +143,13 @@ fn create_trino_log_properties(automatic_container_config: &AutomaticContainerLo automatic_container_config .loggers .iter() - .map(|(logger, config)| format!("{}={}\n", logger, TrinoLogLevel::from(config.level))) + .map(|(logger, config)| { + let log_level = TrinoLogLevel::from(config.level); + if logger == AutomaticContainerLogConfig::ROOT_LOGGER { + format!("={}\n", log_level) + } else { + format!("{}={}\n", logger, log_level) + } + }) .collect::() } diff --git a/tests/templates/kuttl/logging/02-install-trino.yaml.j2 b/tests/templates/kuttl/logging/02-install-trino.yaml.j2 index 6c42cb8f..046667da 100644 --- a/tests/templates/kuttl/logging/02-install-trino.yaml.j2 +++ b/tests/templates/kuttl/logging/02-install-trino.yaml.j2 @@ -67,6 +67,8 @@ spec: loggers: io.trino: level: INFO + ROOT: + level: ERROR vector: console: level: INFO From a900b84cb80e75c5d109451ede77aede52e7fdda Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 14:18:37 +0100 Subject: [PATCH 27/33] fix clippy --- rust/crd/src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index c1d8ae4d..fd3e058a 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -27,10 +27,7 @@ use stackable_operator::{ kube::{runtime::reflector::ObjectRef, CustomResource, ResourceExt}, product_config_utils::{ConfigError, Configuration}, product_logging, - product_logging::spec::{ - AutomaticContainerLogConfigFragment, ContainerLogConfigChoiceFragment, - ContainerLogConfigFragment, Logging, LoggingFragment, - }, + product_logging::spec::Logging, role_utils::{Role, RoleGroup, RoleGroupRef}, schemars::{self, JsonSchema}, }; From 246e43b32a44128f3b7270978d80e7ae81bd303b Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 15:28:00 +0100 Subject: [PATCH 28/33] fix logging properites --- rust/crd/src/lib.rs | 6 +++++ rust/operator-binary/src/controller.rs | 37 +++++++++++++++----------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index fd3e058a..519c96ac 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -128,6 +128,12 @@ pub const SECRET_KEY_S3_ACCESS_KEY: &str = "accessKey"; pub const SECRET_KEY_S3_SECRET_KEY: &str = "secretKey"; // TLS pub const TLS_DEFAULT_SECRET_CLASS: &str = "tls"; +// Logging +pub const LOG_FORMAT: &str = "log.format"; +pub const LOG_PATH: &str = "log.path"; +pub const LOG_COMPRESSION: &str = "log.compression"; +pub const LOG_MAX_SIZE: &str = "log.max-size"; +pub const LOG_MAX_TOTAL_SIZE: &str = "log.max-total-size"; pub const JVM_HEAP_FACTOR: f32 = 0.8; diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 94a7065d..6187dc8d 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -1,13 +1,13 @@ //! Ensures that `Pod`s are configured and running for each [`TrinoCluster`] +use crate::product_logging::{ + get_log_properties, get_vector_toml, resolve_vector_aggregator_address, +}; use crate::{ catalog::{config::CatalogConfig, FromTrinoCatalogError}, command, config, config::password_authenticator_properties, }; -use crate::product_logging::{ - get_log_properties, get_vector_toml, resolve_vector_aggregator_address, -}; use indoc::formatdoc; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{ @@ -61,7 +61,8 @@ use stackable_trino_crd::{ Container, TlsSecretClass, TrinoCluster, TrinoConfig, TrinoRole, ACCESS_CONTROL_PROPERTIES, APP_NAME, CONFIG_DIR_NAME, CONFIG_PROPERTIES, DATA_DIR_NAME, DISCOVERY_URI, ENV_INTERNAL_SECRET, HTTPS_PORT, HTTPS_PORT_NAME, HTTP_PORT, HTTP_PORT_NAME, JVM_CONFIG, - JVM_HEAP_FACTOR, LOG_PROPERTIES, METRICS_PORT, METRICS_PORT_NAME, NODE_PROPERTIES, + JVM_HEAP_FACTOR, LOG_COMPRESSION, LOG_FORMAT, LOG_MAX_SIZE, LOG_MAX_TOTAL_SIZE, LOG_PATH, + LOG_PROPERTIES, METRICS_PORT, METRICS_PORT_NAME, NODE_PROPERTIES, PASSWORD_AUTHENTICATOR_PROPERTIES, PASSWORD_DB, RW_CONFIG_DIR_NAME, STACKABLE_CLIENT_TLS_DIR, STACKABLE_INTERNAL_TLS_DIR, STACKABLE_MOUNT_INTERNAL_TLS_DIR, STACKABLE_MOUNT_SERVER_TLS_DIR, STACKABLE_SERVER_TLS_DIR, STACKABLE_TLS_STORE_PASSWORD, USER_PASSWORD_DATA_DIR_NAME, @@ -86,12 +87,13 @@ pub const CONTROLLER_NAME: &str = "trinocluster"; pub const STACKABLE_LOG_DIR: &str = "/stackable/log"; pub const STACKABLE_LOG_CONFIG_DIR: &str = "/stackable/log_config"; -pub const MAX_TRINO_LOG_FILES_SIZE_IN_MIB: u32 = 10; +const TRINO_LOG_FILE_SIZE_IN_MIB: u32 = TRINO_LOG_FILE_TOTAL_SIZE_IN_MIB / 2; +const TRINO_LOG_FILE_TOTAL_SIZE_IN_MIB: u32 = 10; const MAX_PREPARE_LOG_FILE_SIZE_IN_MIB: u32 = 1; // Additional buffer space is not needed, as the `prepare` container already has sufficient buffer // space and all containers share a single volume. -pub const LOG_VOLUME_SIZE_IN_MIB: u32 = - MAX_TRINO_LOG_FILES_SIZE_IN_MIB + MAX_PREPARE_LOG_FILE_SIZE_IN_MIB; +const LOG_VOLUME_SIZE_IN_MIB: u32 = + TRINO_LOG_FILE_TOTAL_SIZE_IN_MIB + MAX_PREPARE_LOG_FILE_SIZE_IN_MIB; const DOCKER_IMAGE_BASE_NAME: &str = "trino"; @@ -510,22 +512,27 @@ fn build_rolegroup_config_map( dynamic_resolved_config .insert(DISCOVERY_URI.to_string(), Some(discovery.discovery_uri())); - dynamic_resolved_config.insert("log.format".to_string(), Some("json".to_string())); + // The log format used by Trino + dynamic_resolved_config.insert(LOG_FORMAT.to_string(), Some("json".to_string())); // The path to the log file used by Trino dynamic_resolved_config.insert( - "log.path".to_string(), + LOG_PATH.to_string(), Some(format!( "{STACKABLE_LOG_DIR}/{container}/server.airlift.json", container = Container::Trino )), ); - // The maximum number of general application log files to use, before log rotation replaces old content. - dynamic_resolved_config - .insert("log.max-history".to_string(), Some("2".to_string())); - // The maximum file size for the general application log file. + // We do not compress. This will result in LOG_MAX_TOTAL_SIZE / LOG_MAX_SIZE files. + dynamic_resolved_config.insert(LOG_COMPRESSION.to_string(), Some(format!("none"))); + // The size of one log file + dynamic_resolved_config.insert( + LOG_MAX_SIZE.to_string(), + Some(format!("{TRINO_LOG_FILE_SIZE_IN_MIB}MB")), + ); + // The maximum size of all logfiles combined dynamic_resolved_config.insert( - "log.max-size".to_string(), - Some(format!("{MAX_TRINO_LOG_FILES_SIZE_IN_MIB}MB")), + LOG_MAX_TOTAL_SIZE.to_string(), + Some(format!("{TRINO_LOG_FILE_TOTAL_SIZE_IN_MIB}MB")), ); // Add static properties and overrides From b5d733a529dc07590f730b3fc5b6277b0f44bb5f Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 15:29:49 +0100 Subject: [PATCH 29/33] attempt to fix docs --- docs/modules/trino/partials/nav.adoc | 18 ---------------- docs/modules/usage_guide/nav.adoc | 32 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 32 deletions(-) delete mode 100644 docs/modules/trino/partials/nav.adoc diff --git a/docs/modules/trino/partials/nav.adoc b/docs/modules/trino/partials/nav.adoc deleted file mode 100644 index f088942a..00000000 --- a/docs/modules/trino/partials/nav.adoc +++ /dev/null @@ -1,18 +0,0 @@ -* xref:trino:getting_started/index.adoc[] -** xref:trino:getting_started/installation.adoc[] -** xref:trino:getting_started/first_steps.adoc[] -* xref:trino:configuration.adoc[] -* xref:trino:concepts.adoc[] -* xref:trino:usage_guide/index.adoc[] -** xref:trino:usage_guide/cluster.adoc[] -** xref:trino:usage_guide/configuration.adoc[] -** xref:trino:usage_guide/security.adoc[] -** xref:trino:usage_guide/monitoring.adoc[] -** xref:trino:usage_guide/query.adoc[] -** xref:trino:usage_guide/catalogs/index.adoc[] -*** xref:trino:usage_guide/catalogs/black-hole.adoc[] -*** xref:trino:usage_guide/catalogs/google-sheets.adoc[] -*** xref:trino:usage_guide/catalogs/hive.adoc[] -*** xref:trino:usage_guide/catalogs/iceberg.adoc[] -*** xref:trino:usage_guide/catalogs/tpcds.adoc[] -*** xref:trino:usage_guide/catalogs/tpch.adoc[] diff --git a/docs/modules/usage_guide/nav.adoc b/docs/modules/usage_guide/nav.adoc index 7d3092ac..5d934637 100644 --- a/docs/modules/usage_guide/nav.adoc +++ b/docs/modules/usage_guide/nav.adoc @@ -1,14 +1,18 @@ -* xref:index.adoc[] -** xref:cluster.adoc[] -** xref:configuration.adoc[] -** xref:security.adoc[] -** xref:monitoring.adoc[] -** xref:log-aggregation.adoc[] -** xref:query.adoc[] -** xref:catalogs/index.adoc[] -*** xref:catalogs/black-hole.adoc[] -*** xref:catalogs/google-sheets.adoc[] -*** xref:catalogs/hive.adoc[] -*** xref:catalogs/iceberg.adoc[] -*** xref:catalogs/tpcds.adoc[] -*** xref:catalogs/tpch.adoc[] +* xref:trino:getting_started/index.adoc[] +** xref:trino:getting_started/installation.adoc[] +** xref:trino:getting_started/first_steps.adoc[] +* xref:trino:configuration.adoc[] +* xref:trino:concepts.adoc[] +* xref:trino:usage_guide/index.adoc[] +** xref:trino:usage_guide/cluster.adoc[] +** xref:trino:usage_guide/configuration.adoc[] +** xref:trino:usage_guide/security.adoc[] +** xref:trino:usage_guide/monitoring.adoc[] +** xref:trino:usage_guide/query.adoc[] +** xref:trino:usage_guide/catalogs/index.adoc[] +*** xref:trino:usage_guide/catalogs/black-hole.adoc[] +*** xref:trino:usage_guide/catalogs/google-sheets.adoc[] +*** xref:trino:usage_guide/catalogs/hive.adoc[] +*** xref:trino:usage_guide/catalogs/iceberg.adoc[] +*** xref:trino:usage_guide/catalogs/tpcds.adoc[] +*** xref:trino:usage_guide/catalogs/tpch.adoc[] \ No newline at end of file From e28fbd4ed8e05279b81466fefb8cbe334ba58f78 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 15:29:59 +0100 Subject: [PATCH 30/33] clippy --- rust/operator-binary/src/controller.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 6187dc8d..e3f80264 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -523,7 +523,8 @@ fn build_rolegroup_config_map( )), ); // We do not compress. This will result in LOG_MAX_TOTAL_SIZE / LOG_MAX_SIZE files. - dynamic_resolved_config.insert(LOG_COMPRESSION.to_string(), Some(format!("none"))); + dynamic_resolved_config + .insert(LOG_COMPRESSION.to_string(), Some("none".to_string())); // The size of one log file dynamic_resolved_config.insert( LOG_MAX_SIZE.to_string(), From f8c51a5c59fadab3e44ed6fd8dfb605157fe1610 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 15 Feb 2023 15:31:32 +0100 Subject: [PATCH 31/33] yaml linter --- tests/templates/kuttl/logging/01-assert.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/templates/kuttl/logging/01-assert.yaml b/tests/templates/kuttl/logging/01-assert.yaml index 3ffb7b54..e4152dc1 100644 --- a/tests/templates/kuttl/logging/01-assert.yaml +++ b/tests/templates/kuttl/logging/01-assert.yaml @@ -15,4 +15,3 @@ apiVersion: v1 kind: ConfigMap metadata: name: trino-vector-aggregator-discovery - From 2a75762269372c08b28bfc6e6c1554e006594577 Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Mon, 20 Feb 2023 14:07:48 +0100 Subject: [PATCH 32/33] fix nav.adoc location --- docs/modules/{usage_guide => trino/partials}/nav.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename docs/modules/{usage_guide => trino/partials}/nav.adoc (88%) diff --git a/docs/modules/usage_guide/nav.adoc b/docs/modules/trino/partials/nav.adoc similarity index 88% rename from docs/modules/usage_guide/nav.adoc rename to docs/modules/trino/partials/nav.adoc index 5d934637..eccdea5e 100644 --- a/docs/modules/usage_guide/nav.adoc +++ b/docs/modules/trino/partials/nav.adoc @@ -8,6 +8,7 @@ ** xref:trino:usage_guide/configuration.adoc[] ** xref:trino:usage_guide/security.adoc[] ** xref:trino:usage_guide/monitoring.adoc[] +** xref:trino:usage_guide/log-aggregation.adoc[] ** xref:trino:usage_guide/query.adoc[] ** xref:trino:usage_guide/catalogs/index.adoc[] *** xref:trino:usage_guide/catalogs/black-hole.adoc[] @@ -15,4 +16,4 @@ *** xref:trino:usage_guide/catalogs/hive.adoc[] *** xref:trino:usage_guide/catalogs/iceberg.adoc[] *** xref:trino:usage_guide/catalogs/tpcds.adoc[] -*** xref:trino:usage_guide/catalogs/tpch.adoc[] \ No newline at end of file +*** xref:trino:usage_guide/catalogs/tpch.adoc[] From 1a30652fb8e1bf73b549fcc892bf604a576d727d Mon Sep 17 00:00:00 2001 From: Malte Sander Date: Wed, 22 Feb 2023 10:02:45 +0100 Subject: [PATCH 33/33] fix resource integration tests --- tests/templates/kuttl/resources/10-assert.yaml.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/templates/kuttl/resources/10-assert.yaml.j2 b/tests/templates/kuttl/resources/10-assert.yaml.j2 index 2d806810..eebe5025 100644 --- a/tests/templates/kuttl/resources/10-assert.yaml.j2 +++ b/tests/templates/kuttl/resources/10-assert.yaml.j2 @@ -99,6 +99,9 @@ spec: limits: cpu: 800m memory: 4Gi +{% if lookup('env', 'VECTOR_AGGREGATOR') %} + - name: vector +{% endif %} status: readyReplicas: 1 replicas: 1