Skip to content

Commit

Permalink
Adds better logging around SMB mapping for FSX
Browse files Browse the repository at this point in the history
1. Adds debug logging for SMB mapping for the command
that is being executed. This command will not not log the
creds used to attach the mapping.

2. Logs the ps output stderr/stdout from the command on error.

Signed-off-by: Justin Terry <[email protected]>
  • Loading branch information
jterry75 authored and singholt committed Jun 9, 2022
1 parent cba1b38 commit acf0ba2
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,18 +553,23 @@ func (fv *FSxWindowsFileServerResource) performHostMount(remotePath string, user

// New-SmbGlobalMapping cmdlet creates an SMB mapping between the container instance
// and SMB share (FSx for Windows File Server file-system)
cmd := execCommand("powershell.exe",

args := []string{
"New-SmbGlobalMapping",
localPathArg,
remotePathArg,
creds,
"-Persistent $true",
"-RequirePrivacy $true",
"-ErrorAction Stop")
"-ErrorAction Stop",
}
seelog.Debugf("Executing mapping of fsxwindowsfileserver with cmd: %v %v", strings.Join(args[:3], " "), strings.Join(args[4:], " "))

_, err = cmd.CombinedOutput()
cmd := execCommand("powershell.exe", args...)
out, err := cmd.CombinedOutput()
if err != nil {
seelog.Errorf("Failed to map fsxwindowsfileserver resource on the container instance: %v", err)
safeOutput := strings.ReplaceAll(string(out), password, "<pass>")
seelog.Errorf("Failed to map fsxwindowsfileserver resource on the container instance error: %v, out: %v", err, safeOutput)
fv.setTerminalReason(err.Error())
return err
}
Expand Down

0 comments on commit acf0ba2

Please sign in to comment.