Added a warning message that cluster api already initialized
* Currently if the cluster init command is run & the cluster-api has already been initialized, the command fails. * So,this commit adds a warning message that cluster-api already initialized. Signed-off-by: bijayasharma <vetbijaya@gmail.com> Change-Id: I93cc6b141c15fa4bc5661646ae0cbdf08580cbf9 Relates-To: #450 Closes: #450
This commit is contained in:
parent
77268cd1d0
commit
62272ed900
@ -16,6 +16,7 @@ package executors
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
@ -147,18 +148,27 @@ func (c *ClusterctlExecutor) init(opts ifc.RunOptions, evtCh chan events.Event)
|
||||
return
|
||||
}
|
||||
|
||||
eventMsg := "clusterctl init completed successfully"
|
||||
|
||||
// Use cluster name as context in kubeconfig file
|
||||
err = c.Init(kubeConfigFile, context)
|
||||
if err != nil {
|
||||
if err != nil && isAlreadyExistsError(err) {
|
||||
// log the already existed/initialized error as warning and continue
|
||||
eventMsg = fmt.Sprintf("WARNING: clusterctl is already initialized, received an error : %s", err.Error())
|
||||
} else if err != nil {
|
||||
handleError(evtCh, err)
|
||||
return
|
||||
}
|
||||
evtCh <- events.NewEvent().WithClusterctlEvent(events.ClusterctlEvent{
|
||||
Operation: events.ClusterctlInitEnd,
|
||||
Message: "clusterctl init completed successfully",
|
||||
Message: eventMsg,
|
||||
})
|
||||
}
|
||||
|
||||
func isAlreadyExistsError(err error) bool {
|
||||
return strings.Contains(err.Error(), "there is already an instance")
|
||||
}
|
||||
|
||||
// Validate executor configuration and documents
|
||||
func (c *ClusterctlExecutor) Validate() error {
|
||||
return errors.ErrNotImplemented{}
|
||||
|
Loading…
Reference in New Issue
Block a user