2020-03-27 12:35:57 +01:00
|
|
|
package zfscmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Implementation Note:
|
|
|
|
//
|
|
|
|
// Pre-events logged with debug
|
|
|
|
// Post-event without error logged with info
|
|
|
|
// Post-events with error _also_ logged with info
|
|
|
|
// (Not all errors we observe at this layer) are actual errors in higher-level layers)
|
|
|
|
|
|
|
|
func startPreLogging(c *Cmd, now time.Time) {
|
|
|
|
c.log().Debug("starting command")
|
|
|
|
}
|
|
|
|
|
|
|
|
func startPostLogging(c *Cmd, err error, now time.Time) {
|
|
|
|
if err == nil {
|
|
|
|
c.log().Info("started command")
|
|
|
|
} else {
|
|
|
|
c.log().WithError(err).Error("cannot start command")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func waitPreLogging(c *Cmd, now time.Time) {
|
|
|
|
c.log().Debug("start waiting")
|
|
|
|
}
|
|
|
|
|
zfscmd: fix crash in zfscmd_prometheus.go due to incorrectly extracted ProcessState
fixup of 96e188d7c4837ff1188ab923daeb0a0f4cce31ae
refs #196
refs #301
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x9a472a]
goroutine 15826 [running]:
os.(*ProcessState).systemTime(...)
/home/cs/go1.13/src/os/exec_unix.go:98
os.(*ProcessState).SystemTime(...)
/home/cs/go1.13/src/os/exec.go:141
github.com/zrepl/zrepl/zfs/zfscmd.waitPostPrometheus(0xc000c04800, 0xe21ce0, 0xc000068270, 0xbf9f80d88107e861, 0x19bae710e6, 0x13a8b60)
/home/cs/zrepl/zrepl/zfs/zfscmd/zfscmd_prometheus.go:69 +0x22a
github.com/zrepl/zrepl/zfs/zfscmd.(*Cmd).waitPost(0xc000c04800, 0xe21ce0, 0xc000068270)
/home/cs/zrepl/zrepl/zfs/zfscmd/zfscmd.go:155 +0x18a
github.com/zrepl/zrepl/zfs/zfscmd.(*Cmd).CombinedOutput(0xc000c04800, 0xc0004b8270, 0xd02eea, 0x3, 0xc0001f6c40, 0x3)
/home/cs/zrepl/zrepl/zfs/zfscmd/zfscmd.go:40 +0xb3
github.com/zrepl/zrepl/zfs.ZFSRelease(0xe36aa0, 0xc0004b8270, 0xc0009a3a40, 0x13, 0xc0004a5d00, 0x1, 0x1, 0xed62eb221, 0x13a8b60)
/home/cs/zrepl/zrepl/zfs/holds.go:102 +0x2a7
github.com/zrepl/zrepl/endpoint.ReleaseStep(0xe36aa0, 0xc0004b8270, 0xc0004befc0, 0xe, 0xd08482, 0x8, 0xc0001cb02f, 0x2, 0x1eeea3bff89dc90b, 0x134d6, ...)
/home/cs/zrepl/zrepl/endpoint/endpoint_zfs_abstraction_step.go:130 +0x367
github.com/zrepl/zrepl/endpoint.(*Sender).SendCompleted.func2(0xc000459190, 0xc000390e30, 0xc00041fd80, 0xc0004befc0, 0xe, 0xd08482, 0x8, 0xc0001cb02f, 0x2, 0x1eeea3bff89dc90b, ...)
/home/cs/zrepl/zrepl/endpoint/endpoint.go:419 +0x1c3
created by github.com/zrepl/zrepl/endpoint.(*Sender).SendCompleted
/home/cs/zrepl/zrepl/endpoint/endpoint.go:413 +0x776
2020-04-20 13:57:19 +02:00
|
|
|
func waitPostLogging(c *Cmd, u usage, err error, now time.Time) {
|
2020-04-08 00:24:37 +02:00
|
|
|
|
2020-03-27 12:35:57 +01:00
|
|
|
log := c.log().
|
zfscmd: fix crash in zfscmd_prometheus.go due to incorrectly extracted ProcessState
fixup of 96e188d7c4837ff1188ab923daeb0a0f4cce31ae
refs #196
refs #301
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x9a472a]
goroutine 15826 [running]:
os.(*ProcessState).systemTime(...)
/home/cs/go1.13/src/os/exec_unix.go:98
os.(*ProcessState).SystemTime(...)
/home/cs/go1.13/src/os/exec.go:141
github.com/zrepl/zrepl/zfs/zfscmd.waitPostPrometheus(0xc000c04800, 0xe21ce0, 0xc000068270, 0xbf9f80d88107e861, 0x19bae710e6, 0x13a8b60)
/home/cs/zrepl/zrepl/zfs/zfscmd/zfscmd_prometheus.go:69 +0x22a
github.com/zrepl/zrepl/zfs/zfscmd.(*Cmd).waitPost(0xc000c04800, 0xe21ce0, 0xc000068270)
/home/cs/zrepl/zrepl/zfs/zfscmd/zfscmd.go:155 +0x18a
github.com/zrepl/zrepl/zfs/zfscmd.(*Cmd).CombinedOutput(0xc000c04800, 0xc0004b8270, 0xd02eea, 0x3, 0xc0001f6c40, 0x3)
/home/cs/zrepl/zrepl/zfs/zfscmd/zfscmd.go:40 +0xb3
github.com/zrepl/zrepl/zfs.ZFSRelease(0xe36aa0, 0xc0004b8270, 0xc0009a3a40, 0x13, 0xc0004a5d00, 0x1, 0x1, 0xed62eb221, 0x13a8b60)
/home/cs/zrepl/zrepl/zfs/holds.go:102 +0x2a7
github.com/zrepl/zrepl/endpoint.ReleaseStep(0xe36aa0, 0xc0004b8270, 0xc0004befc0, 0xe, 0xd08482, 0x8, 0xc0001cb02f, 0x2, 0x1eeea3bff89dc90b, 0x134d6, ...)
/home/cs/zrepl/zrepl/endpoint/endpoint_zfs_abstraction_step.go:130 +0x367
github.com/zrepl/zrepl/endpoint.(*Sender).SendCompleted.func2(0xc000459190, 0xc000390e30, 0xc00041fd80, 0xc0004befc0, 0xe, 0xd08482, 0x8, 0xc0001cb02f, 0x2, 0x1eeea3bff89dc90b, ...)
/home/cs/zrepl/zrepl/endpoint/endpoint.go:419 +0x1c3
created by github.com/zrepl/zrepl/endpoint.(*Sender).SendCompleted
/home/cs/zrepl/zrepl/endpoint/endpoint.go:413 +0x776
2020-04-20 13:57:19 +02:00
|
|
|
WithField("total_time_s", u.total_secs).
|
|
|
|
WithField("systemtime_s", u.system_secs).
|
|
|
|
WithField("usertime_s", u.user_secs)
|
2020-03-27 12:35:57 +01:00
|
|
|
|
|
|
|
if err == nil {
|
|
|
|
log.Info("command exited without error")
|
|
|
|
} else {
|
|
|
|
log.WithError(err).Info("command exited with error")
|
|
|
|
}
|
|
|
|
}
|