From 5dcca8ca6c5b70ca0453044aeacb0fb16dbd80ce Mon Sep 17 00:00:00 2001 From: Ritu Sood Date: Sun, 29 Sep 2019 06:22:17 -0700 Subject: Add a check for network creation If network already exists consider that as not an error Change-Id: I279338e6e4d6f6ad0d7417bcabbd3f2027ff808e Signed-off-by: Ritu Sood --- pkg/controller/network/network_controller.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'pkg/controller/network/network_controller.go') diff --git a/pkg/controller/network/network_controller.go b/pkg/controller/network/network_controller.go index 2392e3d..abdcb14 100644 --- a/pkg/controller/network/network_controller.go +++ b/pkg/controller/network/network_controller.go @@ -4,13 +4,12 @@ import ( "context" "fmt" k8sv1alpha1 "ovn4nfv-k8s-plugin/pkg/apis/k8s/v1alpha1" - - // corev1 "k8s.io/api/core/v1" "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "ovn4nfv-k8s-plugin/internal/pkg/ovn" "ovn4nfv-k8s-plugin/pkg/utils" + "reflect" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -111,7 +110,7 @@ func (r *ReconcileNetwork) createNetwork(cr *k8sv1alpha1.Network, reqLogger logr return err } err = ovnCtl.CreateNetwork(cr) - if err != nil { + if err != nil && !reflect.DeepEqual(err, fmt.Errorf("LS exists")) { // Log the error reqLogger.Error(err, "Error Creating Network") cr.Status.State = k8sv1alpha1.CreateInternalError -- cgit 1.2.3-korg