@@ -22,7 +22,7 @@ use stackable_operator::{
2222 } ,
2323 cluster_resources:: { ClusterResourceApplyStrategy , ClusterResources } ,
2424 commons:: {
25- listener:: { Listener , ListenerPort , ListenerSpec } ,
25+ listener:: { Listener , ListenerPort } ,
2626 product_image_selection:: ResolvedProductImage ,
2727 } ,
2828 k8s_openapi:: {
@@ -66,6 +66,7 @@ use crate::{
6666 VOLUME_MOUNT_PATH_LOG , VOLUME_MOUNT_PATH_LOG_CONFIG ,
6767 } ,
6868 history:: { self , HistoryConfig , SparkHistoryServerContainer , v1alpha1} ,
69+ listener,
6970 logdir:: ResolvedLogDir ,
7071 tlscerts, to_spark_env_sh_string,
7172 } ,
@@ -82,6 +83,9 @@ pub enum Error {
8283 source : stackable_operator:: builder:: meta:: Error ,
8384 } ,
8485
86+ #[ snafu( display( "failed to build spark history group listener" ) ) ]
87+ BuildListener { source : crate :: crd:: listener:: Error } ,
88+
8589 #[ snafu( display( "failed to build listener volume" ) ) ]
8690 BuildListenerVolume {
8791 source : ListenerOperatorVolumeSourceBuilderError ,
@@ -363,41 +367,27 @@ fn build_group_listener(
363367 rolegroup : & RoleGroupRef < v1alpha1:: SparkHistoryServer > ,
364368 listener_class : String ,
365369) -> Result < Listener , Error > {
366- Ok ( Listener {
367- metadata : ObjectMetaBuilder :: new ( )
368- . name_and_namespace ( shs)
369- . name ( shs. group_listener_name ( rolegroup) )
370- . ownerreference_from_resource ( shs, None , Some ( true ) )
371- . context ( ObjectMissingMetadataForOwnerRefSnafu ) ?
372- . with_recommended_labels ( labels (
373- shs,
374- & resolved_product_image. app_version_label ,
375- & rolegroup. role_group ,
376- ) )
377- . context ( ObjectMetaSnafu ) ?
378- . build ( ) ,
379- spec : ListenerSpec {
380- class_name : Some ( listener_class) ,
381- ports : Some ( listener_ports ( ) ) ,
382- ..ListenerSpec :: default ( )
383- } ,
384- status : None ,
385- } )
386- }
370+ let listener_name = rolegroup. object_name ( ) ;
371+ let recommended_object_labels = labels (
372+ shs,
373+ & resolved_product_image. app_version_label ,
374+ & rolegroup. role_group ,
375+ ) ;
387376
388- fn listener_ports ( ) -> Vec < ListenerPort > {
389- vec ! [
390- ListenerPort {
391- name: "metrics" . to_string( ) ,
392- port: METRICS_PORT . into( ) ,
393- protocol: Some ( "TCP" . to_string( ) ) ,
394- } ,
395- ListenerPort {
396- name: "http" . to_string( ) ,
397- port: HISTORY_UI_PORT . into( ) ,
398- protocol: Some ( "TCP" . to_string( ) ) ,
399- } ,
400- ]
377+ let listener_ports = [ ListenerPort {
378+ name : "http" . to_string ( ) ,
379+ port : HISTORY_UI_PORT . into ( ) ,
380+ protocol : Some ( "TCP" . to_string ( ) ) ,
381+ } ] ;
382+
383+ listener:: build_listener (
384+ shs,
385+ & listener_name,
386+ & listener_class,
387+ recommended_object_labels,
388+ & listener_ports,
389+ )
390+ . context ( BuildListenerSnafu )
401391}
402392
403393pub fn error_policy (
@@ -607,7 +597,7 @@ fn build_stateful_set(
607597 // cluster-internal) as the address should still be consistent.
608598 let volume_claim_templates = Some ( vec ! [
609599 ListenerOperatorVolumeSourceBuilder :: new(
610- & ListenerReference :: ListenerName ( shs . group_listener_name ( rolegroupref ) ) ,
600+ & ListenerReference :: ListenerName ( rolegroupref . object_name ( ) ) ,
611601 & recommended_labels,
612602 )
613603 . context( BuildListenerVolumeSnafu ) ?
0 commit comments