Skip to content

Commit

Permalink
treewide: Use formatted logrus logs when possible
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Chaignon <paul@cilium.io>
  • Loading branch information
pchaigno committed Oct 14, 2021
1 parent 2eb7a22 commit e03a0b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions pkg/bpf/bpffs_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import (

"encoding/binary"

"github.com/cilium/cilium/pkg/logging/logfields"
"github.com/cilium/ebpf"

"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)

Expand Down Expand Up @@ -139,7 +142,8 @@ func repinMap(bpffsPath string, name string, spec *ebpf.MapSpec) error {

dest := file + bpffsPending

log.Infof("New version of map '%s' has different properties, re-pinning from '%s' to '%s'", name, file, dest)
log.WithFields(logrus.Fields{logfields.BPFMapName: name, logfields.BPFMapPath: file}).
Infof("New version of map has different properties, re-pinning with '%s' suffix", bpffsPending)

// Atomically re-pin the map to the its new path.
if err := pinned.Pin(dest); err != nil {
Expand Down Expand Up @@ -170,7 +174,8 @@ func finalizeMap(bpffsPath, name string, revert bool) error {
// Pending Map was found on bpffs and needs to be reverted.
if revert {
dest := filepath.Join(bpffsPath, name)
log.Infof("Reverting map pin from '%s' to '%s' after failed migration", file, dest)
log.WithFields(logrus.Fields{logfields.BPFMapPath: dest, logfields.BPFMapName: name}).
Infof("Repinning without '%s' suffix after failed migration", bpffsPending)

// Atomically re-pin the map to its original path.
if err := pending.Pin(dest); err != nil {
Expand All @@ -180,7 +185,8 @@ func finalizeMap(bpffsPath, name string, revert bool) error {
return nil
}

log.Infof("Unpinning map '%s' after successful recreation", file)
log.WithFields(logrus.Fields{logfields.BPFMapPath: file, logfields.BPFMapName: name}).
Info("Unpinning map after successful recreation")

// Pending Map found on bpffs and its replacement was successfully loaded.
// Unpin the old map since it no longer needs to be interacted with from userspace.
Expand Down
4 changes: 3 additions & 1 deletion pkg/datapath/loader/netlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import (
"github.com/cilium/cilium/pkg/bpf"
"github.com/cilium/cilium/pkg/command/exec"
"github.com/cilium/cilium/pkg/defaults"
"github.com/cilium/cilium/pkg/logging/logfields"
"github.com/cilium/cilium/pkg/mac"
"github.com/cilium/cilium/pkg/option"
"github.com/cilium/cilium/pkg/sysctl"

"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
)

Expand Down Expand Up @@ -115,7 +117,7 @@ func graftDatapath(ctx context.Context, mapPath, objPath, progSec string) error
var revert bool
defer func() {
if err := bpf.FinalizeBPFFSMigration(bpf.GetMapRoot(), objPath, revert); err != nil {
log.WithError(err).WithField("mapPath", mapPath).WithField("objPath", objPath).
log.WithError(err).WithFields(logrus.Fields{logfields.BPFMapPath: mapPath, "objPath": objPath}).
Error("Could not finalize bpffs map migration")
}
}()
Expand Down

0 comments on commit e03a0b9

Please sign in to comment.