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

nsqadmin: work-around bug for raw ipv6 addresses #1179

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions nsqadmin/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ func (s *httpServer) nodesHandler(w http.ResponseWriter, req *http.Request, ps h
messages = append(messages, pe.Error())
}

for _, producer := range producers {
// Assume it is an ipv6 address if a colon is in it
if strings.Contains(producer.BroadcastAddress, ":") {
producer.BroadcastAddress = fmt.Sprintf("[%s]", producer.BroadcastAddress)
}
}

return struct {
Nodes clusterinfo.Producers `json:"nodes"`
Message string `json:"message"`
Expand All @@ -354,6 +361,13 @@ func (s *httpServer) nodeHandler(w http.ResponseWriter, req *http.Request, ps ht
messages = append(messages, pe.Error())
}

for _, producer := range producers {
// Assume it is an ipv6 address if a colon is in it
if strings.Contains(producer.BroadcastAddress, ":") {
producer.BroadcastAddress = fmt.Sprintf("[%s]", producer.BroadcastAddress)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should not apply the work-around here, this makes producers.Search(node) just below not find anything, and result in the 404 "NODE_NOT_FOUND"

}
}

producer := producers.Search(node)
if producer == nil {
return nil, http_api.Err{404, "NODE_NOT_FOUND"}
Expand Down Expand Up @@ -641,6 +655,14 @@ func (s *httpServer) counterHandler(w http.ResponseWriter, req *http.Request, ps
s.ctx.nsqadmin.logf(LOG_WARN, "%s", err)
messages = append(messages, pe.Error())
}

for _, producer := range producers {
// Assume it is an ipv6 address if a colon is in it
if strings.Contains(producer.BroadcastAddress, ":") {
producer.BroadcastAddress = fmt.Sprintf("[%s]", producer.BroadcastAddress)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this place is also inappropriate because this is going to be used for GetNSQDStats(), not for web UI links

}
}

_, channelStats, err := s.ci.GetNSQDStats(producers, "", "", false)
if err != nil {
pe, ok := err.(clusterinfo.PartialErr)
Expand Down
1 change: 1 addition & 0 deletions nsqlookupd/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (s *httpServer) doLookup(w http.ResponseWriter, req *http.Request, ps httpr
producers := s.ctx.nsqlookupd.DB.FindProducers("topic", topicName, "")
producers = producers.FilterByActive(s.ctx.nsqlookupd.opts.InactiveProducerTimeout,
s.ctx.nsqlookupd.opts.TombstoneLifetime)

return map[string]interface{}{
"channels": channels,
"producers": producers.PeerInfo(),
Expand Down