Skip to content

Commit

Permalink
gh-813 Fixed unnecessary error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Sep 30, 2024
1 parent 913deae commit fc7c7d4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
28 changes: 13 additions & 15 deletions api/loxinlp/nlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/loxinet/gobgpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/loxinet/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/loxinet/utils_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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,
})
Expand Down

0 comments on commit fc7c7d4

Please sign in to comment.