[lxc-devel] [lxd/master] 2016 09 16/logging issue 1928
brauner on Github
lxc-bot at linuxcontainers.org
Fri Sep 16 09:51:29 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 333 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160916/1603a651/attachment.bin>
-------------- next part --------------
From 2f5a1d04c8d30ce6d667b00de4f373c9d41cd93c Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 09:51:07 +0200
Subject: [PATCH 01/16] lxd/container_lxc: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/container_lxc.go | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 63c86c2..99e7d40 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -1233,7 +1233,7 @@ func (c *containerLXC) startCommon() (string, error) {
/* it's ok to fail, the device might be hot plugged later */
_, err := c.createUnixDevice(temp)
if err != nil {
- shared.Log.Debug("failed to create usb device", log.Ctx{"err": err, "device": k})
+ shared.LogDebug("failed to create usb device", log.Ctx{"err": err, "device": k})
continue
}
@@ -1504,7 +1504,7 @@ func (c *containerLXC) OnStart() error {
c.fromHook = false
err := c.setNetworkPriority()
if err != nil {
- shared.Log.Error("Failed to apply network priority", log.Ctx{"container": c.name, "err": err})
+ shared.LogError("Failed to apply network priority", log.Ctx{"container": c.name, "err": err})
}
}(c)
}
@@ -1524,7 +1524,7 @@ func (c *containerLXC) OnStart() error {
c.fromHook = false
err = c.setNetworkLimits(name, m)
if err != nil {
- shared.Log.Error("Failed to apply network limits", log.Ctx{"container": c.name, "err": err})
+ shared.LogError("Failed to apply network limits", log.Ctx{"container": c.name, "err": err})
}
}(c, name, m)
}
@@ -1666,13 +1666,13 @@ func (c *containerLXC) OnStop(target string) error {
// Clean all the unix devices
err = c.removeUnixDevices()
if err != nil {
- shared.Log.Error("Unable to remove unix devices", log.Ctx{"err": err})
+ shared.LogError("Unable to remove unix devices", log.Ctx{"err": err})
}
// Clean all the disk devices
err = c.removeDiskDevices()
if err != nil {
- shared.Log.Error("Unable to remove disk devices", log.Ctx{"err": err})
+ shared.LogError("Unable to remove disk devices", log.Ctx{"err": err})
}
// Reboot the container
@@ -1879,7 +1879,7 @@ func (c *containerLXC) Restore(sourceContainer container) error {
if c.IsRunning() {
wasRunning = true
if err := c.Stop(false); err != nil {
- shared.Log.Error(
+ shared.LogError(
"Could not stop container",
log.Ctx{
"container": c.Name(),
@@ -1891,7 +1891,7 @@ func (c *containerLXC) Restore(sourceContainer container) error {
// Restore the rootfs
err = c.storage.ContainerRestore(c, sourceContainer)
if err != nil {
- shared.Log.Error("Restoring the filesystem failed",
+ shared.LogError("Restoring the filesystem failed",
log.Ctx{
"source": sourceContainer.Name(),
"destination": c.Name()})
@@ -1909,7 +1909,7 @@ func (c *containerLXC) Restore(sourceContainer container) error {
err = c.Update(args, false)
if err != nil {
- shared.Log.Error("Restoring the configuration failed",
+ shared.LogError("Restoring the configuration failed",
log.Ctx{
"source": sourceContainer.Name(),
"destination": c.Name()})
@@ -1928,7 +1928,7 @@ func (c *containerLXC) Restore(sourceContainer container) error {
// this in snapshots.
err2 := os.RemoveAll(c.StatePath())
if err2 != nil {
- shared.Log.Error("failed to delete snapshot state", "path", c.StatePath(), "err", err2)
+ shared.LogError("failed to delete snapshot state", log.Ctx{"path": c.StatePath(), "err": err2})
}
if err != nil {
@@ -1966,12 +1966,12 @@ func (c *containerLXC) Delete() error {
if c.IsSnapshot() {
// Remove the snapshot
if err := c.storage.ContainerSnapshotDelete(c); err != nil {
- shared.Log.Warn("failed to delete snapshot", "name", c.Name(), "err", err)
+ shared.LogWarn("failed to delete snapshot", log.Ctx{"name": c.Name(), "err": err})
}
} else {
// Remove all snapshot
if err := containerDeleteSnapshots(c.daemon, c.Name()); err != nil {
- shared.Log.Warn("failed to delete snapshots", "name", c.Name(), "err", err)
+ shared.LogWarn("failed to delete snapshots", log.Ctx{"name": c.Name(), "err": err})
}
// Clean things up
@@ -2617,7 +2617,7 @@ func (c *containerLXC) Update(args containerArgs, userRequested bool) error {
err = c.insertUSBDevice(m, usb)
if err != nil {
- shared.Log.Error("failed to insert usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
+ shared.LogError("failed to insert usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
}
}
}
@@ -2905,7 +2905,7 @@ func (c *containerLXC) Migrate(cmd uint, stateDir string, function string, stop
prettyCmd = "restore"
default:
prettyCmd = "unknown"
- shared.Log.Warn("unknown migrate call", log.Ctx{"cmd": cmd})
+ shared.LogWarn("unknown migrate call", log.Ctx{"cmd": cmd})
}
preservesInodes := c.storage.PreservesInodes()
@@ -3003,7 +3003,7 @@ func (c *containerLXC) Migrate(cmd uint, stateDir string, function string, stop
collectErr := collectCRIULogFile(c, stateDir, function, prettyCmd)
if collectErr != nil {
- shared.Log.Error("Error collecting checkpoint log file", log.Ctx{"err": collectErr})
+ shared.LogError("Error collecting checkpoint log file", log.Ctx{"err": collectErr})
}
if migrateErr != nil {
@@ -3505,7 +3505,7 @@ func (c *containerLXC) networkState() map[string]shared.ContainerStateNetwork {
// Process forkgetnet response
if err != nil {
- shared.Log.Error("Error calling 'lxd forkgetnet", log.Ctx{"container": c.name, "output": string(out), "pid": pid})
+ shared.LogError("Error calling 'lxd forkgetnet", log.Ctx{"container": c.name, "output": string(out), "pid": pid})
return result
}
@@ -3513,7 +3513,7 @@ func (c *containerLXC) networkState() map[string]shared.ContainerStateNetwork {
err = json.Unmarshal(out, &networks)
if err != nil {
- shared.Log.Error("Failure to read forkgetnet json", log.Ctx{"container": c.name, "err": err})
+ shared.LogError("Failure to read forkgetnet json", log.Ctx{"container": c.name, "err": err})
return result
}
@@ -4000,7 +4000,7 @@ func (c *containerLXC) removeUSBDevice(m shared.Device, usb usbDevice) error {
err := c.removeUnixDevice(temp)
if err != nil {
- shared.Log.Error("failed to remove usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
+ shared.LogError("failed to remove usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
return err
}
@@ -4036,7 +4036,7 @@ func (c *containerLXC) removeUnixDevices() error {
devicePath := filepath.Join(c.DevicesPath(), f.Name())
err := os.Remove(devicePath)
if err != nil {
- shared.Log.Error("failed removing unix device", log.Ctx{"err": err, "path": devicePath})
+ shared.LogError("failed removing unix device", log.Ctx{"err": err, "path": devicePath})
}
}
@@ -4496,7 +4496,7 @@ func (c *containerLXC) removeDiskDevices() error {
diskPath := filepath.Join(c.DevicesPath(), f.Name())
err := os.Remove(diskPath)
if err != nil {
- shared.Log.Error("Failed to remove disk device path", log.Ctx{"err": err, "path": diskPath})
+ shared.LogError("Failed to remove disk device path", log.Ctx{"err": err, "path": diskPath})
}
}
From 5777cab970aa5dc08ef25a15763ac8ccaa66f915 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 09:52:38 +0200
Subject: [PATCH 02/16] lxd/container_put: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/container_put.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lxd/container_put.go b/lxd/container_put.go
index 1b19cea..b6aca32 100644
--- a/lxd/container_put.go
+++ b/lxd/container_put.go
@@ -94,7 +94,7 @@ func containerSnapRestore(d *Daemon, name string, snap string) error {
snap = name + shared.SnapshotDelimiter + snap
}
- shared.Log.Info(
+ shared.LogInfo(
"RESTORE => Restoring snapshot",
log.Ctx{
"snapshot": snap,
@@ -102,7 +102,7 @@ func containerSnapRestore(d *Daemon, name string, snap string) error {
c, err := containerLoadByName(d, name)
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"RESTORE => loadcontainerLXD() failed",
log.Ctx{
"container": name,
From 4bd0828484eb20edcd26adb4ea1cdb951af4fa0d Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 10:43:41 +0200
Subject: [PATCH 03/16] lxd/containers: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/containers.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lxd/containers.go b/lxd/containers.go
index 15c6526..39c3e02 100644
--- a/lxd/containers.go
+++ b/lxd/containers.go
@@ -177,7 +177,7 @@ func containersShutdown(d *Daemon) error {
}
func containerDeleteSnapshots(d *Daemon, cname string) error {
- shared.Log.Debug("containerDeleteSnapshots",
+ shared.LogDebug("containerDeleteSnapshots",
log.Ctx{"container": cname})
results, err := dbContainerGetSnapshots(d.db, cname)
@@ -188,7 +188,7 @@ func containerDeleteSnapshots(d *Daemon, cname string) error {
for _, sname := range results {
sc, err := containerLoadByName(d, sname)
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"containerDeleteSnapshots: Failed to load the snapshotcontainer",
log.Ctx{"container": cname, "snapshot": sname})
@@ -196,7 +196,7 @@ func containerDeleteSnapshots(d *Daemon, cname string) error {
}
if err := sc.Delete(); err != nil {
- shared.Log.Error(
+ shared.LogError(
"containerDeleteSnapshots: Failed to delete a snapshotcontainer",
log.Ctx{"container": cname, "snapshot": sname, "err": err})
}
From 2ace6bad04bfee9a8f3c6463c2f18f62f0792d98 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 10:49:03 +0200
Subject: [PATCH 04/16] lxd/daemon: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/daemon.go | 94 +++++++++++++++++++++++++++++------------------------------
1 file changed, 47 insertions(+), 47 deletions(-)
diff --git a/lxd/daemon.go b/lxd/daemon.go
index e8e7f3e..5636a46 100644
--- a/lxd/daemon.go
+++ b/lxd/daemon.go
@@ -218,7 +218,7 @@ func (d *Daemon) httpGetFile(url string, certificate string) (*http.Response, er
func readMyCert() (string, string, error) {
certf := shared.VarPath("server.crt")
keyf := shared.VarPath("server.key")
- shared.Log.Info("Looking for existing certificates", log.Ctx{"cert": certf, "key": keyf})
+ shared.LogInfo("Looking for existing certificates", log.Ctx{"cert": certf, "key": keyf})
err := shared.FindOrGenCert(certf, keyf)
return certf, keyf, err
@@ -277,19 +277,19 @@ func (d *Daemon) createCmd(version string, c Command) {
w.Header().Set("Content-Type", "application/json")
if d.isTrustedClient(r) {
- shared.Log.Info(
+ shared.LogInfo(
"handling",
log.Ctx{"method": r.Method, "url": r.URL.RequestURI(), "ip": r.RemoteAddr})
} else if r.Method == "GET" && c.untrustedGet {
- shared.Log.Info(
+ shared.LogInfo(
"allowing untrusted GET",
log.Ctx{"url": r.URL.RequestURI(), "ip": r.RemoteAddr})
} else if r.Method == "POST" && c.untrustedPost {
- shared.Log.Info(
+ shared.LogInfo(
"allowing untrusted POST",
log.Ctx{"url": r.URL.RequestURI(), "ip": r.RemoteAddr})
} else {
- shared.Log.Warn(
+ shared.LogWarn(
"rejecting request from untrusted client",
log.Ctx{"ip": r.RemoteAddr})
Forbidden.Render(w)
@@ -340,7 +340,7 @@ func (d *Daemon) createCmd(version string, c Command) {
if err := resp.Render(w); err != nil {
err := InternalError(err).Render(w)
if err != nil {
- shared.Log.Error("Failed writing error for error, giving up")
+ shared.LogErrorf("Failed writing error for error, giving up")
}
}
@@ -573,13 +573,13 @@ func (d *Daemon) Init() error {
/* Print welcome message */
if d.MockMode {
- shared.Log.Info("LXD is starting in mock mode",
+ shared.LogInfo("LXD is starting in mock mode",
log.Ctx{"path": shared.VarPath("")})
} else if d.SetupMode {
- shared.Log.Info("LXD is starting in setup mode",
+ shared.LogInfo("LXD is starting in setup mode",
log.Ctx{"path": shared.VarPath("")})
} else {
- shared.Log.Info("LXD is starting in normal mode",
+ shared.LogInfo("LXD is starting in normal mode",
log.Ctx{"path": shared.VarPath("")})
}
@@ -590,31 +590,31 @@ func (d *Daemon) Init() error {
if aaAvailable && os.Getenv("LXD_SECURITY_APPARMOR") == "false" {
aaAvailable = false
aaAdmin = false
- shared.Log.Warn("AppArmor support has been manually disabled")
+ shared.LogWarnf("AppArmor support has been manually disabled")
}
if aaAvailable && !shared.IsDir("/sys/kernel/security/apparmor") {
aaAvailable = false
aaAdmin = false
- shared.Log.Warn("AppArmor support has been disabled because of lack of kernel support")
+ shared.LogWarnf("AppArmor support has been disabled because of lack of kernel support")
}
_, err = exec.LookPath("apparmor_parser")
if aaAvailable && err != nil {
aaAvailable = false
aaAdmin = false
- shared.Log.Warn("AppArmor support has been disabled because 'apparmor_parser' couldn't be found")
+ shared.LogWarnf("AppArmor support has been disabled because 'apparmor_parser' couldn't be found")
}
/* Detect AppArmor admin support */
if aaAdmin && !haveMacAdmin() {
aaAdmin = false
- shared.Log.Warn("Per-container AppArmor profiles are disabled because the mac_admin capability is missing.")
+ shared.LogWarnf("Per-container AppArmor profiles are disabled because the mac_admin capability is missing.")
}
if aaAdmin && runningInUserns {
aaAdmin = false
- shared.Log.Warn("Per-container AppArmor profiles are disabled because LXD is running in an unprivileged container.")
+ shared.LogWarnf("Per-container AppArmor profiles are disabled because LXD is running in an unprivileged container.")
}
/* Detect AppArmor confinment */
@@ -622,54 +622,54 @@ func (d *Daemon) Init() error {
profile := aaProfile()
if profile != "unconfined" && profile != "" {
aaConfined = true
- shared.Log.Warn("Per-container AppArmor profiles are disabled because LXD is already protected by AppArmor.")
+ shared.LogWarnf("Per-container AppArmor profiles are disabled because LXD is already protected by AppArmor.")
}
}
/* Detect CGroup support */
cgBlkioController = shared.PathExists("/sys/fs/cgroup/blkio/")
if !cgBlkioController {
- shared.Log.Warn("Couldn't find the CGroup blkio controller, I/O limits will be ignored.")
+ shared.LogWarnf("Couldn't find the CGroup blkio controller, I/O limits will be ignored.")
}
cgCpuController = shared.PathExists("/sys/fs/cgroup/cpu/")
if !cgCpuController {
- shared.Log.Warn("Couldn't find the CGroup CPU controller, CPU time limits will be ignored.")
+ shared.LogWarnf("Couldn't find the CGroup CPU controller, CPU time limits will be ignored.")
}
cgCpuacctController = shared.PathExists("/sys/fs/cgroup/cpuacct/")
if !cgCpuacctController {
- shared.Log.Warn("Couldn't find the CGroup CPUacct controller, CPU accounting will not be available.")
+ shared.LogWarnf("Couldn't find the CGroup CPUacct controller, CPU accounting will not be available.")
}
cgCpusetController = shared.PathExists("/sys/fs/cgroup/cpuset/")
if !cgCpusetController {
- shared.Log.Warn("Couldn't find the CGroup CPUset controller, CPU pinning will be ignored.")
+ shared.LogWarnf("Couldn't find the CGroup CPUset controller, CPU pinning will be ignored.")
}
cgDevicesController = shared.PathExists("/sys/fs/cgroup/devices/")
if !cgDevicesController {
- shared.Log.Warn("Couldn't find the CGroup devices controller, device access control won't work.")
+ shared.LogWarnf("Couldn't find the CGroup devices controller, device access control won't work.")
}
cgMemoryController = shared.PathExists("/sys/fs/cgroup/memory/")
if !cgMemoryController {
- shared.Log.Warn("Couldn't find the CGroup memory controller, memory limits will be ignored.")
+ shared.LogWarnf("Couldn't find the CGroup memory controller, memory limits will be ignored.")
}
cgNetPrioController = shared.PathExists("/sys/fs/cgroup/net_prio/")
if !cgNetPrioController {
- shared.Log.Warn("Couldn't find the CGroup network class controller, network limits will be ignored.")
+ shared.LogWarnf("Couldn't find the CGroup network class controller, network limits will be ignored.")
}
cgPidsController = shared.PathExists("/sys/fs/cgroup/pids/")
if !cgPidsController {
- shared.Log.Warn("Couldn't find the CGroup pids controller, process limits will be ignored.")
+ shared.LogWarnf("Couldn't find the CGroup pids controller, process limits will be ignored.")
}
cgSwapAccounting = shared.PathExists("/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes")
if !cgSwapAccounting {
- shared.Log.Warn("CGroup memory swap accounting is disabled, swap limits will be ignored.")
+ shared.LogWarnf("CGroup memory swap accounting is disabled, swap limits will be ignored.")
}
/* Get the list of supported architectures */
@@ -727,18 +727,18 @@ func (d *Daemon) Init() error {
/* Detect the filesystem */
d.BackingFs, err = filesystemDetect(d.lxcpath)
if err != nil {
- shared.Log.Error("Error detecting backing fs", log.Ctx{"err": err})
+ shared.LogError("Error detecting backing fs", log.Ctx{"err": err})
}
/* Read the uid/gid allocation */
d.IdmapSet, err = shared.DefaultIdmapSet()
if err != nil {
- shared.Log.Warn("Error reading idmap", log.Ctx{"err": err.Error()})
- shared.Log.Warn("Only privileged containers will be able to run")
+ shared.LogWarn("Error reading idmap", log.Ctx{"err": err.Error()})
+ shared.LogWarnf("Only privileged containers will be able to run")
} else {
- shared.Log.Info("Default uid/gid map:")
+ shared.LogInfof("Default uid/gid map:")
for _, lxcmap := range d.IdmapSet.ToLxcString() {
- shared.Log.Info(strings.TrimRight(" - "+lxcmap, "\n"))
+ shared.LogInfof(strings.TrimRight(" - "+lxcmap, "\n"))
}
}
@@ -776,7 +776,7 @@ func (d *Daemon) Init() error {
err := d.ExpireLogs()
if err != nil {
- shared.Log.Error("Failed to expire logs", log.Ctx{"err": err})
+ shared.LogError("Failed to expire logs", log.Ctx{"err": err})
}
shared.LogDebugf("Done expiring log files")
@@ -835,7 +835,7 @@ func (d *Daemon) Init() error {
tlsConfig.RootCAs = caPool
tlsConfig.ClientCAs = caPool
- shared.Log.Info("LXD is in CA mode, only CA-signed certificates will be allowed")
+ shared.LogInfof("LXD is in CA mode, only CA-signed certificates will be allowed")
}
tlsConfig.BuildNameToCertificate()
@@ -863,14 +863,14 @@ func (d *Daemon) Init() error {
}
d.mux.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- shared.Log.Debug("Sending top level 404", log.Ctx{"url": r.URL})
+ shared.LogDebug("Sending top level 404", log.Ctx{"url": r.URL})
w.Header().Set("Content-Type", "application/json")
NotFound.Render(w)
})
listeners := d.GetListeners()
if len(listeners) > 0 {
- shared.Log.Info("LXD is socket activated")
+ shared.LogInfof("LXD is socket activated")
for _, listener := range listeners {
if shared.PathExists(listener.Addr().String()) {
@@ -881,7 +881,7 @@ func (d *Daemon) Init() error {
}
}
} else {
- shared.Log.Info("LXD isn't socket activated")
+ shared.LogInfof("LXD isn't socket activated")
localSocketPath := shared.VarPath("unix.socket")
@@ -890,7 +890,7 @@ func (d *Daemon) Init() error {
if shared.PathExists(localSocketPath) {
_, err := lxd.NewClient(&lxd.DefaultConfig, "local")
if err != nil {
- shared.Log.Debug("Detected stale unix socket, deleting")
+ shared.LogDebugf("Detected stale unix socket, deleting")
// Connecting failed, so let's delete the socket and
// listen on it ourselves.
err = os.Remove(localSocketPath)
@@ -942,10 +942,10 @@ func (d *Daemon) Init() error {
tcpl, err := tls.Listen("tcp", listenAddr, d.tlsConfig)
if err != nil {
- shared.Log.Error("cannot listen on https socket, skipping...", log.Ctx{"err": err})
+ shared.LogError("cannot listen on https socket, skipping...", log.Ctx{"err": err})
} else {
if d.TCPSocket != nil {
- shared.Log.Info("Replacing inherited TCP socket with configured one")
+ shared.LogInfof("Replacing inherited TCP socket with configured one")
d.TCPSocket.Socket.Close()
}
d.TCPSocket = &Socket{Socket: tcpl, CloseOnExit: true}
@@ -953,14 +953,14 @@ func (d *Daemon) Init() error {
}
d.tomb.Go(func() error {
- shared.Log.Info("REST API daemon:")
+ shared.LogInfof("REST API daemon:")
if d.UnixSocket != nil {
- shared.Log.Info(" - binding Unix socket", log.Ctx{"socket": d.UnixSocket.Socket.Addr()})
+ shared.LogInfo(" - binding Unix socket", log.Ctx{"socket": d.UnixSocket.Socket.Addr()})
d.tomb.Go(func() error { return http.Serve(d.UnixSocket.Socket, &lxdHttpServer{d.mux, d}) })
}
if d.TCPSocket != nil {
- shared.Log.Info(" - binding TCP socket", log.Ctx{"socket": d.TCPSocket.Socket.Addr()})
+ shared.LogInfo(" - binding TCP socket", log.Ctx{"socket": d.TCPSocket.Socket.Addr()})
d.tomb.Go(func() error { return http.Serve(d.TCPSocket.Socket, &lxdHttpServer{d.mux, d}) })
}
@@ -1042,7 +1042,7 @@ func (d *Daemon) Ready() error {
func (d *Daemon) CheckTrustState(cert x509.Certificate) bool {
for k, v := range d.clientCerts {
if bytes.Compare(cert.Raw, v.Raw) == 0 {
- shared.Log.Debug("Found cert", log.Ctx{"k": k})
+ shared.LogDebug("Found cert", log.Ctx{"k": k})
return true
}
}
@@ -1078,33 +1078,33 @@ func (d *Daemon) Stop() error {
forceStop := false
d.tomb.Kill(errStop)
- shared.Log.Info("Stopping REST API handler:")
+ shared.LogInfof("Stopping REST API handler:")
for _, socket := range []*Socket{d.TCPSocket, d.UnixSocket} {
if socket == nil {
continue
}
if socket.CloseOnExit {
- shared.Log.Info(" - closing socket", log.Ctx{"socket": socket.Socket.Addr()})
+ shared.LogInfo(" - closing socket", log.Ctx{"socket": socket.Socket.Addr()})
socket.Socket.Close()
} else {
- shared.Log.Info(" - skipping socket-activated socket", log.Ctx{"socket": socket.Socket.Addr()})
+ shared.LogInfo(" - skipping socket-activated socket", log.Ctx{"socket": socket.Socket.Addr()})
forceStop = true
}
}
if n, err := d.numRunningContainers(); err != nil || n == 0 {
- shared.Log.Debug("Unmounting shmounts")
+ shared.LogDebugf("Unmounting shmounts")
syscall.Unmount(shared.VarPath("shmounts"), syscall.MNT_DETACH)
} else {
shared.LogDebugf("Not unmounting shmounts (containers are still running)")
}
- shared.Log.Debug("Closing the database")
+ shared.LogDebugf("Closing the database")
d.db.Close()
- shared.Log.Debug("Stopping /dev/lxd handler")
+ shared.LogDebugf("Stopping /dev/lxd handler")
d.devlxd.Close()
if d.MockMode || forceStop {
From 0a8cd657deb58db60919aeac51ac67311ec4551a Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 10:49:31 +0200
Subject: [PATCH 05/16] lxd/daemon_config: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/daemon_config.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/daemon_config.go b/lxd/daemon_config.go
index 473054c..ccc30d9 100644
--- a/lxd/daemon_config.go
+++ b/lxd/daemon_config.go
@@ -198,7 +198,7 @@ func daemonConfigInit(db *sql.DB) error {
for k, v := range dbValues {
_, ok := daemonConfig[k]
if !ok {
- shared.Log.Error("Found invalid configuration key in database", log.Ctx{"key": k})
+ shared.LogError("Found invalid configuration key in database", log.Ctx{"key": k})
}
daemonConfig[k].currentValue = v
From fcd89d3a726526fc8e3ecdfae84d8adf6869534a Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 10:51:29 +0200
Subject: [PATCH 06/16] lxd/daemon_images: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/daemon_images.go | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/lxd/daemon_images.go b/lxd/daemon_images.go
index ed1c763..887450c 100644
--- a/lxd/daemon_images.go
+++ b/lxd/daemon_images.go
@@ -77,12 +77,12 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
}
if _, _, err := dbImageGet(d.db, fp, false, false); err == nil {
- shared.Log.Debug("Image already exists in the db", log.Ctx{"image": fp})
+ shared.LogDebug("Image already exists in the db", log.Ctx{"image": fp})
// already have it
return fp, nil
}
- shared.Log.Info(
+ shared.LogInfo(
"Image not in the db, downloading it",
log.Ctx{"image": fp, "server": server})
@@ -92,24 +92,24 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
// We already download the image
d.imagesDownloadingLock.RUnlock()
- shared.Log.Info(
+ shared.LogInfo(
"Already downloading the image, waiting for it to succeed",
log.Ctx{"image": fp})
// Wait until the download finishes (channel closes)
if _, ok := <-waitChannel; ok {
- shared.Log.Warn("Value transmitted over image lock semaphore?")
+ shared.LogWarnf("Value transmitted over image lock semaphore?")
}
if _, _, err := dbImageGet(d.db, fp, false, true); err != nil {
- shared.Log.Error(
+ shared.LogError(
"Previous download didn't succeed",
log.Ctx{"image": fp})
return "", fmt.Errorf("Previous download didn't succeed")
}
- shared.Log.Info(
+ shared.LogInfo(
"Previous download succeeded",
log.Ctx{"image": fp})
@@ -118,7 +118,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
d.imagesDownloadingLock.RUnlock()
- shared.Log.Info(
+ shared.LogInfo(
"Downloading the image",
log.Ctx{"image": fp})
@@ -179,7 +179,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
resp, err := d.httpGetSync(url, certificate)
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Failed to download image metadata",
log.Ctx{"image": fp, "err": err})
@@ -246,7 +246,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
raw, err := d.httpGetFile(exporturl, certificate)
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Failed to download image",
log.Ctx{"image": fp, "err": err})
return "", err
@@ -267,7 +267,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
// Get the metadata tarball
part, err := mr.NextPart()
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Invalid multipart image",
log.Ctx{"image": fp, "err": err})
@@ -275,7 +275,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
}
if part.FormName() != "metadata" {
- shared.Log.Error(
+ shared.LogError(
"Invalid multipart image",
log.Ctx{"image": fp, "err": err})
@@ -285,7 +285,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
destName = filepath.Join(destDir, info.Fingerprint)
f, err := os.Create(destName)
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Failed to save image",
log.Ctx{"image": fp, "err": err})
@@ -296,7 +296,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
f.Close()
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Failed to save image",
log.Ctx{"image": fp, "err": err})
@@ -306,7 +306,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
// Get the rootfs tarball
part, err = mr.NextPart()
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Invalid multipart image",
log.Ctx{"image": fp, "err": err})
@@ -314,7 +314,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
}
if part.FormName() != "rootfs" {
- shared.Log.Error(
+ shared.LogError(
"Invalid multipart image",
log.Ctx{"image": fp})
return "", fmt.Errorf("Invalid multipart image")
@@ -323,7 +323,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
destName = filepath.Join(destDir, info.Fingerprint+".rootfs")
f, err = os.Create(destName)
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Failed to save image",
log.Ctx{"image": fp, "err": err})
return "", err
@@ -333,7 +333,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
f.Close()
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Failed to save image",
log.Ctx{"image": fp, "err": err})
return "", err
@@ -343,7 +343,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
f, err := os.Create(destName)
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Failed to save image",
log.Ctx{"image": fp, "err": err})
@@ -354,7 +354,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
f.Close()
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Failed to save image",
log.Ctx{"image": fp, "err": err})
return "", err
@@ -382,7 +382,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
_, err = imageBuildFromInfo(d, info)
if err != nil {
- shared.Log.Error(
+ shared.LogError(
"Failed to create image",
log.Ctx{"image": fp, "err": err})
@@ -401,7 +401,7 @@ func (d *Daemon) ImageDownload(op *operation, server string, protocol string, ce
}
}
- shared.Log.Info(
+ shared.LogInfo(
"Download succeeded",
log.Ctx{"image": fp})
From 2ac3b0f194f9f2981881350f48f97d43fcf1307f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 10:53:04 +0200
Subject: [PATCH 07/16] lxd/db_containers: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/db_containers.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/db_containers.go b/lxd/db_containers.go
index 059bcf6..7d82fa2 100644
--- a/lxd/db_containers.go
+++ b/lxd/db_containers.go
@@ -346,7 +346,7 @@ func dbContainerRename(db *sql.DB, oldName string, newName string) error {
}
defer stmt.Close()
- shared.Log.Debug(
+ shared.LogDebug(
"Calling SQL Query",
log.Ctx{
"query": "UPDATE containers SET name = ? WHERE name = ?",
From 82a332968e9f3f44d7f95a83b44ca9cf67141726 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 10:55:59 +0200
Subject: [PATCH 08/16] lxd/db_update: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/db_update.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/db_update.go b/lxd/db_update.go
index 6c90c7d..1aba65d 100644
--- a/lxd/db_update.go
+++ b/lxd/db_update.go
@@ -102,7 +102,7 @@ func dbUpdatesApplyAll(d *Daemon) error {
}
if !backup {
- shared.Log.Info("Updating the LXD database schema. Backup made as \"lxd.db.bak\"")
+ shared.LogInfof("Updating the LXD database schema. Backup made as \"lxd.db.bak\"")
err := shared.FileCopy(shared.VarPath("lxd.db"), shared.VarPath("lxd.db.bak"))
if err != nil {
return err
From adf4057e2f107396874fc41603fc452711eaca2b Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 10:58:46 +0200
Subject: [PATCH 09/16] lxd/devices: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/devices.go | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/lxd/devices.go b/lxd/devices.go
index 2324351..652c6b3 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -218,7 +218,7 @@ func deviceNetlinkListener() (chan []string, chan []string, chan usbDevice, erro
devnum,
)
if err != nil {
- shared.Log.Error("error reading usb device", log.Ctx{"err": err, "path": props["PHYSDEVPATH"]})
+ shared.LogError("error reading usb device", log.Ctx{"err": err, "path": props["PHYSDEVPATH"]})
continue
}
@@ -286,24 +286,24 @@ func deviceTaskBalance(d *Daemon) {
// Older kernel - use cpuset.cpus
effectiveCpus, err = cGroupGet("cpuset", "/", "cpuset.cpus")
if err != nil {
- shared.Log.Error("Error reading host's cpuset.cpus")
+ shared.LogErrorf("Error reading host's cpuset.cpus")
return
}
}
err = cGroupSet("cpuset", "/lxc", "cpuset.cpus", effectiveCpus)
if err != nil && shared.PathExists("/sys/fs/cgroup/cpuset/lxc") {
- shared.Log.Warn("Error setting lxd's cpuset.cpus", log.Ctx{"err": err})
+ shared.LogWarn("Error setting lxd's cpuset.cpus", log.Ctx{"err": err})
}
cpus, err := parseCpuset(effectiveCpus)
if err != nil {
- shared.Log.Error("Error parsing host's cpu set", log.Ctx{"cpuset": effectiveCpus, "err": err})
+ shared.LogError("Error parsing host's cpu set", log.Ctx{"cpuset": effectiveCpus, "err": err})
return
}
// Iterate through the containers
containers, err := dbContainersList(d.db, cTypeRegular)
if err != nil {
- shared.Log.Error("problem loading containers list", log.Ctx{"err": err})
+ shared.LogError("problem loading containers list", log.Ctx{"err": err})
return
}
fixedContainers := map[int][]container{}
@@ -367,7 +367,7 @@ func deviceTaskBalance(d *Daemon) {
for cpu, ctns := range fixedContainers {
c, ok := usage[cpu]
if !ok {
- shared.Log.Error("Internal error: container using unavailable cpu")
+ shared.LogErrorf("Internal error: container using unavailable cpu")
continue
}
id := c.strId
@@ -416,7 +416,7 @@ func deviceTaskBalance(d *Daemon) {
sort.Strings(set)
err := ctn.CGroupSet("cpuset.cpus", strings.Join(set, ","))
if err != nil {
- shared.Log.Error("balance: Unable to set cpuset", log.Ctx{"name": ctn.Name(), "err": err, "value": strings.Join(set, ",")})
+ shared.LogError("balance: Unable to set cpuset", log.Ctx{"name": ctn.Name(), "err": err, "value": strings.Join(set, ",")})
}
}
}
@@ -460,7 +460,7 @@ func deviceNetworkPriority(d *Daemon, netif string) {
func deviceUSBEvent(d *Daemon, usb usbDevice) {
containers, err := dbContainersList(d.db, cTypeRegular)
if err != nil {
- shared.Log.Error("problem loading containers list", log.Ctx{"err": err})
+ shared.LogError("problem loading containers list", log.Ctx{"err": err})
return
}
@@ -472,7 +472,7 @@ func deviceUSBEvent(d *Daemon, usb usbDevice) {
c, ok := containerIf.(*containerLXC)
if !ok {
- shared.Log.Error("got device event on non-LXC container?")
+ shared.LogErrorf("got device event on non-LXC container?")
return
}
@@ -494,17 +494,17 @@ func deviceUSBEvent(d *Daemon, usb usbDevice) {
if usb.action == "add" {
err := c.insertUSBDevice(m, usb)
if err != nil {
- shared.Log.Error("failed to create usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
+ shared.LogError("failed to create usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
return
}
} else if usb.action == "remove" {
err := c.removeUSBDevice(m, usb)
if err != nil {
- shared.Log.Error("failed to remove usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
+ shared.LogError("failed to remove usb device", log.Ctx{"err": err, "usb": usb, "container": c.Name()})
return
}
} else {
- shared.Log.Error("unknown action for usb device", log.Ctx{"usb": usb})
+ shared.LogError("unknown action for usb device", log.Ctx{"usb": usb})
continue
}
}
@@ -514,7 +514,7 @@ func deviceUSBEvent(d *Daemon, usb usbDevice) {
func deviceEventListener(d *Daemon) {
chNetlinkCPU, chNetlinkNetwork, chUSB, err := deviceNetlinkListener()
if err != nil {
- shared.Log.Error("scheduler: couldn't setup netlink listener")
+ shared.LogErrorf("scheduler: couldn't setup netlink listener")
return
}
@@ -522,7 +522,7 @@ func deviceEventListener(d *Daemon) {
select {
case e := <-chNetlinkCPU:
if len(e) != 2 {
- shared.Log.Error("Scheduler: received an invalid cpu hotplug event")
+ shared.LogErrorf("Scheduler: received an invalid cpu hotplug event")
continue
}
@@ -534,7 +534,7 @@ func deviceEventListener(d *Daemon) {
deviceTaskBalance(d)
case e := <-chNetlinkNetwork:
if len(e) != 2 {
- shared.Log.Error("Scheduler: received an invalid network hotplug event")
+ shared.LogErrorf("Scheduler: received an invalid network hotplug event")
continue
}
@@ -548,7 +548,7 @@ func deviceEventListener(d *Daemon) {
deviceUSBEvent(d, e)
case e := <-deviceSchedRebalance:
if len(e) != 3 {
- shared.Log.Error("Scheduler: received an invalid rebalance event")
+ shared.LogErrorf("Scheduler: received an invalid rebalance event")
continue
}
From 03ca42fc11b5eaeee3dd6dffa4bf9b1664992e43 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 11:25:58 +0200
Subject: [PATCH 10/16] lxd/main: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/main.go | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/lxd/main.go b/lxd/main.go
index 832693f..d464cfe 100644
--- a/lxd/main.go
+++ b/lxd/main.go
@@ -374,8 +374,7 @@ func cmdDaemon() error {
signal.Notify(ch, syscall.SIGPWR)
sig := <-ch
- shared.Log.Info(
- fmt.Sprintf("Received '%s signal', shutting down containers.", sig))
+ shared.LogInfof("Received '%s signal', shutting down containers.", sig)
containersShutdown(d)
@@ -386,8 +385,7 @@ func cmdDaemon() error {
go func() {
<-d.shutdownChan
- shared.Log.Info(
- fmt.Sprintf("Asked to shutdown by API, shutting down containers."))
+ shared.LogInfof("Asked to shutdown by API, shutting down containers.")
containersShutdown(d)
@@ -402,7 +400,7 @@ func cmdDaemon() error {
signal.Notify(ch, syscall.SIGTERM)
sig := <-ch
- shared.Log.Info(fmt.Sprintf("Received '%s signal', exiting.", sig))
+ shared.LogInfof("Received '%s signal', exiting.", sig)
ret = d.Stop()
wg.Done()
}()
From 2d5425d31204143dd548b46d0329ebbeeb3d5e34 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 11:27:54 +0200
Subject: [PATCH 11/16] lxd/patches: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/patches.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/patches.go b/lxd/patches.go
index 4d7f0f0..3d303dd 100644
--- a/lxd/patches.go
+++ b/lxd/patches.go
@@ -95,7 +95,7 @@ func patchInvalidProfileNames(name string, d *Daemon) error {
for _, profile := range profiles {
if strings.Contains(profile, "/") || shared.StringInSlice(profile, []string{".", ".."}) {
- shared.Log.Info("Removing unreachable profile (invalid name)", log.Ctx{"name": profile})
+ shared.LogInfo("Removing unreachable profile (invalid name)", log.Ctx{"name": profile})
err := dbProfileDelete(d.db, profile)
if err != nil {
return err
From ed197dbc2ac5a5418426f468fc57b9df171fc8f4 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 11:29:51 +0200
Subject: [PATCH 12/16] lxd/profiles: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/profiles.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lxd/profiles.go b/lxd/profiles.go
index bf3fdff..a76e612 100644
--- a/lxd/profiles.go
+++ b/lxd/profiles.go
@@ -43,7 +43,7 @@ func profilesGet(d *Daemon, r *http.Request) Response {
} else {
profile, err := doProfileGet(d, name)
if err != nil {
- shared.Log.Error("Failed to get profile", log.Ctx{"profile": name})
+ shared.LogError("Failed to get profile", log.Ctx{"profile": name})
continue
}
resultMap[i] = profile
@@ -134,7 +134,7 @@ func getRunningContainersWithProfile(d *Daemon, profile string) []container {
for _, name := range output {
c, err := containerLoadByName(d, name)
if err != nil {
- shared.Log.Error("Failed opening container", log.Ctx{"container": name})
+ shared.LogError("Failed opening container", log.Ctx{"container": name})
continue
}
results = append(results, c)
From 76386b4ca537af620bc508198378e0a133bc8624 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 11:35:48 +0200
Subject: [PATCH 13/16] lxd/storage: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/storage.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/storage.go b/lxd/storage.go
index 7b6f9ac..a660dde 100644
--- a/lxd/storage.go
+++ b/lxd/storage.go
@@ -309,7 +309,7 @@ func (ss *storageShared) shiftRootfs(c container) error {
dpath := c.Path()
rpath := c.RootfsPath()
- shared.Log.Debug("Shifting root filesystem",
+ shared.LogDebug("Shifting root filesystem",
log.Ctx{"container": c.Name(), "rootfs": rpath})
idmapset := c.IdmapSet()
From 5a619cee3967cd02729547f99432cef49a782327 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 11:37:59 +0200
Subject: [PATCH 14/16] lxd/storage_btrfs: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/storage_btrfs.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index 9e6621d..16308f6 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -1033,7 +1033,7 @@ func (s *storageBtrfs) MigrationSink(live bool, container container, snapshots [
err = cmd.Wait()
if err != nil {
- shared.Log.Error("problem with btrfs receive", log.Ctx{"output": string(output)})
+ shared.LogError("problem with btrfs receive", log.Ctx{"output": string(output)})
return err
}
@@ -1042,13 +1042,13 @@ func (s *storageBtrfs) MigrationSink(live bool, container container, snapshots [
err := s.subvolSnapshot(cPath, targetPath, false)
if err != nil {
- shared.Log.Error("problem with btrfs snapshot", log.Ctx{"err": err})
+ shared.LogError("problem with btrfs snapshot", log.Ctx{"err": err})
return err
}
err = s.subvolsDelete(cPath)
if err != nil {
- shared.Log.Error("problem with btrfs delete", log.Ctx{"err": err})
+ shared.LogError("problem with btrfs delete", log.Ctx{"err": err})
return err
}
}
From 41c00cdf0310503a8c4301ed2a286414c31ee54f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 11:44:28 +0200
Subject: [PATCH 15/16] lxd/storage_lvm: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/storage_lvm.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 2964346..3f8fc5d 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -20,7 +20,7 @@ import (
func storageLVMCheckVolumeGroup(vgName string) error {
output, err := exec.Command("vgdisplay", "-s", vgName).CombinedOutput()
if err != nil {
- shared.Log.Debug("vgdisplay failed to find vg", log.Ctx{"output": string(output)})
+ shared.LogDebug("vgdisplay failed to find vg", log.Ctx{"output": string(output)})
return fmt.Errorf("LVM volume group '%s' not found", vgName)
}
@@ -557,7 +557,7 @@ func (s *storageLvm) createSnapshotContainer(
srcName := containerNameToLVName(sourceContainer.Name())
destName := containerNameToLVName(snapshotContainer.Name())
- shared.Log.Debug(
+ shared.LogDebug(
"Creating snapshot",
log.Ctx{"srcName": srcName, "destName": destName})
@@ -649,7 +649,7 @@ func (s *storageLvm) ContainerSnapshotStart(container container) error {
srcName := containerNameToLVName(container.Name())
destName := containerNameToLVName(container.Name() + "/rw")
- shared.Log.Debug(
+ shared.LogDebug(
"Creating snapshot",
log.Ctx{"srcName": srcName, "destName": destName})
From 370ced5debca070de390d74b67e6171a3b6949fd Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Fri, 16 Sep 2016 11:47:19 +0200
Subject: [PATCH 16/16] lxd/storage_zfs: switch to new logging functions
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
lxd/storage_zfs.go | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 39d33bd..9457c88 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -1250,12 +1250,12 @@ func (s *zfsMigrationSourceDriver) send(conn *websocket.Conn, zfsName string, zf
output, err := ioutil.ReadAll(stderr)
if err != nil {
- shared.Log.Error("problem reading zfs send stderr", "err", err)
+ shared.LogError("problem reading zfs send stderr", log.Ctx{"err": err})
}
err = cmd.Wait()
if err != nil {
- shared.Log.Error("problem with zfs send", "output", string(output))
+ shared.LogError("problem with zfs send", log.Ctx{"output": string(output)})
}
return err
@@ -1397,12 +1397,12 @@ func (s *storageZfs) MigrationSink(live bool, container container, snapshots []c
output, err := ioutil.ReadAll(stderr)
if err != nil {
- shared.LogDebugf("problem reading zfs recv stderr %s", "err", err)
+ shared.LogDebug("problem reading zfs recv stderr %s", log.Ctx{"err": err})
}
err = cmd.Wait()
if err != nil {
- shared.Log.Error("problem with zfs recv", "output", string(output))
+ shared.LogError("problem with zfs recv", log.Ctx{"output": string(output)})
}
return err
}
@@ -1441,7 +1441,7 @@ func (s *storageZfs) MigrationSink(live bool, container container, snapshots []c
/* clean up our migration-send snapshots that we got from recv. */
zfsSnapshots, err := s.zfsListSnapshots(fmt.Sprintf("containers/%s", container.Name()))
if err != nil {
- shared.Log.Error("failed listing snapshots post migration", "err", err)
+ shared.LogError("failed listing snapshots post migration", log.Ctx{"err": err})
return
}
More information about the lxc-devel
mailing list