|
7 | 7 | "fmt"
|
8 | 8 | "math"
|
9 | 9 | "net"
|
10 |
| - "os" |
11 | 10 | "slices"
|
12 | 11 | "strconv"
|
13 | 12 | "strings"
|
@@ -311,22 +310,22 @@ func (qc *qdbCoordinator) lockCoordinator(ctx context.Context, initialRouter boo
|
311 | 310 | if !initialRouter {
|
312 | 311 | return true
|
313 | 312 | }
|
| 313 | + routerHost, err := config.GetHostOrHostname(config.RouterConfig().Host) |
| 314 | + if err != nil { |
| 315 | + return false |
| 316 | + } |
314 | 317 | router := &topology.Router{
|
315 | 318 | ID: uuid.NewString(),
|
316 |
| - Address: net.JoinHostPort(config.RouterConfig().Host, config.RouterConfig().GrpcApiPort), |
| 319 | + Address: net.JoinHostPort(routerHost, config.RouterConfig().GrpcApiPort), |
317 | 320 | State: qdb.OPENED,
|
318 | 321 | }
|
319 | 322 | if err := qc.RegisterRouter(ctx, router); err != nil {
|
320 | 323 | spqrlog.Zero.Error().Err(err).Msg("register router when locking coordinator")
|
321 | 324 | }
|
322 | 325 |
|
323 |
| - host := config.CoordinatorConfig().Host |
324 |
| - if host == "" { |
325 |
| - var err error |
326 |
| - host, err = os.Hostname() |
327 |
| - if err != nil { |
328 |
| - return false |
329 |
| - } |
| 326 | + host, err := config.GetHostOrHostname(config.CoordinatorConfig().Host) |
| 327 | + if err != nil { |
| 328 | + return false |
330 | 329 | }
|
331 | 330 | coordAddr := net.JoinHostPort(host, config.CoordinatorConfig().GrpcApiPort)
|
332 | 331 | if err := qc.UpdateCoordinator(ctx, coordAddr); err != nil {
|
@@ -1634,9 +1633,13 @@ func (qc *qdbCoordinator) SyncRouterMetadata(ctx context.Context, qRouter *topol
|
1634 | 1633 | }
|
1635 | 1634 | spqrlog.Zero.Debug().Msg("successfully add all key ranges")
|
1636 | 1635 |
|
| 1636 | + host, err := config.GetHostOrHostname(config.CoordinatorConfig().Host) |
| 1637 | + if err != nil { |
| 1638 | + return err |
| 1639 | + } |
1637 | 1640 | rCl := routerproto.NewTopologyServiceClient(cc)
|
1638 | 1641 | if _, err := rCl.UpdateCoordinator(ctx, &routerproto.UpdateCoordinatorRequest{
|
1639 |
| - Address: net.JoinHostPort(config.CoordinatorConfig().Host, config.CoordinatorConfig().GrpcApiPort), |
| 1642 | + Address: net.JoinHostPort(host, config.CoordinatorConfig().GrpcApiPort), |
1640 | 1643 | }); err != nil {
|
1641 | 1644 | return err
|
1642 | 1645 | }
|
@@ -1667,9 +1670,13 @@ func (qc *qdbCoordinator) SyncRouterCoordinatorAddress(ctx context.Context, qRou
|
1667 | 1670 | /* Update current coordinator address. */
|
1668 | 1671 | /* Todo: check that router metadata is in sync. */
|
1669 | 1672 |
|
| 1673 | + host, err := config.GetHostOrHostname(config.CoordinatorConfig().Host) |
| 1674 | + if err != nil { |
| 1675 | + return err |
| 1676 | + } |
1670 | 1677 | rCl := routerproto.NewTopologyServiceClient(cc)
|
1671 | 1678 | if _, err := rCl.UpdateCoordinator(ctx, &routerproto.UpdateCoordinatorRequest{
|
1672 |
| - Address: net.JoinHostPort(config.CoordinatorConfig().Host, config.CoordinatorConfig().GrpcApiPort), |
| 1679 | + Address: net.JoinHostPort(host, config.CoordinatorConfig().GrpcApiPort), |
1673 | 1680 | }); err != nil {
|
1674 | 1681 | return err
|
1675 | 1682 | }
|
|
0 commit comments