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

Warn about route asymmetry per cluster rather than per sc #871

Merged
merged 1 commit into from
Sep 21, 2023
Merged
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
29 changes: 20 additions & 9 deletions cli/server_list_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ type SrvLsCmd struct {
}

type srvListCluster struct {
name string
nodes []string
gwOut int
gwIn int
conns int
name string
nodes []string
gwOut int
gwIn int
conns int
routeSizes []int
}

func configureServerListCommand(srv *fisk.CmdClause) {
Expand Down Expand Up @@ -105,12 +106,14 @@ func (c *SrvLsCmd) list(_ *fisk.ParseContext) error {
if cluster != "" {
_, ok := clusters[cluster]
if !ok {
clusters[cluster] = &srvListCluster{cluster, []string{}, 0, 0, 0}
clusters[cluster] = &srvListCluster{name: cluster}
}

clusters[cluster].conns += ssm.Stats.Connections
clusters[cluster].nodes = append(clusters[cluster].nodes, ssm.Server.Name)
clusters[cluster].gwOut += len(ssm.Stats.Gateways)
clusters[cluster].routeSizes = append(clusters[cluster].routeSizes, len(ssm.Stats.Routes))

for _, g := range ssm.Stats.Gateways {
clusters[cluster].gwIn += g.NumInbound
}
Expand Down Expand Up @@ -210,6 +213,16 @@ func (c *SrvLsCmd) list(_ *fisk.ParseContext) error {
gwaysOk := ""
routesOk := ""

// handle asymmetric clusters by ensuring each cluster has same route count
// rather than all nodes in all clusters having the same route count
for _, v := range clusters {
for _, s := range v.routeSizes {
if s != v.routeSizes[0] {
routesOk = "X"
}
}
}

for i, ssm := range results {
cluster := ssm.Server.Cluster
jsEnabled := "no"
Expand All @@ -224,9 +237,7 @@ func (c *SrvLsCmd) list(_ *fisk.ParseContext) error {
if ssm.Server.Version != results[0].ServerStatsMsg.Server.Version {
versionsOk = "X"
}
if len(ssm.Stats.Routes) != len(results[0].ServerStatsMsg.Stats.Routes) {
routesOk = "X"
}

if len(ssm.Stats.Gateways) != len(results[0].ServerStatsMsg.Stats.Gateways) {
gwaysOk = "X"
}
Expand Down
Loading