mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-21 20:40:20 +00:00
remove secret and key from logging
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
77e930c2f3
commit
68e69502e8
@ -49,38 +49,39 @@ func closePipeOnError(pipe io.Closer, err error) {
|
|||||||
|
|
||||||
func execCommand(program string, args ...string) (stdout, stderr []byte, err error) {
|
func execCommand(program string, args ...string) (stdout, stderr []byte, err error) {
|
||||||
cmd := exec.Command(program, args...) // nolint: gosec
|
cmd := exec.Command(program, args...) // nolint: gosec
|
||||||
klog.V(4).Infof("cephfs: EXEC %s %s", program, util.StripSecretInArgs(args))
|
stripArgs := util.StripSecretInArgs(args)
|
||||||
|
klog.V(4).Infof("cephfs: EXEC %s %s", program, stripArgs)
|
||||||
|
|
||||||
stdoutPipe, err := cmd.StdoutPipe()
|
stdoutPipe, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("cannot open stdout pipe for %s %v: %v", program, args, err)
|
return nil, nil, fmt.Errorf("cannot open stdout pipe for %s %v: %v", program, stripArgs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer closePipeOnError(stdoutPipe, err)
|
defer closePipeOnError(stdoutPipe, err)
|
||||||
|
|
||||||
stderrPipe, err := cmd.StderrPipe()
|
stderrPipe, err := cmd.StderrPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("cannot open stdout pipe for %s %v: %v", program, args, err)
|
return nil, nil, fmt.Errorf("cannot open stdout pipe for %s %v: %v", program, stripArgs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer closePipeOnError(stderrPipe, err)
|
defer closePipeOnError(stderrPipe, err)
|
||||||
|
|
||||||
if err = cmd.Start(); err != nil {
|
if err = cmd.Start(); err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to run %s %v: %v", program, args, err)
|
return nil, nil, fmt.Errorf("failed to run %s %v: %v", program, stripArgs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout, err = ioutil.ReadAll(stdoutPipe)
|
stdout, err = ioutil.ReadAll(stdoutPipe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to read from stdout for %s %v: %v", program, args, err)
|
return nil, nil, fmt.Errorf("failed to read from stdout for %s %v: %v", program, stripArgs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
stderr, err = ioutil.ReadAll(stderrPipe)
|
stderr, err = ioutil.ReadAll(stderrPipe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to read from stderr for %s %v: %v", program, args, err)
|
return nil, nil, fmt.Errorf("failed to read from stderr for %s %v: %v", program, stripArgs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if waitErr := cmd.Wait(); waitErr != nil {
|
if waitErr := cmd.Wait(); waitErr != nil {
|
||||||
return nil, nil, fmt.Errorf("an error occurred while running %s %v: %v: %s", program, args, waitErr, stderr)
|
return nil, nil, fmt.Errorf("an error occurred while running %s %v: %v: %s", program, stripArgs, waitErr, stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -98,7 +99,7 @@ func execCommandJSON(v interface{}, program string, args ...string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err = json.Unmarshal(stdout, v); err != nil {
|
if err = json.Unmarshal(stdout, v); err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal JSON for %s %v: %s: %v", program, args, stdout, err)
|
return fmt.Errorf("failed to unmarshal JSON for %s %v: %s: %v", program, util.StripSecretInArgs(args), stdout, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user