@@ -15,6 +15,7 @@ use product_config::{
1515use snafu:: { OptionExt , ResultExt , Snafu } ;
1616use stackable_operator:: {
1717 builder:: {
18+ self ,
1819 configmap:: ConfigMapBuilder ,
1920 meta:: ObjectMetaBuilder ,
2021 pod:: {
@@ -45,7 +46,9 @@ use stackable_operator::{
4546 product_config_utils:: { transform_all_roles_to_config, validate_all_roles_and_groups_config} ,
4647 product_logging:: {
4748 self ,
48- framework:: { create_vector_shutdown_file_command, remove_vector_shutdown_file_command} ,
49+ framework:: {
50+ create_vector_shutdown_file_command, remove_vector_shutdown_file_command, LoggingError ,
51+ } ,
4952 spec:: {
5053 ConfigMapLogConfig , ContainerLogConfig , ContainerLogConfigChoice ,
5154 CustomContainerLogConfig ,
@@ -291,6 +294,17 @@ pub enum Error {
291294
292295 #[ snafu( display( "authorization is only supported from HBase 2.6 onwards" ) ) ]
293296 AuthorizationNotSupported ,
297+
298+ #[ snafu( display( "failed to configure logging" ) ) ]
299+ ConfigureLogging { source : LoggingError } ,
300+
301+ #[ snafu( display( "failed to add needed volume" ) ) ]
302+ AddVolume { source : builder:: pod:: Error } ,
303+
304+ #[ snafu( display( "failed to add needed volumeMount" ) ) ]
305+ AddVolumeMount {
306+ source : builder:: pod:: container:: Error ,
307+ } ,
294308}
295309
296310type Result < T , E = Error > = std:: result:: Result < T , E > ;
@@ -859,9 +873,13 @@ fn build_rolegroup_statefulset(
859873 } ] )
860874 . add_env_vars ( merged_env)
861875 . add_volume_mount ( "hbase-config" , HBASE_CONFIG_TMP_DIR )
876+ . context ( AddVolumeMountSnafu ) ?
862877 . add_volume_mount ( "hdfs-discovery" , HDFS_DISCOVERY_TMP_DIR )
878+ . context ( AddVolumeMountSnafu ) ?
863879 . add_volume_mount ( "log-config" , HBASE_LOG_CONFIG_TMP_DIR )
880+ . context ( AddVolumeMountSnafu ) ?
864881 . add_volume_mount ( "log" , STACKABLE_LOG_DIR )
882+ . context ( AddVolumeMountSnafu ) ?
865883 . add_container_ports ( ports)
866884 . resources ( config. resources . clone ( ) . into ( ) )
867885 . startup_probe ( startup_probe)
@@ -892,6 +910,7 @@ fn build_rolegroup_statefulset(
892910 } ) ,
893911 ..Default :: default ( )
894912 } )
913+ . context ( AddVolumeSnafu ) ?
895914 . add_volume ( stackable_operator:: k8s_openapi:: api:: core:: v1:: Volume {
896915 name : "hdfs-discovery" . to_string ( ) ,
897916 config_map : Some ( ConfigMapVolumeSource {
@@ -900,12 +919,14 @@ fn build_rolegroup_statefulset(
900919 } ) ,
901920 ..Default :: default ( )
902921 } )
922+ . context ( AddVolumeSnafu ) ?
903923 . add_empty_dir_volume (
904924 "log" ,
905925 Some ( product_logging:: framework:: calculate_log_volume_size_limit (
906926 & [ MAX_HBASE_LOG_FILES_SIZE ] ,
907927 ) ) ,
908928 )
929+ . context ( AddVolumeSnafu ) ?
909930 . service_account_name ( service_account_name ( APP_NAME ) )
910931 . security_context (
911932 PodSecurityContextBuilder :: new ( )
@@ -922,23 +943,27 @@ fn build_rolegroup_statefulset(
922943 } ) ) ,
923944 } ) = config. logging . containers . get ( & Container :: Hbase )
924945 {
925- pod_builder. add_volume ( Volume {
926- name : "log-config" . to_string ( ) ,
927- config_map : Some ( ConfigMapVolumeSource {
928- name : config_map. into ( ) ,
929- ..ConfigMapVolumeSource :: default ( )
930- } ) ,
931- ..Volume :: default ( )
932- } ) ;
946+ pod_builder
947+ . add_volume ( Volume {
948+ name : "log-config" . to_string ( ) ,
949+ config_map : Some ( ConfigMapVolumeSource {
950+ name : config_map. into ( ) ,
951+ ..ConfigMapVolumeSource :: default ( )
952+ } ) ,
953+ ..Volume :: default ( )
954+ } )
955+ . context ( AddVolumeSnafu ) ?;
933956 } else {
934- pod_builder. add_volume ( Volume {
935- name : "log-config" . to_string ( ) ,
936- config_map : Some ( ConfigMapVolumeSource {
937- name : rolegroup_ref. object_name ( ) ,
938- ..ConfigMapVolumeSource :: default ( )
939- } ) ,
940- ..Volume :: default ( )
941- } ) ;
957+ pod_builder
958+ . add_volume ( Volume {
959+ name : "log-config" . to_string ( ) ,
960+ config_map : Some ( ConfigMapVolumeSource {
961+ name : rolegroup_ref. object_name ( ) ,
962+ ..ConfigMapVolumeSource :: default ( )
963+ } ) ,
964+ ..Volume :: default ( )
965+ } )
966+ . context ( AddVolumeSnafu ) ?;
942967 }
943968
944969 add_graceful_shutdown_config ( config, & mut pod_builder) . context ( GracefulShutdownSnafu ) ?;
@@ -950,18 +975,21 @@ fn build_rolegroup_statefulset(
950975
951976 // Vector sidecar shall be the last container in the list
952977 if config. logging . enable_vector_agent {
953- pod_builder. add_container ( product_logging:: framework:: vector_container (
954- resolved_product_image,
955- "hbase-config" ,
956- "log" ,
957- config. logging . containers . get ( & Container :: Vector ) ,
958- ResourceRequirementsBuilder :: new ( )
959- . with_cpu_request ( "250m" )
960- . with_cpu_limit ( "500m" )
961- . with_memory_request ( "128Mi" )
962- . with_memory_limit ( "128Mi" )
963- . build ( ) ,
964- ) ) ;
978+ pod_builder. add_container (
979+ product_logging:: framework:: vector_container (
980+ resolved_product_image,
981+ "hbase-config" ,
982+ "log" ,
983+ config. logging . containers . get ( & Container :: Vector ) ,
984+ ResourceRequirementsBuilder :: new ( )
985+ . with_cpu_request ( "250m" )
986+ . with_cpu_limit ( "500m" )
987+ . with_memory_request ( "128Mi" )
988+ . with_memory_limit ( "128Mi" )
989+ . build ( ) ,
990+ )
991+ . context ( ConfigureLoggingSnafu ) ?,
992+ ) ;
965993 }
966994
967995 let mut pod_template = pod_builder. build_template ( ) ;
0 commit comments