kvrocks-controller icon indicating copy to clipboard operation
kvrocks-controller copied to clipboard

Command cannot find interface

Open GO-Zheng opened this issue 10 months ago • 3 comments

Description

After modifying the configuration file to ip, the command cannot find the interface.

Steps to Reproduce

After seeing the warning below, I changed 127.0.0.1 to the local ip.

{"level":"warn","timestamp":"2025-02-18T16:00:12.099+0800","caller":"config/config.go:94","msg":"Leader forward may not work if the host is 127.0.0.1"}
  • config/config.yaml
# addr: "127.0.0.1:9379"
addr: "192.168.1.45:9379"
-> # make setup
[+] Running 4/4
 ✔ Network kvrocks-controller_default  Created     0.7s
 ✔ Container etcd0                     Started                2.0s
 ✔ Container kvrocks0                  Started                2.0s
 ✔ Container kvrocks1                  Started                1.7s
(base) root@OpsWorker [16:26:20] [~/code/github/kvrocks-controller] [unstable *]
-> # ./_build/kvctl-server -c config/config.yaml
{"level":"info","timestamp":"2025-02-18T16:27:05.272+0800","caller":"server/main.go:78","msg":"Kvrocks controller is running with version: unstable"}
{"level":"info","timestamp":"2025-02-18T16:27:05.286+0800","caller":"server/server.go:63","msg":"Use Etcd as store"}
{"level":"info","timestamp":"2025-02-18T16:27:05.501+0800","caller":"controller/controller.go:121","msg":"Became the leader, resume the controller"}
(base) root@OpsWorker [16:27:15] [~/code/github/kvrocks-controller] [unstable *]
-> # netstat -an | grep 9379
tcp        0      0 192.168.1.45:9379      0.0.0.0:*               LISTEN
(base) root@OpsWorker [16:27:15] [~/code/github/kvrocks-controller] [unstable *]
-> # ./_build/kvctl create namespace my-ns
error: Post "http://127.0.0.1:9379/api/v1/namespaces": dial tcp 127.0.0.1:9379: connect: connection refused

Environment

# system
WSL2 - Ubuntu 24.04.1 LTS

# controller
The latest "unstable" branch

# docker images
REPOSITORY            TAG       IMAGE ID       CREATED        SIZE
apache/kvrocks        2.11.0    9140d7b357fc   3 weeks ago    156MB
quay.io/coreos/etcd   v3.5.17   0b844ea0bc6b   3 months ago   59MB

Supplement

I tried other commands, but none of them worked. However, the default configuration of "127.0.0.1" worked fine.

GO-Zheng avatar Feb 18 '25 09:02 GO-Zheng

@GO-Zheng Could have a try at the following command:

./_build/kvctl -H "http://192.168.1.45:9379" create namespace my-ns

because you're listening on the address 192.168.1.45.

git-hulk avatar Feb 18 '25 12:02 git-hulk

@GO-Zheng Could have a try at the following command:

./_build/kvctl -H "http://192.168.1.45:9379" create namespace my-ns because you're listening on the address 192.168.1.45.

Sorry, I didn't notice this option.

Flags:
  -h, --help          help for kvctl
  -H, --host string   The host of the Kvrocks controller service (default "http://127.0.0.1:9379")

I tried it, and it does work, but the command line can only find it when the ip is "127.0.0.1". I changed the port to "9738" and used "-H" and it worked.

# addr: "127.0.0.1:9378"
-> # ./_build/kvctl -H "http://127.0.0.1:9378" create namespace my-ns
create namespace: my-ns successfully.

But when I used "192.168.1.198:9379", the command failed.

# addr: "192.168.1.198:9379"
-> # ./_build/kvctl -H "http://192.168.1.198:9379" create namespace my-ns
error: unexpected end of JSON input

However, if I access the port directly, it is available.

# addr: "192.168.1.198:9379"
-> # curl http://192.168.1.198:9379/api/v1/namespaces
{"data":{"namespaces":["my-ns"]}}

GO-Zheng avatar Feb 19 '25 07:02 GO-Zheng

@GO-Zheng

But when I used "192.168.1.198:9379", the command failed. However, if I access the port directly, it is available.

I'm not quite sure how this can happen. Perhaps you could use the command sudo tcpdump -i any port 9379 to inspect what's different from the network side.

git-hulk avatar Feb 20 '25 12:02 git-hulk