@@ -13,6 +13,7 @@ use product_config::{
1313 types:: PropertyNameKind ,
1414 writer:: { PropertiesWriterError , to_java_properties_string} ,
1515} ;
16+ use semver:: Version ;
1617use snafu:: { ResultExt , Snafu } ;
1718use stackable_operator:: {
1819 builder:: {
@@ -66,13 +67,15 @@ use crate::{
6667 authentication:: DruidAuthenticationConfig ,
6768 config:: jvm:: construct_jvm_args,
6869 crd:: {
69- APP_NAME , AUTH_AUTHORIZER_OPA_URI , CommonRoleGroupConfig , Container ,
70+ APP_NAME , AUTH_AUTHORIZER_OPA_URI , AWS_REGION , CommonRoleGroupConfig , Container ,
7071 DRUID_CONFIG_DIRECTORY , DS_BUCKET , DeepStorageSpec , DruidClusterStatus , DruidRole ,
71- EXTENSIONS_LOADLIST , HDFS_CONFIG_DIRECTORY , JVM_CONFIG , JVM_SECURITY_PROPERTIES_FILE ,
72- LOG_CONFIG_DIRECTORY , MAX_DRUID_LOG_FILES_SIZE , METRICS_PORT , METRICS_PORT_NAME ,
73- OPERATOR_NAME , RUNTIME_PROPS , RW_CONFIG_DIRECTORY , S3_ACCESS_KEY , S3_ENDPOINT_URL ,
74- S3_PATH_STYLE_ACCESS , S3_SECRET_KEY , STACKABLE_LOG_DIR , ZOOKEEPER_CONNECTION_STRING ,
75- build_recommended_labels, build_string_list, security:: DruidTlsSecurity , v1alpha1,
72+ EXTENSIONS_LOADLIST , HDFS_CONFIG_DIRECTORY , INDEXER_JAVA_OPTS , JVM_CONFIG ,
73+ JVM_SECURITY_PROPERTIES_FILE , LOG_CONFIG_DIRECTORY , MAX_DRUID_LOG_FILES_SIZE , METRICS_PORT ,
74+ METRICS_PORT_NAME , OPERATOR_NAME , RUNTIME_PROPS , RW_CONFIG_DIRECTORY , S3_ACCESS_KEY ,
75+ S3_ENDPOINT_URL , S3_PATH_STYLE_ACCESS , S3_SECRET_KEY , S3_USE_TRANSFER_MANAGER ,
76+ STACKABLE_LOG_DIR , STACKABLE_TRUST_STORE , STACKABLE_TRUST_STORE_PASSWORD ,
77+ ZOOKEEPER_CONNECTION_STRING , build_recommended_labels, build_string_list,
78+ security:: DruidTlsSecurity , v1alpha1,
7679 } ,
7780 discovery:: { self , build_discovery_configmaps} ,
7881 extensions:: get_extension_list,
@@ -678,15 +681,42 @@ fn build_rolegroup_config_map(
678681 }
679682
680683 if let Some ( s3) = s3_conn {
681- if !s3. region . is_default_config ( ) {
682- // Raising this as warning instead of returning an error, better safe than sorry.
683- // It might still work out for the user.
684- tracing:: warn!(
685- region = ?s3. region,
686- "You configured a non-default region on the S3Connection.
687- The S3Connection region field is ignored because Druid uses the AWS SDK v1, which ignores the region if the endpoint is set. \
688- The host is a required field, therefore the endpoint will always be set."
689- )
684+ // TODO (@NickLarsenNZ): Remove the version condition once we no longer support
685+ // Druid less than 37.0.0.
686+ // Druid >= 37.0.0 uses the AWS SDK v2, which requires a region. Older versions
687+ // use the AWS SDK v1, which ignores the region when an endpoint is set (and the
688+ // endpoint is always set because `host` is a required field on S3Connection).
689+ let druid_version = Version :: parse ( & resolved_product_image. product_version ) ;
690+ match & druid_version {
691+ Ok ( v) if * v < Version :: new ( 37 , 0 , 0 ) => {
692+ if !s3. region . is_default_config ( ) {
693+ tracing:: warn!(
694+ region = ?s3. region,
695+ "You configured a non-default region on the S3Connection. \
696+ The S3Connection region field is ignored because this Druid version \
697+ uses the AWS SDK v1, which ignores the region if the endpoint is set. \
698+ The host is a required field, therefore the endpoint will always be set."
699+ ) ;
700+ }
701+ }
702+ Err ( err) => {
703+ tracing:: warn!(
704+ %err,
705+ version = %resolved_product_image. product_version,
706+ "Failed to parse Druid product version, skipping S3 region configuration"
707+ ) ;
708+ }
709+ // For Druid >= 37.0.0, region is set via JVM system property
710+ // `-Daws.region` in the JVM_CONFIG section below.
711+ Ok ( _) => {
712+ // Disable the S3 Transfer Manager to avoid the AWS
713+ // CRT async HTTP client, which fails with non-AWS
714+ // S3 endpoints. See S3_TRANSFER_MANAGER_ENABLED.
715+ conf. insert (
716+ S3_USE_TRANSFER_MANAGER . to_string ( ) ,
717+ Some ( "false" . to_string ( ) ) ,
718+ ) ;
719+ }
690720 }
691721
692722 conf. insert (
@@ -733,6 +763,34 @@ fn build_rolegroup_config_map(
733763 // extend the config to respect overrides
734764 conf. extend ( transformed_config) ;
735765
766+ // Build javaOptsArray for Middle Manager Peon workers.
767+ // These JVM opts are passed to Peon processes spawned by the
768+ // Middle Manager.
769+ if druid_role == DruidRole :: MiddleManager {
770+ let mut peon_java_opts = vec ! [
771+ format!( "-Djavax.net.ssl.trustStore={STACKABLE_TRUST_STORE}" ) ,
772+ format!(
773+ "-Djavax.net.ssl.trustStorePassword={STACKABLE_TRUST_STORE_PASSWORD}"
774+ ) ,
775+ "-Djavax.net.ssl.trustStoreType=pkcs12" . to_owned( ) ,
776+ ] ;
777+
778+ if let Some ( s3) = s3_conn {
779+ let druid_version = Version :: parse ( & resolved_product_image. product_version ) ;
780+ if matches ! ( & druid_version, Ok ( v) if * v >= Version :: new( 37 , 0 , 0 ) ) {
781+ peon_java_opts. push ( format ! (
782+ "-D{AWS_REGION}={region_name}" ,
783+ region_name = s3. region. name,
784+ ) ) ;
785+ }
786+ }
787+
788+ conf. insert (
789+ INDEXER_JAVA_OPTS . to_string ( ) ,
790+ Some ( build_string_list ( & peon_java_opts) ) ,
791+ ) ;
792+ }
793+
736794 let runtime_properties =
737795 to_java_properties_string ( conf. iter ( ) ) . context ( PropertiesWriteSnafu ) ?;
738796 cm_conf_data. insert ( RUNTIME_PROPS . to_string ( ) , runtime_properties) ;
@@ -743,9 +801,19 @@ fn build_rolegroup_config_map(
743801 . resources
744802 . get_memory_sizes ( & druid_role)
745803 . context ( DeriveMemorySettingsSnafu ) ?;
746- let jvm_config =
747- construct_jvm_args ( & druid_role, & role, & rolegroup. role_group , heap, direct)
748- . context ( GetJvmConfigSnafu ) ?;
804+ // TODO (@NickLarsenNZ): Remove this once we don't support Druid less than 37.0.0
805+ let druid_version = Version :: parse ( & resolved_product_image. product_version ) ;
806+ let jvm_config = construct_jvm_args (
807+ & druid_role,
808+ & role,
809+ & rolegroup. role_group ,
810+ heap,
811+ direct,
812+ s3_conn,
813+ druid_version,
814+ )
815+ . context ( GetJvmConfigSnafu ) ?;
816+
749817 cm_conf_data. insert ( JVM_CONFIG . to_string ( ) , jvm_config) ;
750818 }
751819
0 commit comments