From 18a06515a896cbe81c846a5478f58bfd6d28328e Mon Sep 17 00:00:00 2001 From: releng Date: Fri, 8 Nov 2024 13:15:31 -0500 Subject: [PATCH] Sync from server repo (49a48c41aa8) --- vclusterops/start_subcluster.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vclusterops/start_subcluster.go b/vclusterops/start_subcluster.go index 89509d8..2cba327 100644 --- a/vclusterops/start_subcluster.go +++ b/vclusterops/start_subcluster.go @@ -130,6 +130,10 @@ func (vcc VClusterCommands) VStartSubcluster(options *VStartScOptions) (VCoordin if err != nil { return vdb, err } + err = options.validateNewHosts(&vdb, options.NewHostList) + if err != nil { + return vdb, err + } nodesToStart := options.collectDownHosts(&vdb) if len(nodesToStart) == 0 { @@ -203,6 +207,15 @@ func (options *VStartScOptions) collectDownHosts(vdb *VCoordinationDatabase) (no return nodesToStart } +func (options *VStartScOptions) validateNewHosts(vdb *VCoordinationDatabase, newHosts []string) error { + for _, h := range newHosts { + if _, exists := vdb.HostNodeMap[h]; exists { + return fmt.Errorf("host %s is already a part of the database, please provide a new host ip to start the subcluster", h) + } + } + return nil +} + // Unbound nodes that need to be started need to be re-ip'd and require node directories to be set up func (options *VStartScOptions) checkPrepDirs(vdb *VCoordinationDatabase, nodesToStart map[string]string, logger vlog.Printer) error {