Skip to content

Commit

Permalink
fix service access in diff namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
catpineapple committed Nov 13, 2024
1 parent 1a70fe9 commit b51e93e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
4 changes: 4 additions & 0 deletions api/disaggregated/v1/unique_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func (ddc *DorisDisaggregatedCluster) GetFEServiceName() string {
return ddc.Name + "-" + "fe"
}

func (ddc *DorisDisaggregatedCluster) GetFEServiceNameForAccess() string {
return ddc.GetFEServiceName() + "." + ddc.Namespace
}

func (ddc *DorisDisaggregatedCluster) GetFEInternalServiceName() string {
return ddc.Name + "-" + "fe-internal"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,8 @@ func (dcgs *DisaggregatedComputeGroupsController) scaledOutBENodesBySQL(
adminUserName, password := resource.GetDorisLoginInformation(secret)

// get host and port
serviceName := cluster.GetFEServiceName()
// When the operator and dcr are deployed in different namespace, it will be inaccessible, so need to add the dcr svc namespace
host := serviceName + "." + cluster.Namespace
host := cluster.GetFEServiceNameForAccess()
confMap := dcgs.GetConfigValuesFromConfigMaps(cluster.Namespace, resource.FE_RESOLVEKEY, cluster.Spec.FeSpec.ConfigMaps)
queryPort := resource.GetPort(confMap, resource.QUERY_PORT)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (dcgs *DisaggregatedComputeGroupsController) newSpecificEnvs(ddc *dv1.Doris
fqp := resource.GetPort(confMap, resource.QUERY_PORT)
fqpStr := strconv.FormatInt(int64(fqp), 10)
//use fe service name as access address.
feAddr := ddc.GetFEServiceName()
feAddr := ddc.GetFEServiceNameForAccess()
cgEnvs = append(cgEnvs,
corev1.EnvVar{Name: resource.STATEFULSET_NAME, Value: stsName},
corev1.EnvVar{Name: resource.COMPUTE_GROUP_NAME, Value: ddc.GetCGName(cg)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ func (dfc *DisaggregatedFEController) dropFEBySQLClient(ctx context.Context, k8s
adminUserName, password := resource.GetDorisLoginInformation(secret)

// get host and port
serviceName := cluster.GetFEServiceName()
// When the operator and dcr are deployed in different namespace, it will be inaccessible, so need to add the dcr svc namespace
host := serviceName + "." + cluster.Namespace
host := cluster.GetFEServiceNameForAccess()
confMap := dfc.GetConfigValuesFromConfigMaps(cluster.Namespace, resource.FE_RESOLVEKEY, cluster.Spec.FeSpec.ConfigMaps)
queryPort := resource.GetPort(confMap, resource.QUERY_PORT)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (dfc *DisaggregatedFEController) newSpecificEnvs(ddc *v1.DorisDisaggregated
corev1.EnvVar{Name: MS_ENDPOINT, Value: msEndpoint},
corev1.EnvVar{Name: CLUSTER_ID, Value: fmt.Sprintf("%d", ddc.GetInstanceHashId())},
corev1.EnvVar{Name: STATEFULSET_NAME, Value: stsName},
corev1.EnvVar{Name: resource.ENV_FE_ADDR, Value: ddc.GetFEServiceName()},
corev1.EnvVar{Name: resource.ENV_FE_ADDR, Value: ddc.GetFEServiceNameForAccess()},
corev1.EnvVar{Name: resource.ENV_FE_ELECT_NUMBER, Value: strconv.FormatInt(int64(ddc.GetElectionNumber()), 10)},
)
return feEnvs
Expand Down

0 comments on commit b51e93e

Please sign in to comment.