util: use context.Context for logging in ExecCommand

All calls to util.ExecCommand() now pass the context.Context. In some
cases this is not possible or needed, and util.ExecCommand() will not
log the command.

This should make debugging easier when command executions fail.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2020-07-22 14:11:41 +02:00
committed by mergify[bot]
parent bb4f1c7c9d
commit ddac66d76b
6 changed files with 32 additions and 18 deletions

View File

@ -31,12 +31,12 @@ import (
type volumeID string
func execCommandErr(ctx context.Context, program string, args ...string) error {
_, _, err := util.ExecCommand(program, args...)
_, _, err := util.ExecCommand(ctx, program, args...)
return err
}
func execCommandJSON(ctx context.Context, v interface{}, program string, args ...string) error {
stdout, _, err := util.ExecCommand(program, args...)
stdout, _, err := util.ExecCommand(ctx, program, args...)
if err != nil {
return err
}

View File

@ -52,6 +52,7 @@ func getVolumeRootPathCephDeprecated(volID volumeID) string {
func getVolumeRootPathCeph(ctx context.Context, volOptions *volumeOptions, cr *util.Credentials, volID volumeID) (string, error) {
stdout, stderr, err := util.ExecCommand(
ctx,
"ceph",
"fs",
"subvolume",

View File

@ -167,7 +167,7 @@ func mountFuse(ctx context.Context, mountPoint string, cr *util.Credentials, vol
args = append(args, "--client_mds_namespace="+volOptions.FsName)
}
_, stderr, err := util.ExecCommand("ceph-fuse", args[:]...)
_, stderr, err := util.ExecCommand(ctx, "ceph-fuse", args[:]...)
if err != nil {
return err
}