mirror of https://github.com/kubernetes/kops.git
Handle NotFound error when checking if the instance group exists
This commit is contained in:
parent
f749aa5b0c
commit
95c4b6b728
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/kops/cmd/kops/util"
|
"k8s.io/kops/cmd/kops/util"
|
||||||
api "k8s.io/kops/pkg/apis/kops"
|
api "k8s.io/kops/pkg/apis/kops"
|
||||||
|
|
@ -133,8 +134,11 @@ func RunCreateInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string,
|
||||||
|
|
||||||
existing, err := clientset.InstanceGroupsFor(cluster).Get(groupName, metav1.GetOptions{})
|
existing, err := clientset.InstanceGroupsFor(cluster).Get(groupName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// We expect a NotFound error when creating the instance group
|
||||||
|
if !errors.IsNotFound(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if existing != nil {
|
if existing != nil {
|
||||||
return fmt.Errorf("instance group %q already exists", groupName)
|
return fmt.Errorf("instance group %q already exists", groupName)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue