@@ -161,6 +161,7 @@ func getTiFlashConfigV2(tc *v1alpha1.TidbCluster) *v1alpha1.TiFlashConfigWraper
161161 listenHost = listenHostForIPv6
162162 }
163163 version := tc .TiFlashVersion ()
164+ ticiEnabled := tc .Spec .TiCI != nil && tc .Spec .TiCI .S3 != nil
164165
165166 // common
166167 {
@@ -207,7 +208,12 @@ func getTiFlashConfigV2(tc *v1alpha1.TidbCluster) *v1alpha1.TiFlashConfigWraper
207208 }
208209 common .SetIfNil ("flash.tidb_status_addr" , tidbStatusAddr )
209210 if ! mountCMInTiflashContainer {
210- common .SetIfNil ("flash.service_addr" , fmt .Sprintf ("%s:%d" , listenHost , v1alpha1 .DefaultTiFlashFlashPort ))
211+ flashServiceAddr := fmt .Sprintf ("%s:%d" , listenHost , v1alpha1 .DefaultTiFlashFlashPort )
212+ if ticiEnabled {
213+ flashServiceAddr = fmt .Sprintf ("%s-POD_NUM.%s.%s.svc%s:%d" , controller .TiFlashMemberName (name ),
214+ controller .TiFlashPeerMemberName (name ), ns , controller .FormatClusterDomain (clusterDomain ), v1alpha1 .DefaultTiFlashFlashPort )
215+ }
216+ common .SetIfNil ("flash.service_addr" , flashServiceAddr )
211217 }
212218 common .SetIfNil ("flash.flash_cluster.log" , defaultClusterLog )
213219 common .SetIfNil ("flash.proxy.addr" , fmt .Sprintf ("%s:%d" , listenHost , v1alpha1 .DefaultTiFlashProxyPort ))
@@ -314,12 +320,13 @@ func getTiFlashConfig(tc *v1alpha1.TidbCluster) *v1alpha1.TiFlashConfigWraper {
314320 noLocalPD := tc .WithoutLocalPD ()
315321 acrossK8s := tc .AcrossK8s ()
316322 noLocalTiDB := tc .WithoutLocalTiDB ()
323+ ticiEnabled := tc .Spec .TiCI != nil && tc .Spec .TiCI .S3 != nil
317324 listenHost := listenHostForIPv4
318325 if tc .Spec .PreferIPv6 {
319326 listenHost = listenHostForIPv6
320327 }
321328
322- setTiFlashConfigDefault (config , ref , tc .Name , tc .Namespace , tc .Spec .ClusterDomain , listenHost , noLocalPD , noLocalTiDB , acrossK8s )
329+ setTiFlashConfigDefault (config , ref , tc .Name , tc .Namespace , tc .Spec .ClusterDomain , listenHost , noLocalPD , noLocalTiDB , acrossK8s , ticiEnabled )
323330
324331 // Note the config of tiflash use "_" by convention, others(proxy) use "-".
325332 if tc .IsTLSClusterEnabled () {
@@ -361,12 +368,12 @@ func setTiFlashLogConfigDefault(config *v1alpha1.TiFlashConfigWraper) {
361368
362369// setTiFlashConfigDefault sets default configs for TiFlash
363370func setTiFlashConfigDefault (config * v1alpha1.TiFlashConfigWraper , ref * v1alpha1.TidbClusterRef ,
364- clusterName , ns , clusterDomain , listenHost string , noLocalPD bool , noLocalTiDB bool , acrossK8s bool ,
371+ clusterName , ns , clusterDomain , listenHost string , noLocalPD bool , noLocalTiDB bool , acrossK8s bool , ticiEnabled bool ,
365372) {
366373 if config .Common == nil {
367374 config .Common = v1alpha1 .NewTiFlashCommonConfig ()
368375 }
369- setTiFlashCommonConfigDefault (config .Common , ref , clusterName , ns , clusterDomain , listenHost , noLocalPD , noLocalTiDB , acrossK8s )
376+ setTiFlashCommonConfigDefault (config .Common , ref , clusterName , ns , clusterDomain , listenHost , noLocalPD , noLocalTiDB , acrossK8s , ticiEnabled )
370377
371378 if config .Proxy == nil {
372379 config .Proxy = v1alpha1 .NewTiFlashProxyConfig ()
@@ -383,7 +390,7 @@ func setTiFlashProxyConfigDefault(config *v1alpha1.TiFlashProxyConfigWraper, clu
383390 controller .FormatClusterDomain (clusterDomain ), v1alpha1 .DefaultTiFlashProxyStatusPort ))
384391}
385392
386- func setTiFlashCommonConfigDefault (config * v1alpha1.TiFlashCommonConfigWraper , ref * v1alpha1.TidbClusterRef , clusterName , ns , clusterDomain , listenHost string , noLocalPD bool , noLocalTiDB bool , acrossK8s bool ) {
393+ func setTiFlashCommonConfigDefault (config * v1alpha1.TiFlashCommonConfigWraper , ref * v1alpha1.TidbClusterRef , clusterName , ns , clusterDomain , listenHost string , noLocalPD bool , noLocalTiDB bool , acrossK8s bool , ticiEnabled bool ) {
387394 config .SetIfNil ("tmp_path" , "/data0/tmp" )
388395 config .SetIfNil ("display_name" , "TiFlash" )
389396 config .SetIfNil ("default_profile" , "default" )
@@ -396,7 +403,7 @@ func setTiFlashCommonConfigDefault(config *v1alpha1.TiFlashCommonConfigWraper, r
396403 config .SetIfNil ("https_port" , int64 (v1alpha1 .DefaultTiFlashHttpPort ))
397404 config .SetIfNil ("http_port" , int64 (v1alpha1 .DefaultTiFlashHttpPort ))
398405 config .SetIfNil ("interserver_http_port" , int64 (v1alpha1 .DefaultTiFlashInternalPort ))
399- setTiFlashFlashConfigDefault (config , ref , clusterName , ns , clusterDomain , listenHost , noLocalTiDB , acrossK8s )
406+ setTiFlashFlashConfigDefault (config , ref , clusterName , ns , clusterDomain , listenHost , noLocalTiDB , acrossK8s , ticiEnabled )
400407 setTiFlashLoggerConfigDefault (config )
401408 setTiFlashApplicationConfigDefault (config )
402409
@@ -431,7 +438,7 @@ func setTiFlashCommonConfigDefault(config *v1alpha1.TiFlashCommonConfigWraper, r
431438 config .SetIfNil ("profiles.default.use_uncompressed_cache" , int64 (0 ))
432439}
433440
434- func setTiFlashFlashConfigDefault (config * v1alpha1.TiFlashCommonConfigWraper , ref * v1alpha1.TidbClusterRef , clusterName , ns , clusterDomain , listenHost string , noLocalTiDB , acrossK8s bool ) {
441+ func setTiFlashFlashConfigDefault (config * v1alpha1.TiFlashCommonConfigWraper , ref * v1alpha1.TidbClusterRef , clusterName , ns , clusterDomain , listenHost string , noLocalTiDB , acrossK8s bool , ticiEnabled bool ) {
435442 tidbStatusAddr := fmt .Sprintf ("%s.%s.svc:%d" , controller .TiDBMemberName (clusterName ), ns , v1alpha1 .DefaultTiDBStatusPort )
436443 if noLocalTiDB {
437444 // TODO: support first cluster without TiDB when deploy cluster across mutli Kubernete clusters
@@ -449,7 +456,16 @@ func setTiFlashFlashConfigDefault(config *v1alpha1.TiFlashCommonConfigWraper, re
449456 }
450457
451458 config .SetIfNil ("flash.tidb_status_addr" , tidbStatusAddr )
452- config .SetIfNil ("flash.service_addr" , fmt .Sprintf ("%s:%d" , listenHost , v1alpha1 .DefaultTiFlashFlashPort ))
459+ flashServiceAddr := fmt .Sprintf ("%s:%d" , listenHost , v1alpha1 .DefaultTiFlashFlashPort )
460+ if ticiEnabled {
461+ flashServiceAddr = fmt .Sprintf ("%s-POD_NUM.%s.%s.svc%s:%d" ,
462+ controller .TiFlashMemberName (clusterName ),
463+ controller .TiFlashPeerMemberName (clusterName ),
464+ ns ,
465+ controller .FormatClusterDomain (clusterDomain ),
466+ v1alpha1 .DefaultTiFlashFlashPort )
467+ }
468+ config .SetIfNil ("flash.service_addr" , flashServiceAddr )
453469 config .SetIfNil ("flash.overlap_threshold" , 0.6 )
454470 config .SetIfNil ("flash.compact_log_min_period" , int64 (200 ))
455471
0 commit comments