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

Fixed log messages in infra manager packages #66

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
46 changes: 20 additions & 26 deletions inframanager/api_handler/api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,15 @@ func InsertDefaultRule() {

IP, netIp, err := net.ParseCIDR(types.DefaultRoute)
if err != nil {
log.Errorf("Failed to get IP from the default route cidr, %s",
types.DefaultRoute)
log.Errorf("Failed to get IP from the default route cidr %s", types.DefaultRoute)
return
}

_ = netIp

ip := IP.String()
if len(ip) == 0 {
log.Errorf("Empty value: %s, cannot program default gateway",
types.DefaultRoute)
log.Errorf("Empty value %s, cannot program default gateway", types.DefaultRoute)
return
}

Expand Down Expand Up @@ -319,30 +317,26 @@ func insertRule(log *log.Entry, ctx context.Context, p4RtC *client.Client, macAd
epEntry.InterfaceID == ep.InterfaceID &&
epEntry.PodMacAddress == ep.PodMacAddress {

logger.Infof("Entry %s %s %d already exists",
macAddr, ipAddr, portID)
logger.Debugf("Entry %s %s %d already exists", macAddr, ipAddr, portID)
return true, nil
} else {
err = fmt.Errorf("A different entry for %s already exists in the store", ipAddr)
err = fmt.Errorf("A different entry for %s, already exists in the store", ipAddr)
return false, err
}
}

logger.Infof("Inserting entry into the cni tables")
if err = p4.InsertCniRules(ctx, p4RtC, macAddr, ipAddr, portID, ifaceType); err != nil {
logger.Errorf("Failed to insert the entries for %s %s", macAddr, ipAddr)
logger.Errorf("Failed to insert the entries for cni add %s %s", macAddr, ipAddr)
return false, err
}
logger.Infof("Inserted the entries %s %s %d into the pipeline",
macAddr, ipAddr, portID)
logger.Debugf("Inserted the entries %s %s %d into the pipeline", macAddr, ipAddr, portID)

if ep.WriteToStore() != true {
err = fmt.Errorf("Failed to add %s %s %d to the store",
macAddr, ipAddr, portID)
err = fmt.Errorf("Failed to add %s %s %d entry to the store", macAddr, ipAddr, portID)
return false, err
}
logger.Infof("Inserted the entries %s %s %d into the store",
macAddr, ipAddr, portID)
logger.Debugf("Inserted the entries %s %s %d into the store", macAddr, ipAddr, portID)

return true, err
}
Expand Down Expand Up @@ -410,14 +404,14 @@ func (s *ApiServer) DeleteNetwork(ctx context.Context, in *proto.DeleteNetworkRe
out.Successful = false
return out, err
}
logger.Infof("Deleted the entries %s %s from the pipeline", macAddr, ipAddr)
logger.Debugf("Deleted the entries %s %s from the pipeline", macAddr, ipAddr)

if ep.DeleteFromStore() != true {
out.Successful = false
err = fmt.Errorf("Failed to delete %s %s from the store", macAddr, ipAddr)
return out, err
}
logger.Infof("Deleted the entries %s %s from the store", macAddr, ipAddr)
logger.Debugf("Deleted the entries %s %s from the store", macAddr, ipAddr)

