@@ -867,6 +867,27 @@ fn build_rolegroup_config_map(
867867 }
868868 }
869869 PropertyNameKind :: File ( file_name) if file_name == JVM_CONFIG => { }
870+ PropertyNameKind :: File ( file_name) if file_name == SPOOLING_MANAGER_PROPERTIES => {
871+ // Add automatic properties for the spooling protocol
872+ if let Some ( spooling_config) = resolved_spooling_config {
873+ dynamic_resolved_config = spooling_config
874+ . spooling_manager_properties
875+ . iter ( )
876+ . map ( |( k, v) | ( k. clone ( ) , Some ( v. clone ( ) ) ) )
877+ . collect ( ) ;
878+ }
879+
880+ // Override automatic properties with user provided configuration for the spooling protocol
881+ dynamic_resolved_config. extend ( transformed_config) ;
882+
883+ if !dynamic_resolved_config. is_empty ( ) {
884+ cm_conf_data. insert (
885+ file_name. to_string ( ) ,
886+ to_java_properties_string ( dynamic_resolved_config. iter ( ) )
887+ . with_context ( |_| FailedToWriteJavaPropertiesSnafu ) ?,
888+ ) ;
889+ }
890+ }
870891 _ => { }
871892 }
872893 }
@@ -889,20 +910,6 @@ fn build_rolegroup_config_map(
889910 }
890911 }
891912
892- // Add client protocol properties (especially spooling properties)
893- if let Some ( spooling_config) = resolved_spooling_config {
894- let spooling_props_with_options: BTreeMap < String , Option < String > > = spooling_config
895- . spooling_manager_properties
896- . iter ( )
897- . map ( |( k, v) | ( k. clone ( ) , Some ( v. clone ( ) ) ) )
898- . collect ( ) ;
899- cm_conf_data. insert (
900- SPOOLING_MANAGER_PROPERTIES . to_string ( ) ,
901- to_java_properties_string ( spooling_props_with_options. iter ( ) )
902- . with_context ( |_| FailedToWriteJavaPropertiesSnafu ) ?,
903- ) ;
904- }
905-
906913 let jvm_sec_props: BTreeMap < String , Option < String > > = config
907914 . get ( & PropertyNameKind :: File ( JVM_SECURITY_PROPERTIES . to_string ( ) ) )
908915 . cloned ( )
@@ -1435,6 +1442,7 @@ fn validated_product_config(
14351442 PropertyNameKind :: File ( LOG_PROPERTIES . to_string( ) ) ,
14361443 PropertyNameKind :: File ( JVM_SECURITY_PROPERTIES . to_string( ) ) ,
14371444 PropertyNameKind :: File ( ACCESS_CONTROL_PROPERTIES . to_string( ) ) ,
1445+ PropertyNameKind :: File ( SPOOLING_MANAGER_PROPERTIES . to_string( ) ) ,
14381446 ] ;
14391447
14401448 let coordinator_role = TrinoRole :: Coordinator ;
@@ -1802,6 +1810,7 @@ mod tests {
18021810 use stackable_operator:: commons:: networking:: DomainName ;
18031811
18041812 use super :: * ;
1813+ use crate :: crd:: client_protocol:: ResolvedClientProtocolConfig ;
18051814
18061815 #[ test]
18071816 fn test_config_overrides ( ) {
@@ -1838,7 +1847,7 @@ mod tests {
18381847 default:
18391848 replicas: 1
18401849 "# ;
1841- let cm = build_config_map ( trino_yaml) . data . unwrap ( ) ;
1850+ let cm = build_config_map ( trino_yaml, & None , & None ) . data . unwrap ( ) ;
18421851 let config = cm. get ( "config.properties" ) . unwrap ( ) ;
18431852 assert ! ( config. contains( "foo=bar" ) ) ;
18441853 assert ! ( config. contains( "level=role-group" ) ) ;
@@ -1861,7 +1870,74 @@ mod tests {
18611870 assert ! ( cm. contains_key( "access-control.properties" ) ) ;
18621871 }
18631872
1864- fn build_config_map ( trino_yaml : & str ) -> ConfigMap {
1873+ #[ test]
1874+ fn test_client_protocol_config_overrides ( ) {
1875+ let trino_yaml = r#"
1876+ apiVersion: trino.stackable.tech/v1alpha1
1877+ kind: TrinoCluster
1878+ metadata:
1879+ name: simple-trino
1880+ spec:
1881+ image:
1882+ productVersion: "470"
1883+ clusterConfig:
1884+ catalogLabelSelector:
1885+ matchLabels:
1886+ trino: simple-trino
1887+ coordinators:
1888+ configOverrides:
1889+ config.properties:
1890+ protocol.spooling.enabled: "false"
1891+ spooling-manager.properties:
1892+ fs.location: s3a://bucket/cluster/spooling
1893+ roleGroups:
1894+ default:
1895+ configOverrides:
1896+ config.properties:
1897+ protocol.spooling.enabled: "false"
1898+ spooling-manager.properties:
1899+ fs.location: s3a://bucket/cluster/spooling
1900+ replicas: 1
1901+ workers:
1902+ roleGroups:
1903+ default:
1904+ replicas: 1
1905+ "# ;
1906+ let resolved_spooling_config = Some ( ResolvedClientProtocolConfig {
1907+ config_properties : BTreeMap :: from ( [
1908+ ( "protocol.spooling.enabled" . to_string ( ) , "true" . to_string ( ) ) ,
1909+ (
1910+ "protocol.spooling.shared-secret-key" . to_string ( ) ,
1911+ "test" . to_string ( ) ,
1912+ ) ,
1913+ ] ) ,
1914+ spooling_manager_properties : BTreeMap :: from ( [ (
1915+ "spooling-manager.name" . to_string ( ) ,
1916+ "filesystem" . to_string ( ) ,
1917+ ) ] ) ,
1918+ volume_mounts : vec ! [ ] ,
1919+ volumes : vec ! [ ] ,
1920+ load_env_from_files : BTreeMap :: new ( ) ,
1921+ init_container_extra_start_commands : vec ! [ ] ,
1922+ } ) ;
1923+
1924+ let cm = build_config_map ( trino_yaml, & None , & resolved_spooling_config)
1925+ . data
1926+ . unwrap ( ) ;
1927+ let config = cm. get ( "config.properties" ) . unwrap ( ) ;
1928+ assert ! ( config. contains( "protocol.spooling.enabled=false" ) ) ;
1929+ assert ! ( config. contains( "protocol.spooling.shared-secret-key=test" ) ) ;
1930+
1931+ let config = cm. get ( "spooling-manager.properties" ) . unwrap ( ) ;
1932+ assert ! ( config. contains( "fs.location=s3a\\ ://bucket/cluster/spooling" ) ) ;
1933+ assert ! ( config. contains( "spooling-manager.name=filesystem" ) ) ;
1934+ }
1935+
1936+ fn build_config_map (
1937+ trino_yaml : & str ,
1938+ resolved_fte_config : & Option < ResolvedFaultTolerantExecutionConfig > ,
1939+ resolved_spooling_config : & Option < client_protocol:: ResolvedClientProtocolConfig > ,
1940+ ) -> ConfigMap {
18651941 let mut trino: v1alpha1:: TrinoCluster =
18661942 serde_yaml:: from_str ( trino_yaml) . expect ( "illegal test input" ) ;
18671943 trino. metadata . namespace = Some ( "default" . to_owned ( ) ) ;
@@ -1882,6 +1958,7 @@ mod tests {
18821958 PropertyNameKind :: File ( LOG_PROPERTIES . to_string( ) ) ,
18831959 PropertyNameKind :: File ( JVM_SECURITY_PROPERTIES . to_string( ) ) ,
18841960 PropertyNameKind :: File ( ACCESS_CONTROL_PROPERTIES . to_string( ) ) ,
1961+ PropertyNameKind :: File ( SPOOLING_MANAGER_PROPERTIES . to_string( ) ) ,
18851962 ] ;
18861963 let validated_config = validate_all_roles_and_groups_config (
18871964 // The Trino version is a single number like 396.
@@ -1964,8 +2041,8 @@ mod tests {
19642041 & trino_authentication_config,
19652042 & trino_opa_config,
19662043 & cluster_info,
1967- & None ,
1968- & None ,
2044+ resolved_fte_config ,
2045+ resolved_spooling_config ,
19692046 )
19702047 . unwrap ( )
19712048 }
@@ -2008,7 +2085,7 @@ mod tests {
20082085 replicas: 1
20092086 "# ;
20102087
2011- let cm = build_config_map ( trino_yaml) . data . unwrap ( ) ;
2088+ let cm = build_config_map ( trino_yaml, & None , & None ) . data . unwrap ( ) ;
20122089 let access_control_config = cm. get ( "access-control.properties" ) . unwrap ( ) ;
20132090
20142091 assert ! ( access_control_config. contains( "access-control.name=opa" ) ) ;
0 commit comments