Skip to content

Commit 53bb65a

Browse files
committed
refactor: use pod ip instead of service name to make it consistent
Signed-off-by: zyy17 <[email protected]>
1 parent e53b240 commit 53bb65a

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

cmd/initializer/internal/config_generator.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ func (c *ConfigGenerator) generateDatanodeConfig(initConfig []byte) ([]byte, err
124124
return nil, fmt.Errorf("empty pod name")
125125
}
126126

127-
datanodeCfg.RPCServerAddr = ptr.To(fmt.Sprintf("%s.%s.%s:%d", podName,
128-
c.DatanodeServiceName, c.Namespace, c.DatanodeRPCPort))
127+
datanodeCfg.RPCServerAddr = ptr.To(fmt.Sprintf("%s:%d", podIP, c.DatanodeRPCPort))
129128

130129
configData, err := dbconfig.Marshal(cfg, v1alpha1.ConfigMergeStrategyOperatorFirst)
131130
if err != nil {
@@ -167,8 +166,7 @@ func (c *ConfigGenerator) generateFlownodeConfig(initConfig []byte) ([]byte, err
167166
return nil, fmt.Errorf("empty pod name")
168167
}
169168

170-
flownodeCfg.RPCServerAddr = ptr.To(fmt.Sprintf("%s.%s.%s:%d", podName,
171-
c.ServiceName, c.Namespace, c.RPCPort))
169+
flownodeCfg.RPCServerAddr = ptr.To(fmt.Sprintf("%s:%d", podIP, c.RPCPort))
172170

173171
configData, err := dbconfig.Marshal(cfg, v1alpha1.ConfigMergeStrategyOperatorFirst)
174172
if err != nil {

cmd/initializer/internal/config_generator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func TestDatanodeConfigGenerator(t *testing.T) {
9393
if !ok {
9494
t.Fatalf("grpc server_addr is not string")
9595
}
96-
wantRPCServerAddr := fmt.Sprintf("%s.%s.%s:%d", testDatanodePodName, testClusterService, testClusterNamespace, testRPCPort)
96+
wantRPCServerAddr := fmt.Sprintf("%s:%d", testPodIP, testRPCPort)
9797
if !reflect.DeepEqual(wantRPCServerAddr, rpcServerAddr) {
9898
t.Fatalf("RPCServerAddr is not equal, want: '%s', got: '%s'", wantRPCServerAddr, rpcServerAddr)
9999
}
@@ -154,7 +154,7 @@ func TestFlownodeConfigGenerator(t *testing.T) {
154154
if !ok {
155155
t.Fatalf("grpc server_addr is not string")
156156
}
157-
wantRPCServerAddr := fmt.Sprintf("%s.%s.%s:%d", testFlownodePodName, testClusterService, testClusterNamespace, testRPCPort)
157+
wantRPCServerAddr := fmt.Sprintf("%s:%d", testPodIP, testRPCPort)
158158
if !reflect.DeepEqual(wantRPCServerAddr, rpcServerAddr) {
159159
t.Fatalf("RPCServerAddr is not equal, want: '%s', got: '%s'", wantRPCServerAddr, rpcServerAddr)
160160
}

0 commit comments

Comments
 (0)