Skip to content

Commit

Permalink
fix: golangci lint
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <[email protected]>
  • Loading branch information
zbb88888 committed Jan 24, 2024
1 parent e4e3e17 commit 276034a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 6 additions & 5 deletions pkg/controller/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,16 +496,17 @@ func (c *Controller) createOrUpdateCrdIPs(ipCRName, podName, ip, mac, subnetName
return nil
}

_, err := c.config.KubeOvnClient.KubeovnV1().IPs().Update(context.Background(), newIPCR, metav1.UpdateOptions{})
ipCR, err = c.config.KubeOvnClient.KubeovnV1().IPs().Update(context.Background(), newIPCR, metav1.UpdateOptions{})
if err != nil {
err := fmt.Errorf("failed to update ip CR %s: %v", newIPCR.Name, err)
klog.Error(err)
return err
}
if err := c.handleAddIPFinalizer(ipCR, util.ControllerName); err != nil {
klog.Errorf("failed to handle add ip finalizer %v", err)
return err
}
}

if err := c.handleAddIPFinalizer(ipCR, util.ControllerName); err != nil {
klog.Errorf("failed to handle add ip finalizer %v", err)
return err
}

return nil
Expand Down
9 changes: 7 additions & 2 deletions pkg/webhook/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"net"
"net/http"

ovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1"
"github.com/kubeovn/kube-ovn/pkg/util"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
ctrlwebhook "sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

ovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1"
"github.com/kubeovn/kube-ovn/pkg/util"
)

var ipGVK = metav1.GroupVersionKind{Group: ovnv1.SchemeGroupVersion.Group, Version: ovnv1.SchemeGroupVersion.Version, Kind: "IP"}
Expand Down Expand Up @@ -39,6 +40,10 @@ func (v *ValidatingHook) IPUpdateHook(ctx context.Context, req admission.Request
return ctrlwebhook.Errored(http.StatusBadRequest, err)
}

if err := v.ValidateIP(ctx, &ipNew); err != nil {
return ctrlwebhook.Errored(http.StatusBadRequest, err)
}

// ip can not change these specs below
if ipNew.Spec.Namespace != ipOld.Spec.Namespace {
err := fmt.Errorf("ip %s namespace can not change", ipNew.Name)
Expand Down

0 comments on commit 276034a

Please sign in to comment.