return out, err
}
Expand Down Expand Up @@ -485,7 +479,7 @@ func (s *ApiServer) NatTranslationAdd(ctx context.Context, in *proto.NatTranslat
*/
if entry != nil {
logger.Infof("Incoming NatTranslationUpdate %+v", in)
logger.Infof("Service ip %v and proto %v port %v , num of endpoints %v",
logger.Debugf("Service ip %v and proto %v port %v , num of endpoints %v",
in.Endpoint.Ipv4Addr, in.Proto, in.Endpoint.Port, len(in.Backends))

service = entry.(store.Service)
Expand All @@ -509,7 +503,7 @@ func (s *ApiServer) NatTranslationAdd(ctx context.Context, in *proto.NatTranslat
New service. Add it to store
*/
logger.Infof("Incoming NatTranslationAdd %+v", in)
logger.Infof("Service ip %v proto %v port %v, num of endpoints %v",
logger.Debugf("Service ip %v proto %v port %v, num of endpoints %v",
in.Endpoint.Ipv4Addr, in.Proto, in.Endpoint.Port, len(in.Backends))

service.MacAddr = serviceMacAddr
Expand All @@ -533,24 +527,24 @@ func (s *ApiServer) NatTranslationAdd(ctx context.Context, in *proto.NatTranslat
}

if newEps == 0 {
logger.Info("No new endpoints in the service. No rules inserted")
logger.Infof("No new endpoints in the service. No rules inserted")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix this. This is causing the build failure.

return out, err
}

if err, service = p4.InsertServiceRules(ctx, server.p4RtC, podIpAddrs,
podPortIDs, service, update); err != nil {
logger.Errorf("Failed to insert the service entry %s:%s:%d, backends: %v into the pipeline",
logger.Errorf("Failed to insert the service entry %s:%s:%d, backends: %v, into the pipeline",
serviceIpAddr, in.Proto, in.Endpoint.Port, podIpAddrs)
out.Successful = false
return out, err
}
logger.Infof("Inserted the service entry %s:%s:%d, backends: %v into the pipeline",
logger.Debugf("Inserted the service entry %s:%s:%d, backends: %v into the pipeline",
serviceIpAddr, in.Proto, in.Endpoint.Port, podIpAddrs)

if update {
/* Update only the endpoint details to the store */
if !service.UpdateToStore() {
logger.Errorf("Failed to update service entry %s:%s:%d, backends: %v into the store. Reverting from the pipeline",
logger.Errorf("Failed to update service entry %s:%s:%d, backends: %v, into the store. Reverting from the pipeline",
serviceIpAddr, in.Proto, in.Endpoint.Port, podIpAddrs)

p4.DeleteServiceRules(ctx, server.p4RtC, service)
Expand All @@ -560,7 +554,7 @@ func (s *ApiServer) NatTranslationAdd(ctx context.Context, in *proto.NatTranslat
out.Successful = false
return out, err
}
logger.Infof("Updated the service entry %s:%s:%d, backends: %v in the store",
logger.Debugf("Updated the service entry %s:%s:%d, backends: %v in the store",
serviceIpAddr, in.Proto, in.Endpoint.Port, podIpAddrs)
} else {
if !service.WriteToStore() {
Expand All @@ -574,7 +568,7 @@ func (s *ApiServer) NatTranslationAdd(ctx context.Context, in *proto.NatTranslat
out.Successful = false
return out, err
}
logger.Infof("Inserted the service entry %s:%s:%d, backends: %v into the store",
logger.Debugf("Inserted the service entry %s:%s:%d, backends: %v into the store",
serviceIpAddr, in.Proto, in.Endpoint.Port, podIpAddrs)
}

Expand Down Expand Up @@ -800,7 +794,7 @@ func (s *ApiServer) SetupHostInterface(ctx context.Context, in *proto.SetupHostI
return out, err
}

logger.Infof("Interface: %s, port id: %d", in.IfName, portID)
logger.Debugf("Interface: %s, port id: %d", in.IfName, portID)

if status, err := insertRule(s.log, ctx, server.p4RtC, macAddr,
ipAddr, int(portID), p4.HOST); err != nil {
Expand All @@ -821,7 +815,7 @@ func (s *ApiServer) SetupHostInterface(ctx context.Context, in *proto.SetupHostI
status, err := insertRule(s.log, ctx, server.p4RtC, hostInterfaceMac,
config.NodeIP, int(portID), p4.HOST)
if err != nil {
logger.Errorf("Failed to insert rule to the pipeline ip: %s mac: %s port id: %d err: %v",
logger.Errorf("Failed to insert rule to the pipeline p: %s mac: %s port id: %d err: %v",
config.NodeIP, macAddr, portID, err)
}
out.Successful = status
Expand Down
12 changes: 4 additions & 8 deletions pkg/inframanager/p4/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func ArptToPortTable(ctx context.Context, p4RtC *client.Client, arpTpa string, p
var err error

if net.ParseIP(arpTpa) == nil {
err = fmt.Errorf("Invalid IP Address")
err = fmt.Errorf("Invalid IP Address %s", arpTpa)
return err
}

Expand All @@ -44,12 +44,10 @@ func ArptToPortTable(ctx context.Context, p4RtC *client.Client, arpTpa string, p
nil,
)
if err = p4RtC.InsertTableEntry(ctx, entryAdd); err != nil {
log.Errorf("Cannot insert entry into arpt_to_port_table table, ip: %s, port: %d, err: %v",
log.Errorf("Cannot insert entry into arpt_to_port_table table, ip:%s, port: %d, err: %v",
arpTpa, port, err)
return err
}
log.Debugf("Successfully inserted entry into arpt_to_port_table, ip: %s, port: %d",
arpTpa, port)
} else {
entryDelete := p4RtC.NewTableEntry(
"k8s_dp_control.arpt_to_port_table",
Expand All @@ -62,12 +60,10 @@ func ArptToPortTable(ctx context.Context, p4RtC *client.Client, arpTpa string, p
nil,
)
if err = p4RtC.DeleteTableEntry(ctx, entryDelete); err != nil {
log.Errorf("Cannot delete entry from arpt_to_port_table table, ip: %s, port: %d, err: %v",
log.Errorf("Cannot delete entry from arpt_to_port_table table, ip:%s, port: %d, err: %v",
arpTpa, port, err)
return err
}
log.Debugf("Successfully deleted entry from arpt_to_port_table, ip: %s, port: %d",
arpTpa, port)
}

return nil
Expand All @@ -77,7 +73,7 @@ func Ipv4ToPortTable(ctx context.Context, p4RtC *client.Client, ipAddr string, m
var err error

if net.ParseIP(ipAddr) == nil {
err = fmt.Errorf("Invalid IP Address")
err = fmt.Errorf("Invalid IP Address %s", ipAddr)
return err
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/inframanager/p4/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func InsertServiceRules(ctx context.Context, p4RtC *client.Client,

memberID = append(memberID, id)
modblobPtrDNAT = append(modblobPtrDNAT, id)
log.Infof("modblobPtrDNAT: %d memberid: %d, pod ip: %s, portID: %d",
log.Debugf("modblobPtrDNAT: %d memberid: %d, pod ip: %s, portID: %d",
modblobPtrDNAT[i], memberID[i], podIpAddr[i], portID[i])

serviceEp := store.ServiceEndPoint{
Expand All @@ -535,7 +535,7 @@ func InsertServiceRules(ctx context.Context, p4RtC *client.Client,
}
service.NumEndPoints = epNum

log.Infof("group id: %d, service ip: %s, service mac: %s, service port: %d",
log.Debugf("group id: %d, service ip: %s, service mac: %s, service port: %d",
groupID, service.ClusterIp, service.MacAddr, service.Port)

if err = WriteDestIpTable(ctx, p4RtC, podIpAddr, portID,
Expand Down Expand Up @@ -639,7 +639,7 @@ func DeleteServiceRules(ctx context.Context, p4RtC *client.Client,
podPortIDs = append(podPortIDs, uint16(ep.Port))
memberID = append(memberID, ep.MemberID)
modblobPtrDNAT = append(modblobPtrDNAT, ep.ModBlobPtrDNAT)
log.Infof("modblobPtrDNAT: %d memberid: %d, pod ip: %s, portID: %d",
log.Debugf("modblobPtrDNAT: %d memberid: %d, pod ip: %s, portID: %d",
ep.ModBlobPtrDNAT, ep.MemberID, ep.IpAddress, ep.Port)
}

Expand Down