@@ -40,20 +40,22 @@ use stackable_operator::{
4040 kvp:: Labels ,
4141 product_logging:: {
4242 self ,
43- framework:: {
44- LoggingError , create_vector_shutdown_file_command, remove_vector_shutdown_file_command,
45- } ,
43+ framework:: { create_vector_shutdown_file_command, remove_vector_shutdown_file_command} ,
4644 spec:: {
4745 AutomaticContainerLogConfig , ConfigMapLogConfig , ContainerLogConfig ,
4846 ContainerLogConfigChoice , CustomContainerLogConfig ,
4947 } ,
5048 } ,
5149 utils:: { COMMON_BASH_TRAP_FUNCTIONS , cluster_info:: KubernetesClusterInfo } ,
5250 v2:: {
53- builder:: pod:: container:: new_container_builder,
51+ builder:: pod:: container:: { EnvVarSet , new_container_builder} ,
52+ product_logging:: framework:: {
53+ STACKABLE_LOG_DIR , ValidatedContainerLogConfigChoice , VectorContainerLogConfig ,
54+ vector_container,
55+ } ,
5456 types:: {
5557 common:: Port ,
56- kubernetes:: { ContainerName , VolumeName } ,
58+ kubernetes:: { ConfigMapName , ContainerName , VolumeName } ,
5759 operator:: RoleGroupName ,
5860 } ,
5961 } ,
@@ -67,11 +69,11 @@ use crate::{
6769 self ,
6870 jvm:: { self , construct_global_jvm_args, construct_role_specific_jvm_args} ,
6971 kerberos:: KERBEROS_CONTAINER_PATH ,
70- properties:: logging :: {
72+ properties:: product_logging :: {
7173 FORMAT_NAMENODES_LOG4J_CONFIG_FILE , FORMAT_ZOOKEEPER_LOG4J_CONFIG_FILE ,
7274 HDFS_LOG4J_CONFIG_FILE , MAX_FORMAT_NAMENODE_LOG_FILE_SIZE ,
7375 MAX_FORMAT_ZOOKEEPER_LOG_FILE_SIZE , MAX_HDFS_LOG_FILE_SIZE ,
74- MAX_WAIT_NAMENODES_LOG_FILE_SIZE , MAX_ZKFC_LOG_FILE_SIZE , STACKABLE_LOG_DIR ,
76+ MAX_WAIT_NAMENODES_LOG_FILE_SIZE , MAX_ZKFC_LOG_FILE_SIZE ,
7577 WAIT_FOR_NAMENODES_LOG4J_CONFIG_FILE , ZKFC_LOG4J_CONFIG_FILE ,
7678 } ,
7779 } ,
@@ -98,6 +100,12 @@ constant!(pub(crate) TLS_STORE_VOLUME_NAME: VolumeName = "tls");
98100pub ( crate ) const TLS_STORE_PASSWORD : & str = "changeit" ;
99101constant ! ( pub ( crate ) KERBEROS_VOLUME_NAME : VolumeName = "kerberos" ) ;
100102
103+ constant ! ( VECTOR_CONTAINER_NAME : ContainerName = "vector" ) ;
104+ // The volume the rolegroup ConfigMap (including the static `vector.yaml`) is mounted into.
105+ constant ! ( VECTOR_CONFIG_VOLUME_NAME : VolumeName = "hdfs-config" ) ;
106+ // The volume holding the product logs that Vector tails.
107+ constant ! ( VECTOR_LOG_VOLUME_NAME : VolumeName = "log" ) ;
108+
101109type Result < T , E = Error > = std:: result:: Result < T , E > ;
102110
103111#[ derive( Snafu , Debug , EnumDiscriminants ) ]
@@ -128,9 +136,6 @@ pub enum Error {
128136 source : ListenerOperatorVolumeSourceBuilderError ,
129137 } ,
130138
131- #[ snafu( display( "failed to configure logging" ) ) ]
132- ConfigureLogging { source : LoggingError } ,
133-
134139 #[ snafu( display( "failed to add needed volume" ) ) ]
135140 AddVolume { source : builder:: pod:: Error } ,
136141
@@ -141,6 +146,11 @@ pub enum Error {
141146
142147 #[ snafu( display( "vector agent is enabled but vector aggregator ConfigMap is missing" ) ) ]
143148 VectorAggregatorConfigMapMissing ,
149+
150+ #[ snafu( display( "invalid Vector log config ConfigMap name" ) ) ]
151+ ParseVectorLogConfigMapName {
152+ source : stackable_operator:: v2:: macros:: attributed_string_type:: Error ,
153+ } ,
144154}
145155
146156/// ContainerConfig contains information to create all main, side and init containers for
@@ -233,35 +243,45 @@ impl ContainerConfig {
233243 labels,
234244 ) ?) ;
235245
236- // Vector side container
246+ // Vector sidecar container.
237247 if merged_config. vector_logging_enabled ( ) {
238- match & cluster
248+ let vector_aggregator_config_map_name = cluster
239249 . cluster_config
240250 . logging
241251 . vector_aggregator_config_map_name
242- {
243- Some ( vector_aggregator_config_map_name) => {
244- pb. add_container (
245- product_logging:: framework:: vector_container (
246- & cluster. image ,
247- ContainerConfig :: HDFS_CONFIG_VOLUME_MOUNT_NAME ,
248- ContainerConfig :: STACKABLE_LOG_VOLUME_MOUNT_NAME ,
249- Some ( & merged_config. vector_logging ( ) ) ,
250- ResourceRequirementsBuilder :: new ( )
251- . with_cpu_request ( "250m" )
252- . with_cpu_limit ( "500m" )
253- . with_memory_request ( "128Mi" )
254- . with_memory_limit ( "128Mi" )
255- . build ( ) ,
256- vector_aggregator_config_map_name. as_ref ( ) ,
257- )
258- . context ( ConfigureLoggingSnafu ) ?,
259- ) ;
260- }
261- None => {
262- VectorAggregatorConfigMapMissingSnafu . fail ( ) ?;
263- }
264- }
252+ . clone ( )
253+ . context ( VectorAggregatorConfigMapMissingSnafu ) ?;
254+
255+ let log_config = match & * merged_config. vector_logging ( ) {
256+ ContainerLogConfig {
257+ choice :
258+ Some ( ContainerLogConfigChoice :: Custom ( CustomContainerLogConfig {
259+ custom : ConfigMapLogConfig { config_map } ,
260+ } ) ) ,
261+ } => ValidatedContainerLogConfigChoice :: Custom (
262+ ConfigMapName :: from_str ( config_map)
263+ . context ( ParseVectorLogConfigMapNameSnafu ) ?,
264+ ) ,
265+ ContainerLogConfig {
266+ choice : Some ( ContainerLogConfigChoice :: Automatic ( log_config) ) ,
267+ } => ValidatedContainerLogConfigChoice :: Automatic ( log_config. clone ( ) ) ,
268+ _ => ValidatedContainerLogConfigChoice :: Automatic (
269+ AutomaticContainerLogConfig :: default ( ) ,
270+ ) ,
271+ } ;
272+
273+ pb. add_container ( vector_container (
274+ & VECTOR_CONTAINER_NAME ,
275+ & cluster. image ,
276+ & VectorContainerLogConfig {
277+ log_config,
278+ vector_aggregator_config_map_name,
279+ } ,
280+ & cluster. resource_names ( role, role_group_name) ,
281+ & VECTOR_CONFIG_VOLUME_NAME ,
282+ & VECTOR_LOG_VOLUME_NAME ,
283+ EnvVarSet :: new ( ) ,
284+ ) ) ;
265285 }
266286
267287 if let Some ( authentication_config) = cluster. authentication_config ( ) {
0 commit comments