@@ -39,7 +39,7 @@ use stackable_operator::{
3939 core:: { DeserializeGuard , error_boundary} ,
4040 runtime:: { controller:: Action , reflector:: ObjectRef } ,
4141 } ,
42- kvp:: { Labels , ObjectLabels } ,
42+ kvp:: Labels ,
4343 logging:: controller:: ReconcilerError ,
4444 product_logging:: {
4545 framework:: { LoggingError , calculate_log_volume_size_limit, vector_container} ,
@@ -57,20 +57,24 @@ use crate::{
5757 Ctx ,
5858 crd:: {
5959 constants:: {
60- ACCESS_KEY_ID , HISTORY_APP_NAME , HISTORY_CONTROLLER_NAME , HISTORY_ROLE_NAME ,
61- HISTORY_UI_PORT , JVM_SECURITY_PROPERTIES_FILE , LISTENER_VOLUME_DIR ,
62- LISTENER_VOLUME_NAME , MAX_SPARK_LOG_FILES_SIZE , METRICS_PORT , OPERATOR_NAME ,
63- SECRET_ACCESS_KEY , SPARK_DEFAULTS_FILE_NAME , SPARK_ENV_SH_FILE_NAME ,
64- SPARK_IMAGE_BASE_NAME , STACKABLE_TRUST_STORE , VOLUME_MOUNT_NAME_CONFIG ,
65- VOLUME_MOUNT_NAME_LOG , VOLUME_MOUNT_NAME_LOG_CONFIG , VOLUME_MOUNT_PATH_CONFIG ,
66- VOLUME_MOUNT_PATH_LOG , VOLUME_MOUNT_PATH_LOG_CONFIG ,
60+ ACCESS_KEY_ID , HISTORY_APP_NAME , HISTORY_CONTROLLER_NAME , HISTORY_UI_PORT ,
61+ JVM_SECURITY_PROPERTIES_FILE , LISTENER_VOLUME_DIR , LISTENER_VOLUME_NAME ,
62+ MAX_SPARK_LOG_FILES_SIZE , METRICS_PORT , OPERATOR_NAME , SECRET_ACCESS_KEY ,
63+ SPARK_DEFAULTS_FILE_NAME , SPARK_ENV_SH_FILE_NAME , SPARK_IMAGE_BASE_NAME ,
64+ STACKABLE_TRUST_STORE , VOLUME_MOUNT_NAME_CONFIG , VOLUME_MOUNT_NAME_LOG ,
65+ VOLUME_MOUNT_NAME_LOG_CONFIG , VOLUME_MOUNT_PATH_CONFIG , VOLUME_MOUNT_PATH_LOG ,
66+ VOLUME_MOUNT_PATH_LOG_CONFIG ,
6767 } ,
6868 history:: { self , HistoryConfig , SparkHistoryServerContainer , v1alpha1} ,
6969 listener_ext,
7070 logdir:: ResolvedLogDir ,
7171 tlscerts, to_spark_env_sh_string,
7272 } ,
73- history:: operations:: pdb:: add_pdbs,
73+ history:: {
74+ operations:: pdb:: add_pdbs,
75+ recommended_labels,
76+ service:: { self , build_rolegroup_metrics_service} ,
77+ } ,
7478 product_logging:: { self } ,
7579} ;
7680
@@ -96,9 +100,6 @@ pub enum Error {
96100 #[ snafu( display( "missing secret lifetime" ) ) ]
97101 MissingSecretLifetime ,
98102
99- #[ snafu( display( "object has no namespace" ) ) ]
100- ObjectHasNoNamespace ,
101-
102103 #[ snafu( display( "invalid config map {name}" ) ) ]
103104 InvalidConfigMap {
104105 source : stackable_operator:: builder:: configmap:: Error ,
@@ -125,6 +126,11 @@ pub enum Error {
125126 source : stackable_operator:: cluster_resources:: Error ,
126127 } ,
127128
129+ #[ snafu( display( "failed to update history server metrics service" ) ) ]
130+ ApplyMetricsService {
131+ source : stackable_operator:: cluster_resources:: Error ,
132+ } ,
133+
128134 #[ snafu( display( "failed to apply role ServiceAccount" ) ) ]
129135 ApplyServiceAccount {
130136 source : stackable_operator:: cluster_resources:: Error ,
@@ -233,6 +239,9 @@ pub enum Error {
233239 ResolveProductImage {
234240 source : product_image_selection:: Error ,
235241 } ,
242+
243+ #[ snafu( display( "failed to resolve product image" ) ) ]
244+ BuildMetricsService { source : service:: Error } ,
236245}
237246
238247impl ReconcilerError for Error {
@@ -320,10 +329,10 @@ pub async fn reconcile(
320329 & rgr,
321330 & log_dir,
322331 ) ?;
323- cluster_resources
324- . add ( client , config_map )
325- . await
326- . context ( ApplyConfigMapSnafu ) ?;
332+
333+ let metrics_service =
334+ build_rolegroup_metrics_service ( shs , & resolved_product_image , & rgr )
335+ . context ( BuildMetricsServiceSnafu ) ?;
327336
328337 let sts = build_stateful_set (
329338 shs,
@@ -333,6 +342,15 @@ pub async fn reconcile(
333342 & merged_config,
334343 & service_account,
335344 ) ?;
345+
346+ cluster_resources
347+ . add ( client, config_map)
348+ . await
349+ . context ( ApplyConfigMapSnafu ) ?;
350+ cluster_resources
351+ . add ( client, metrics_service)
352+ . await
353+ . context ( ApplyMetricsServiceSnafu ) ?;
336354 cluster_resources
337355 . add ( client, sts)
338356 . await
@@ -380,7 +398,7 @@ fn build_group_listener(
380398 let listener_name = group_listener_name ( shs, role) ;
381399
382400 let recommended_object_labels =
383- labels ( shs, & resolved_product_image. app_version_label_value , "none" ) ;
401+ recommended_labels ( shs, & resolved_product_image. app_version_label_value , "none" ) ;
384402
385403 let listener_ports = [ listener:: v1alpha1:: ListenerPort {
386404 name : "http" . to_string ( ) ,
@@ -445,7 +463,7 @@ fn build_config_map(
445463 . name ( & cm_name)
446464 . ownerreference_from_resource ( shs, None , Some ( true ) )
447465 . context ( ObjectMissingMetadataForOwnerRefSnafu ) ?
448- . with_recommended_labels ( labels (
466+ . with_recommended_labels ( recommended_labels (
449467 shs,
450468 app_version_label_value,
451469 & rolegroupref. role_group ,
@@ -511,7 +529,7 @@ fn build_stateful_set(
511529 rolegroupref. object_name ( )
512530 } ;
513531
514- let recommended_object_labels = labels (
532+ let recommended_object_labels = recommended_labels (
515533 shs,
516534 & resolved_product_image. app_version_label_value ,
517535 rolegroupref. role_group . as_ref ( ) ,
@@ -732,22 +750,6 @@ fn command_args(logdir: &ResolvedLogDir) -> Vec<String> {
732750 vec ! [ command. join( "\n " ) ]
733751}
734752
735- fn labels < ' a , T > (
736- shs : & ' a T ,
737- app_version_label_value : & ' a str ,
738- role_group : & ' a str ,
739- ) -> ObjectLabels < ' a , T > {
740- ObjectLabels {
741- owner : shs,
742- app_name : HISTORY_APP_NAME ,
743- app_version : app_version_label_value,
744- operator_name : OPERATOR_NAME ,
745- controller_name : HISTORY_CONTROLLER_NAME ,
746- role : HISTORY_ROLE_NAME ,
747- role_group,
748- }
749- }
750-
751753/// Return the Spark properties for the cleaner role group (if any).
752754/// There should be only one role group with "cleaner=true" and this
753755/// group should have a replica count of 0 or 1.
0 commit comments