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

Log near err #3739

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions pkg/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (c *Controller) handleUpdateEndpoint(key string) error {
if errors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}

Expand All @@ -106,6 +107,7 @@ func (c *Controller) handleUpdateEndpoint(key string) error {
if errors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}
svc := cachedService.DeepCopy()
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/external-gw.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func (c *Controller) establishExternalGateway(config map[string]string) error {
lrpName := fmt.Sprintf("%s-%s", c.config.ClusterRouter, c.config.ExternalGatewaySwitch)
exist, err := c.ovnClient.LogicalRouterPortExists(lrpName)
if err != nil {
klog.Error(err)
return err
}
if exist {
Expand Down
14 changes: 14 additions & 0 deletions pkg/controller/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (c *Controller) gc() error {
}
for _, gcFunc := range gcFunctions {
if err := gcFunc(); err != nil {
klog.Error(err)
return err
}
}
Expand Down Expand Up @@ -270,6 +271,7 @@ func (c *Controller) gcVip() error {
}
return nil
}
klog.Error(err)
return err
}
}
Expand Down Expand Up @@ -394,6 +396,7 @@ func (c *Controller) gcLoadBalancer() error {
// remove lb from logical switch
vpcs, err := c.vpcsLister.List(labels.Everything())
if err != nil {
klog.Error(err)
return err
}
for _, cachedVpc := range vpcs {
Expand All @@ -404,6 +407,7 @@ func (c *Controller) gcLoadBalancer() error {
if k8serrors.IsNotFound(err) {
continue
}
klog.Error(err)
return err
}
if !isOvnSubnet(subnet) {
Expand All @@ -419,6 +423,7 @@ func (c *Controller) gcLoadBalancer() error {
vpc.Status.SctpLoadBalancer,
vpc.Status.SctpSessionLoadBalancer)
if err != nil {
klog.Error(err)
return err
}
}
Expand All @@ -431,10 +436,12 @@ func (c *Controller) gcLoadBalancer() error {
vpc.Status.SctpSessionLoadBalancer = ""
bytes, err := vpc.Status.Bytes()
if err != nil {
klog.Error(err)
return err
}
_, err = c.config.KubeOvnClient.KubeovnV1().Vpcs().Patch(context.Background(), vpc.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status")
if err != nil {
klog.Error(err)
return err
}
}
Expand Down Expand Up @@ -528,21 +535,27 @@ func (c *Controller) gcLoadBalancer() error {
}

if err = removeVIP(tcpLb, tcpVips); err != nil {
klog.Error(err)
return err
}
if err = removeVIP(tcpSessLb, tcpSessionVips); err != nil {
klog.Error(err)
return err
}
if err = removeVIP(udpLb, udpVips); err != nil {
klog.Error(err)
return err
}
if err = removeVIP(udpSessLb, udpSessionVips); err != nil {
klog.Error(err)
return err
}
if err = removeVIP(sctpLb, sctpVips); err != nil {
klog.Error(err)
return err
}
if err = removeVIP(sctpSessLb, sctpSessionVips); err != nil {
klog.Error(err)
return err
}
}
Expand All @@ -561,6 +574,7 @@ func (c *Controller) gcLoadBalancer() error {
}
klog.Infof("start to destroy load balancer %s", lb)
if err := c.ovnLegacyClient.DeleteLoadBalancer(lb); err != nil {
klog.Error(err)
return err
}
}
Expand Down
21 changes: 19 additions & 2 deletions pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (c *Controller) InitDefaultVpc() error {

bytes, err := vpc.Status.Bytes()
if err != nil {
klog.Error(err)
return err
}
_, err = c.config.KubeOvnClient.KubeovnV1().Vpcs().Patch(context.Background(), vpc.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status")
Expand Down Expand Up @@ -137,8 +138,10 @@ func (c *Controller) initDefaultLogicalSwitch() error {
defaultSubnet.Spec.U2OInterconnection = c.config.DefaultU2OInterconnection
}

_, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Create(context.Background(), &defaultSubnet, metav1.CreateOptions{})
return err
if _, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Create(context.Background(), &defaultSubnet, metav1.CreateOptions{}); err != nil {
klog.Error(err)
}
return nil
}

// InitNodeSwitch init node switch to connect host and pod
Expand Down Expand Up @@ -191,6 +194,7 @@ func (c *Controller) initNodeSwitch() error {
func (c *Controller) initClusterRouter() error {
lrs, err := c.ovnLegacyClient.ListLogicalRouter(c.config.EnableExternalVpc)
if err != nil {
klog.Error(err)
return err
}
klog.Infof("exists routers: %v", lrs)
Expand Down Expand Up @@ -237,21 +241,27 @@ func (c *Controller) initLoadBalancer() error {
vpc := cachedVpc.DeepCopy()
vpcLb := c.GenVpcLoadBalancer(vpc.Name)
if err = c.initLB(vpcLb.TcpLoadBalancer, string(v1.ProtocolTCP), false); err != nil {
klog.Error(err)
return err
}
if err = c.initLB(vpcLb.TcpSessLoadBalancer, string(v1.ProtocolTCP), true); err != nil {
klog.Error(err)
return err
}
if err = c.initLB(vpcLb.UdpLoadBalancer, string(v1.ProtocolUDP), false); err != nil {
klog.Error(err)
return err
}
if err = c.initLB(vpcLb.UdpSessLoadBalancer, string(v1.ProtocolUDP), true); err != nil {
klog.Error(err)
return err
}
if err = c.initLB(vpcLb.SctpLoadBalancer, string(v1.ProtocolSCTP), false); err != nil {
klog.Error(err)
return err
}
if err = c.initLB(vpcLb.SctpSessLoadBalancer, string(v1.ProtocolSCTP), true); err != nil {
klog.Error(err)
return err
}

Expand All @@ -263,10 +273,12 @@ func (c *Controller) initLoadBalancer() error {
vpc.Status.SctpSessionLoadBalancer = vpcLb.SctpSessLoadBalancer
bytes, err := vpc.Status.Bytes()
if err != nil {
klog.Error(err)
return err
}
_, err = c.config.KubeOvnClient.KubeovnV1().Vpcs().Patch(context.Background(), vpc.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status")
if err != nil {
klog.Error(err)
return err
}
}
Expand Down Expand Up @@ -525,6 +537,7 @@ func (c *Controller) initDefaultVlan() error {
}

if err := c.initDefaultProviderNetwork(); err != nil {
klog.Error(err)
return err
}

Expand Down Expand Up @@ -565,6 +578,7 @@ func (c *Controller) initSyncCrdIPs() error {
if k8serrors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}

Expand Down Expand Up @@ -610,6 +624,7 @@ func (c *Controller) initSyncCrdSubnets() error {
if k8serrors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}
for _, orisubnet := range subnets {
Expand Down Expand Up @@ -663,6 +678,7 @@ func (c *Controller) initSyncCrdVlans() error {
if k8serrors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}

Expand Down Expand Up @@ -695,6 +711,7 @@ func (c *Controller) migrateNodeRoute(af int, node, ip, nexthop string) error {
match := fmt.Sprintf("ip%d.dst == %s", af, ip)
consistent, err := c.ovnLegacyClient.CheckPolicyRouteNexthopConsistent(c.config.ClusterRouter, match, nexthop, util.NodeRouterPolicyPriority)
if err != nil {
klog.Error(err)
return err
}
if consistent {
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/inspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (c *Controller) inspectPod() error {
delete(pod.Annotations, fmt.Sprintf(util.RoutedAnnotationTemplate, podNet.ProviderName))
patch, err := util.GenerateStrategicMergePatchPayload(oriPod, pod)
if err != nil {
klog.Error(err)
return err
}
if _, err := c.config.KubeClient.CoreV1().Pods(pod.Namespace).Patch(context.Background(), pod.Name,
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func (c *Controller) handleAddIP(key string) error {
if k8serrors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}
klog.V(3).Infof("handle add ip %s", cachedIP.Name)
Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (c *Controller) handleAddNamespace(key string) error {
if errors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}
namespace := cachedNs.DeepCopy()
Expand Down Expand Up @@ -184,11 +185,13 @@ func (c *Controller) handleAddNamespace(key string) error {

patch, err := util.GenerateStrategicMergePatchPayload(cachedNs, namespace)
if err != nil {
klog.Error(err)
return err
}
if _, err = c.config.KubeClient.CoreV1().Namespaces().Patch(context.Background(), key,
types.StrategicMergePatchType, patch, metav1.PatchOptions{}, ""); err != nil {
klog.Errorf("patch namespace %s failed %v", key, err)
return err
}
return err
return nil
}
1 change: 1 addition & 0 deletions pkg/controller/network_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (c *Controller) handleUpdateNp(key string) error {
if k8serrors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}

Expand Down
34 changes: 22 additions & 12 deletions pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (c *Controller) handleAddNode(key string) error {
if k8serrors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}
node := cachedNode.DeepCopy()
Expand Down Expand Up @@ -254,6 +255,7 @@ func (c *Controller) handleAddNode(key string) error {

ipStr := util.GetStringIP(v4IP, v6IP)
if err := c.ovnLegacyClient.CreatePort(c.config.NodeSwitch, portName, ipStr, mac, "", "", false, "", "", false, false, nil, false); err != nil {
klog.Error(err)
return err
}

Expand Down Expand Up @@ -348,10 +350,12 @@ func (c *Controller) handleAddNode(key string) error {
}

if err := c.validateChassis(node); err != nil {
klog.Error(err)
return err
}

if err := c.retryDelDupChassis(util.ChasRetryTime, util.ChasRetryIntev+2, c.checkChassisDupl, node); err != nil {
klog.Error(err)
return err
}

Expand Down Expand Up @@ -457,6 +461,7 @@ func (c *Controller) handleDeleteNode(key string) error {
}

if err := c.config.KubeOvnClient.KubeovnV1().IPs().Delete(context.Background(), portName, metav1.DeleteOptions{}); err != nil && !k8serrors.IsNotFound(err) {
klog.Error(err)
return err
}

Expand Down Expand Up @@ -500,6 +505,7 @@ func (c *Controller) handleDeleteNode(key string) error {

for _, pn := range providerNetworks {
if err = c.updateProviderNetworkForNodeDeletion(pn, key); err != nil {
klog.Error(err)
return err
}
}
Expand Down Expand Up @@ -567,6 +573,7 @@ func (c *Controller) handleUpdateNode(key string) error {
if k8serrors.IsNotFound(err) {
return nil
}
klog.Error(err)
return err
}

Expand All @@ -582,16 +589,19 @@ func (c *Controller) handleUpdateNode(key string) error {
}

if err := c.validateChassis(node); err != nil {
klog.Error(err)
return err
}
if err := c.retryDelDupChassis(util.ChasRetryTime, util.ChasRetryIntev+2, c.checkChassisDupl, node); err != nil {
klog.Error(err)
return err
}

for _, cachedSubnet := range subnets {
subnet := cachedSubnet.DeepCopy()
if util.GatewayContains(subnet.Spec.GatewayNode, node.Name) {
if err := c.reconcileOvnRoute(subnet); err != nil {
klog.Error(err)
return err
}
}
Expand All @@ -618,9 +628,9 @@ func (c *Controller) createOrUpdateCrdIPs(podName, ip, mac, subnetName, ns, node
ipCr, err = c.config.KubeOvnClient.KubeovnV1().IPs().Get(context.Background(), ipName, metav1.GetOptions{})
if err != nil {
if !k8serrors.IsNotFound(err) {
errMsg := fmt.Errorf("failed to get ip CR %s: %v", ipName, err)
klog.Error(errMsg)
return errMsg
err := fmt.Errorf("failed to get ip CR %s: %v", ipName, err)
klog.Error(err)
return err
}
// the returned pointer is not nil if the CR does not exist
ipCr = nil
Expand Down Expand Up @@ -652,9 +662,9 @@ func (c *Controller) createOrUpdateCrdIPs(podName, ip, mac, subnetName, ns, node
},
}, metav1.CreateOptions{})
if err != nil {
errMsg := fmt.Errorf("failed to create ip CR %s: %v", ipName, err)
klog.Error(errMsg)
return errMsg
err := fmt.Errorf("failed to create ip CR %s: %v", ipName, err)
klog.Error(err)
return err
}
} else {
newIpCr := ipCr.DeepCopy()
Expand Down Expand Up @@ -683,9 +693,9 @@ func (c *Controller) createOrUpdateCrdIPs(podName, ip, mac, subnetName, ns, node

_, err := c.config.KubeOvnClient.KubeovnV1().IPs().Update(context.Background(), newIpCr, metav1.UpdateOptions{})
if err != nil {
errMsg := fmt.Errorf("failed to update ip CR %s: %v", newIpCr.Name, err)
klog.Error(errMsg)
return errMsg
err := fmt.Errorf("failed to update ip CR %s: %v", newIpCr.Name, err)
klog.Error(err)
return err
}
}

Expand Down Expand Up @@ -866,9 +876,9 @@ func (c *Controller) retryDelDupChassis(attempts int, sleep int, f func(node *v1
time.Sleep(time.Duration(sleep) * time.Second)
}
if i >= (attempts - 1) {
errMsg := fmt.Errorf("exhausting all attempts")
klog.Error(errMsg)
return errMsg
err := fmt.Errorf("exhausting all attempts")
klog.Error(err)
return err
}
klog.V(3).Infof("finish check chassis")
return nil
Expand Down
Loading
Loading