From fc7c7d4979fc4ef1e3253a045a7b7b2a5c307b8e Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Mon, 30 Sep 2024 17:16:57 +0900 Subject: [PATCH] gh-813 Fixed unnecessary error logs --- api/loxinlp/nlp.go | 28 +++++++++++++--------------- pkg/loxinet/gobgpclient.go | 4 ++-- pkg/loxinet/port.go | 2 +- pkg/loxinet/utils_aws.go | 4 ++-- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/api/loxinlp/nlp.go b/api/loxinlp/nlp.go index bcc15c16e..331fc2e57 100644 --- a/api/loxinlp/nlp.go +++ b/api/loxinlp/nlp.go @@ -907,8 +907,9 @@ func ModLink(link nlp.Link, add bool) int { Link: linkState, State: state, Mtu: mtu, Master: master, Real: real, TunID: tunId, TunDst: tunDst, TunSrc: tunSrc}) if err != nil { - tk.LogIt(tk.LogError, "[NLP] Port %v, %v, %v, %v add failed\n", name, ifMac, state, mtu) - fmt.Println(err) + if !strings.Contains(err.Error(), "port exists") { + tk.LogIt(tk.LogError, "[NLP] Port %v, %v, %v, %v add failed\n", name, ifMac, state, mtu) + } } else { tk.LogIt(tk.LogInfo, "[NLP] Port %v, %v, %v, %v add [OK]\n", name, ifMac, state, mtu) } @@ -917,7 +918,6 @@ func ModLink(link nlp.Link, add bool) int { ret, err = hooks.NetPortDel(&cmn.PortMod{Dev: name, Ptype: pType}) if err != nil { tk.LogIt(tk.LogError, "[NLP] Port %v, %v, %v, %v delete failed\n", name, ifMac, state, mtu) - fmt.Println(err) } else { tk.LogIt(tk.LogInfo, "[NLP] Port %v, %v, %v, %v delete [OK]\n", name, ifMac, state, mtu) } @@ -1627,50 +1627,48 @@ func LbSessionGet(done bool) int { if _, err := os.Stat(opt.Opts.ConfigPath + "/EPconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] No EndPoint config file : %s \n", err.Error()) + tk.LogIt(tk.LogInfo, "[NLP] Continuing without EP config file: %s\n", err.Error()) } } else { applyEPConfig() } - tk.LogIt(tk.LogInfo, "[NLP] EndPoint done\n") + tk.LogIt(tk.LogInfo, "[NLP] EndPoint config process done\n") if _, err := os.Stat(opt.Opts.ConfigPath + "/lbconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] No load balancer config file : %s \n", err.Error()) + tk.LogIt(tk.LogInfo, "[NLP] Continuing without LB config file : %s \n", err.Error()) } } else { applyLoadBalancerConfig() } + tk.LogIt(tk.LogInfo, "[NLP] LoadBalancer config done\n") - tk.LogIt(tk.LogInfo, "[NLP] LoadBalancer done\n") if _, err := os.Stat(opt.Opts.ConfigPath + "/sessionconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] No Session config file : %s \n", err.Error()) + tk.LogIt(tk.LogInfo, "[NLP] Continuing without Session config file : %s \n", err.Error()) } } else { applySessionConfig() } + tk.LogIt(tk.LogInfo, "[NLP] Session config done\n") - tk.LogIt(tk.LogInfo, "[NLP] Session done\n") if _, err := os.Stat(opt.Opts.ConfigPath + "/sessionulclconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] No UlCl config file : %s \n", err.Error()) + tk.LogIt(tk.LogInfo, "[NLP] Continuing without UlCl config file : %s \n", err.Error()) } } else { applyUlClConfig() } + tk.LogIt(tk.LogInfo, "[NLP] Session UlCl config done\n") - tk.LogIt(tk.LogInfo, "[NLP] Session UlCl done\n") if _, err := os.Stat(opt.Opts.ConfigPath + "/FWconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] No Firewall config file : %s \n", err.Error()) + tk.LogIt(tk.LogInfo, "[NLP] Continuing without Firewall config file : %s \n", err.Error()) } } else { applyFWConfig() } - tk.LogIt(tk.LogInfo, "[NLP] Firewall done\n") - - tk.LogIt(tk.LogInfo, "[NLP] LbSessionGet done\n") + tk.LogIt(tk.LogInfo, "[NLP] Firewall config done\n") } return 0 diff --git a/pkg/loxinet/gobgpclient.go b/pkg/loxinet/gobgpclient.go index ca75d40ad..dd65f5a17 100644 --- a/pkg/loxinet/gobgpclient.go +++ b/pkg/loxinet/gobgpclient.go @@ -205,12 +205,12 @@ func (gbh *GoBgpH) processRouteSingle(p *goBgpRouteInfo, showIdentifier bgp.BGPA tk.LogIt(tk.LogInfo, format, pathStr...) - if err := gbh.syncRoute(p, showIdentifier); err != nil { + if err := gbh.syncRoute(p); err != nil { tk.LogIt(tk.LogError, " failed to "+format, pathStr...) } } -func (gbh *GoBgpH) syncRoute(p *goBgpRouteInfo, showIdentifier bgp.BGPAddPathMode) error { +func (gbh *GoBgpH) syncRoute(p *goBgpRouteInfo) error { if gbh.noNlp { return nil } diff --git a/pkg/loxinet/port.go b/pkg/loxinet/port.go index 1c37d61be..a6e6a3e4e 100644 --- a/pkg/loxinet/port.go +++ b/pkg/loxinet/port.go @@ -293,7 +293,7 @@ func (P *PortsH) PortAdd(name string, osid int, ptype int, zone string, return 0, nil } } - tk.LogIt(tk.LogError, "port add - %s exists\n", name) + tk.LogIt(tk.LogTrace, "port add - %s exists\n", name) return PortExistsErr, errors.New("port exists") } diff --git a/pkg/loxinet/utils_aws.go b/pkg/loxinet/utils_aws.go index c0d489901..572ae46e0 100644 --- a/pkg/loxinet/utils_aws.go +++ b/pkg/loxinet/utils_aws.go @@ -696,7 +696,7 @@ func awsAssociateElasticIp(vIP, eIP net.IP, add bool) error { tk.LogIt(tk.LogInfo, "AWS adding elastic IP : %s\n", eIP.String()) if !add { - return awsDisassociateElasticIpWithInterface(ctx, eipAssociateID, niID) + return awsDisassociateElasticIpWithInterface(ctx, eipAssociateID) } return awsAssociateElasticIpWithInterface(ctx, eipID, niID, vIP) } @@ -723,7 +723,7 @@ func awsAssociateElasticIpWithInterface(ctx context.Context, eipID, niID string, return err } -func awsDisassociateElasticIpWithInterface(ctx context.Context, eipAssociateID, niID string) error { +func awsDisassociateElasticIpWithInterface(ctx context.Context, eipAssociateID string) error { _, err := ec2Client.DisassociateAddress(ctx, &ec2.DisassociateAddressInput{ AssociationId: &eipAssociateID, })