Skip to content

Commit

Permalink
Warn about route asymmetry per cluster rather than per sc
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <[email protected]>
  • Loading branch information
ripienaar committed Sep 21, 2023
1 parent 3994d92 commit d15e8b0
Showing 1 changed file with 20 additions and 9 deletions.
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

0 comments on commit d15e8b0

Please sign in to comment.