commit
280c2511f7
|
@ -64,7 +64,7 @@ var nodeAddCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := node.Add(cc, n, false); err != nil {
|
if err := node.Add(cc, n, false); err != nil {
|
||||||
_, err := maybeDeleteAndRetry(*cc, n, nil, err)
|
_, err := maybeDeleteAndRetry(cmd, *cc, n, nil, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("failed to add node", err)
|
exit.WithError("failed to add node", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ var nodeStartCmd = &cobra.Command{
|
||||||
|
|
||||||
_, err = node.Start(s, false)
|
_, err = node.Start(s, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, err := maybeDeleteAndRetry(*cc, *n, nil, err)
|
_, err := maybeDeleteAndRetry(cmd, *cc, *n, nil, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
node.MaybeExitWithAdvice(err)
|
node.MaybeExitWithAdvice(err)
|
||||||
exit.WithError("failed to start node", err)
|
exit.WithError("failed to start node", err)
|
||||||
|
|
|
@ -200,7 +200,7 @@ func runStart(cmd *cobra.Command, args []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kubeconfig, err := startWithDriver(starter, existing)
|
kubeconfig, err := startWithDriver(cmd, starter, existing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
node.MaybeExitWithAdvice(err)
|
node.MaybeExitWithAdvice(err)
|
||||||
exit.WithError("failed to start node", err)
|
exit.WithError("failed to start node", err)
|
||||||
|
@ -279,10 +279,10 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func startWithDriver(starter node.Starter, existing *config.ClusterConfig) (*kubeconfig.Settings, error) {
|
func startWithDriver(cmd *cobra.Command, starter node.Starter, existing *config.ClusterConfig) (*kubeconfig.Settings, error) {
|
||||||
kubeconfig, err := node.Start(starter, true)
|
kubeconfig, err := node.Start(starter, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
kubeconfig, err = maybeDeleteAndRetry(*starter.Cfg, *starter.Node, starter.ExistingAddons, err)
|
kubeconfig, err = maybeDeleteAndRetry(cmd, *starter.Cfg, *starter.Node, starter.ExistingAddons, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -411,20 +411,22 @@ func showKubectlInfo(kcs *kubeconfig.Settings, k8sVersion string, machineName st
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func maybeDeleteAndRetry(cc config.ClusterConfig, n config.Node, existingAddons map[string]bool, originalErr error) (*kubeconfig.Settings, error) {
|
func maybeDeleteAndRetry(cmd *cobra.Command, existing config.ClusterConfig, n config.Node, existingAddons map[string]bool, originalErr error) (*kubeconfig.Settings, error) {
|
||||||
if viper.GetBool(deleteOnFailure) {
|
if viper.GetBool(deleteOnFailure) {
|
||||||
out.WarningT("Node {{.name}} failed to start, deleting and trying again.", out.V{"name": n.Name})
|
out.WarningT("Node {{.name}} failed to start, deleting and trying again.", out.V{"name": n.Name})
|
||||||
// Start failed, delete the cluster and try again
|
// Start failed, delete the cluster and try again
|
||||||
profile, err := config.LoadProfile(cc.Name)
|
profile, err := config.LoadProfile(existing.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
out.ErrT(out.Meh, `"{{.name}}" profile does not exist, trying anyways.`, out.V{"name": cc.Name})
|
out.ErrT(out.Meh, `"{{.name}}" profile does not exist, trying anyways.`, out.V{"name": existing.Name})
|
||||||
}
|
}
|
||||||
|
|
||||||
err = deleteProfile(profile)
|
err = deleteProfile(profile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
out.WarningT("Failed to delete cluster {{.name}}, proceeding with retry anyway.", out.V{"name": cc.Name})
|
out.WarningT("Failed to delete cluster {{.name}}, proceeding with retry anyway.", out.V{"name": existing.Name})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-generate the cluster config, just in case the failure was related to an old config format
|
||||||
|
cc := updateExistingConfigFromFlags(cmd, &existing)
|
||||||
var kubeconfig *kubeconfig.Settings
|
var kubeconfig *kubeconfig.Settings
|
||||||
for _, n := range cc.Nodes {
|
for _, n := range cc.Nodes {
|
||||||
r, p, m, h, err := node.Provision(&cc, &n, n.ControlPlane, false)
|
r, p, m, h, err := node.Provision(&cc, &n, n.ControlPlane, false)
|
||||||
|
|
|
@ -217,7 +217,7 @@ func ClusterFlagValue() string {
|
||||||
// generateClusterConfig generate a config.ClusterConfig based on flags or existing cluster config
|
// generateClusterConfig generate a config.ClusterConfig based on flags or existing cluster config
|
||||||
func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k8sVersion string, drvName string) (config.ClusterConfig, config.Node, error) {
|
func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k8sVersion string, drvName string) (config.ClusterConfig, config.Node, error) {
|
||||||
var cc config.ClusterConfig
|
var cc config.ClusterConfig
|
||||||
if existing != nil { // create profile config first time
|
if existing != nil {
|
||||||
cc = updateExistingConfigFromFlags(cmd, existing)
|
cc = updateExistingConfigFromFlags(cmd, existing)
|
||||||
} else {
|
} else {
|
||||||
glog.Info("no existing cluster config was found, will generate one from the flags ")
|
glog.Info("no existing cluster config was found, will generate one from the flags ")
|
||||||
|
|
Loading…
Reference in New Issue