Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kops Replace Force #4275

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions cmd/kops/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,25 @@ func RunReplace(f *util.Factory, cmd *cobra.Command, out io.Writer, c *replaceOp
cluster, err := clientset.GetCluster(clusterName)
if err != nil {
if errors.IsNotFound(err) {
cluster = nil
return fmt.Errorf("cluster %q not found", clusterName)
} else {
return fmt.Errorf("error fetching cluster %q: %v", clusterName, err)
}
}
if cluster == nil {
return fmt.Errorf("cluster %q not found", clusterName)
}
// check if the instancegroup exists already
igName := v.ObjectMeta.Name
ig, err := clientset.InstanceGroupsFor(cluster).Get(igName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("unable to check for instanceGroup: %v", err)
if errors.IsNotFound(err) {
if !c.force {
return fmt.Errorf("instanceGroup: %v does not exist (try adding --force flag)", igName)
}
} else {
return fmt.Errorf("unable to check for instanceGroup: %v", err)
}
}
switch ig {
case nil:
if !c.force {
return fmt.Errorf("instanceGroup: %v does not exist (try adding --force flag)", igName)
}
glog.Infof("instanceGroup: %v was not found, creating resource now", igName)
_, err = clientset.InstanceGroupsFor(cluster).Create(v)
if err != nil {
Expand Down