mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
app/{vmselect, vminsert}: fails with error when user defines equal addresses in the -storageNodes flag (#3082)
This commit is contained in:
parent
21d608b210
commit
ec273eafef
@ -83,6 +83,9 @@ func main() {
|
||||
if len(*storageNodes) == 0 {
|
||||
logger.Fatalf("missing -storageNode arg")
|
||||
}
|
||||
if duplicatedAddr := checkDuplicates(*storageNodes); duplicatedAddr != "" {
|
||||
logger.Fatalf("found equal addresses of storage nodes in the -storageNodes flag: %q", duplicatedAddr)
|
||||
}
|
||||
hashSeed := uint64(0)
|
||||
if *clusternativeListenAddr != "" {
|
||||
// Use different hash seed for the second level of vminsert nodes in multi-level cluster setup.
|
||||
@ -355,3 +358,14 @@ See the docs at https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html .
|
||||
`
|
||||
flagutil.Usage(s)
|
||||
}
|
||||
|
||||
func checkDuplicates(arr []string) string {
|
||||
visited := make(map[string]struct{})
|
||||
for _, s := range arr {
|
||||
if _, ok := visited[s]; ok {
|
||||
return s
|
||||
}
|
||||
visited[s] = struct{}{}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -85,6 +85,10 @@ func main() {
|
||||
if len(*storageNodes) == 0 {
|
||||
logger.Fatalf("missing -storageNode arg")
|
||||
}
|
||||
if duplicatedAddr := checkDuplicates(*storageNodes); duplicatedAddr != "" {
|
||||
logger.Fatalf("found equal addresses of storage nodes in the -storageNodes flag: %q", duplicatedAddr)
|
||||
}
|
||||
|
||||
netstorage.InitStorageNodes(*storageNodes)
|
||||
logger.Infof("started netstorage in %.3f seconds", time.Since(startTime).Seconds())
|
||||
|
||||
@ -771,3 +775,14 @@ func initVMAlertProxy() {
|
||||
vmalertProxyHost = proxyURL.Host
|
||||
vmalertProxy = httputil.NewSingleHostReverseProxy(proxyURL)
|
||||
}
|
||||
|
||||
func checkDuplicates(arr []string) string {
|
||||
visited := make(map[string]struct{})
|
||||
for _, s := range arr {
|
||||
if _, ok := visited[s]; ok {
|
||||
return s
|
||||
}
|
||||
visited[s] = struct{}{}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user