-
Notifications
You must be signed in to change notification settings - Fork 50
Handle varying output formats for rbd status #454
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
Handle varying output formats for rbd status #454
Conversation
Codecov Report
@@ Coverage Diff @@
## master #454 +/- ##
==========================================
- Coverage 30.61% 30.55% -0.06%
==========================================
Files 29 29
Lines 1777 1777
==========================================
- Hits 544 543 -1
- Misses 1175 1176 +1
Partials 58 58
Continue to review full report at Codecov.
|
| } | ||
|
|
||
| // Init initializes the driver. | ||
| func (d *driver) Init(context types.Context, config gofig.Config) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Since this PR needs to be rebased onto master anyway, can you please fix the name of the context variable to be ctx. It's the standard way of naming the first parameter of a function when it's of type Context. Thank you.
drivers/storage/rbd/utils/utils.go
Outdated
|
|
||
| cmd := exec.Command(radosCmd, "lspools") | ||
| log.Debugf("running command: %v", cmd.Args) | ||
| ctx.Debugf("running command: %v", cmd.Args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Please use this instead:
ctx.WithFields(map[string]interface{}{
"cmd": radosCmd,
"args": cmd.Args,
}).Debug("running rados cmd")
drivers/storage/rbd/utils/utils.go
Outdated
| if exiterr, ok := err.(*exec.ExitError); ok { | ||
| stderr := string(exiterr.Stderr) | ||
| log.Errorf("Unable to get pools: %s", stderr) | ||
| ctx.Errorf("Unable to get pools: %s", stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Please use this instead (formatting aside):
ctx.WithError(
exiterr,
).WithField(
"stderr", stderr,
).Error("error getting pools")
drivers/storage/rbd/utils/utils.go
Outdated
| if exiterr, ok := err.(*exec.ExitError); ok { | ||
| stderr := string(exiterr.Stderr) | ||
| log.Errorf("Unable to get rbd images: %s", stderr) | ||
| ctx.Errorf("Unable to get rbd images: %s", stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Please use this instead (formatting aside):
ctx.WithError(
exiterr,
).WithField(
"stderr", stderr,
).Error("error getting rbd images")
drivers/storage/rbd/utils/utils.go
Outdated
| rbdCmd, "info", "-p", *pool, *name, formatOpt, jsonArg) | ||
|
|
||
| log.Debugf("running command: %v", cmd.Args) | ||
| ctx.Debugf("running command: %v", cmd.Args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Please use this instead:
ctx.WithFields(map[string]interface{}{
"cmd": rbdCmd,
"args": cmd.Args,
}).Debug("running rados cmd")
drivers/storage/rbd/utils/utils.go
Outdated
| if exiterr, ok := err.(*exec.ExitError); ok { | ||
| stderr := string(exiterr.Stderr) | ||
| log.Errorf("Unable to map RBD: %s", stderr) | ||
| ctx.Errorf("Unable to map RBD: %s", stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Please use this instead (formatting aside):
ctx.WithError(
exiterr,
).WithField(
"stderr", stderr,
).Error("error mapping rbd")
drivers/storage/rbd/utils/utils.go
Outdated
| if exiterr, ok := err.(*exec.ExitError); ok { | ||
| stderr := string(exiterr.Stderr) | ||
| log.Errorf("Unable to unmap RBD: %s", stderr) | ||
| ctx.Errorf("Unable to unmap RBD: %s", stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Please use this instead (formatting aside):
ctx.WithError(
exiterr,
).WithField(
"stderr", stderr,
).Error("error unmapping rbd")
drivers/storage/rbd/utils/utils.go
Outdated
| if exiterr, ok := err.(*exec.ExitError); ok { | ||
| stderr := string(exiterr.Stderr) | ||
| log.Errorf("Unable to get RBD status: %s", stderr) | ||
| ctx.Errorf("Unable to get RBD status: %s", stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Please use this instead (formatting aside):
ctx.WithError(
exiterr,
).WithField(
"stderr", stderr,
).Error("error getting rbd status")
drivers/storage/rbd/utils/utils.go
Outdated
|
|
||
| cmd := exec.Command(rbdCmd, "unmap", *device) | ||
| log.Debugf("running command: %v", cmd.Args) | ||
| ctx.Debugf("running command: %v", cmd.Args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Please use this instead:
ctx.WithFields(map[string]interface{}{
"cmd": rbdCmd,
"args": cmd.Args,
}).Debug("running rados cmd")
drivers/storage/rbd/utils/utils.go
Outdated
| rbdCmd, "status", poolOpt, *pool, *image, formatOpt, jsonArg, | ||
| ) | ||
| log.Debugf("running command: %v", cmd.Args) | ||
| ctx.Debugf("running command: %v", cmd.Args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @codenrhoden,
Please use this instead:
ctx.WithFields(map[string]interface{}{
"cmd": rbdCmd,
"args": cmd.Args,
}).Debug("running rados cmd")The output for rbd status --format json has been updated recently to have the "watchers" field be an array instead of a map. Account for that.
da8e8e4 to
544afc0
Compare
|
Thanks for the guidance on better structured logging, @akutz. A definite improvement. I think I've made all the requested changes. |
The output for rbd status --format json has been updated recently
to have the "watchers" field be an array instead of a map. Account
for that.
Fixes #451