Skip to content

Commit

Permalink
fix(cluster): don't assume that --host is set
Browse files Browse the repository at this point in the history
E.g. clusters created before SM 3.2.6 can have empty --host SM DB column.
  • Loading branch information
Michal-Leszczynski authored and karol-kokoszka committed Sep 11, 2024
1 parent aa77cb7 commit ed87d32
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/service/cluster/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,19 @@ func (s *Service) discoverAndSetClusterHosts(ctx context.Context, c *Cluster) er

func (s *Service) discoverClusterHosts(ctx context.Context, c *Cluster) ([]string, error) {
var contactPoints []string
contactPoints = append(contactPoints, c.Host) // Go with the designated contact point first
if c.Host != "" {
contactPoints = append(contactPoints, c.Host) // Go with the designated contact point first
} else {
s.logger.Error(ctx, "Missing --host flag. Using only previously discovered hosts instead", "cluster ID", c.ID)
}
contactPoints = append(contactPoints, c.KnownHosts...) // In case it failed, try to contact previously discovered hosts

for _, cp := range contactPoints {
if cp == "" {
s.logger.Error(ctx, "Empty contact point", "cluster ID", c.ID, "contact points", contactPoints)
continue
}

config := scyllaclient.DefaultConfigWithTimeout(s.timeoutConfig)
if c.Port != 0 {
config.Port = fmt.Sprint(c.Port)
Expand Down

0 comments on commit ed87d32

Please sign in to comment.