Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #40 from jodh-intel/logging-fixes
Browse files Browse the repository at this point in the history
logging: Use structured logging and simplest log calls
  • Loading branch information
Sebastien Boeuf authored Dec 5, 2017
2 parents e370d13 + 1351def commit d8bd396
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func init() {
runtime.LockOSThread()
factory, _ := libcontainer.New("")
if err := factory.StartInitialization(); err != nil {
agentLog.Errorf("init went wrong: %v", err)
agentLog.WithError(err).Error("init failed")
}
panic("--this line should have never been executed, congratulations--")
}
Expand Down
10 changes: 7 additions & 3 deletions grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/opencontainers/runc/libcontainer"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/utils"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -303,7 +304,7 @@ func (a *agentGRPC) CreateContainer(ctx context.Context, req *pb.CreateContainer
// re-scan PCI bus
// looking for hidden devices
if err := ioutil.WriteFile(pciBusRescanFile, []byte("1"), pciBusMode); err != nil {
agentLog.WithError(err).Warnf("Could not rescan PCI bus")
agentLog.WithError(err).Warn("Could not rescan PCI bus")
}

mountList, err := addMounts(req.Storages)
Expand Down Expand Up @@ -465,8 +466,11 @@ func (a *agentGRPC) SignalProcess(ctx context.Context, req *pb.SignalProcessRequ
signal := syscall.Signal(req.Signal)

if status == libcontainer.Stopped {
agentLog.Info("Container %s is Stopped on sandbox %s, discard signal %s", req.ContainerId, a.sandbox.id, signal.String())
return emptyResp, nil
agentLog.WithFields(logrus.Fields{
"containerID": req.ContainerId,
"sandbox": a.sandbox.id,
"signal": signal.String(),
}).Info("discarding signal as container stopped")
}

// If the process is the container process, let's use the container
Expand Down
2 changes: 1 addition & 1 deletion network.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (s *sandbox) updateInterface(netHandle *netlink.Handle, iface *pb.Interface
return fmt.Errorf("Interface HwAddr and Name are both empty")
}

fieldLogger.WithField("link", fmt.Sprintf("%+v", link)).Infof("Link found")
fieldLogger.WithField("link", fmt.Sprintf("%+v", link)).Info("Link found")

lAttrs := link.Attrs()
if lAttrs != nil && (lAttrs.Flags&net.FlagUp) == net.FlagUp {
Expand Down

0 comments on commit d8bd396

Please sign in to comment.