Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid calling v4 api #52

Open
zmstone opened this issue Aug 29, 2023 · 0 comments
Open

avoid calling v4 api #52

zmstone opened this issue Aug 29, 2023 · 0 comments

Comments

@zmstone
Copy link
Member

zmstone commented Aug 29, 2023

this version probing will generate some suspicious logs in emqx v5.

func (c *cluster) checkNodes() {
httpClient := getHTTPClient(*emqxNodes)
var currentVersion string
for {
var client client
var err4, err5 error
client = &cluster4x{client: httpClient}
_, err4 = client.getClusterStatus()
if err4 != nil {
client = &cluster5x{client: httpClient}
_, err5 = client.getClusterStatus()
}
if err4 != nil && err5 != nil {
_ = level.Warn(c.logger).Log("check nodes", "couldn't get node info", "addr", *emqxNodes,
"err4", err4.Error(), "err5", err5.Error())
client = nil
} else if currentVersion != client.getVersion() {
currentVersion = client.getVersion()
_ = level.Info(c.logger).Log("ClusterVersion", currentVersion)
}
c.nodeLock.Lock()
c.client = client
c.nodeLock.Unlock()
select {
case <-context.Background().Done():
return
case <-time.After(5 * time.Second):
}
}
}

an alternative is to try to call the /status endpoint with ?format=json, in v4 it will return text (ignore the json arg).
in v5 it returns a json like below

curl -s 'http://127.0.0.1:18083/status?format=json'
{"rel_vsn":"e5.1.1","node_name":"[email protected]","broker_status":"started","app_status":"running"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant