From acf0ba2e7d90541555215a10a859a29c6ec3475e Mon Sep 17 00:00:00 2001 From: Justin Terry Date: Fri, 3 Jun 2022 10:28:57 -0700 Subject: [PATCH] Adds better logging around SMB mapping for FSX 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 --- .../fsxwindowsfileserver_windows.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/agent/taskresource/fsxwindowsfileserver/fsxwindowsfileserver_windows.go b/agent/taskresource/fsxwindowsfileserver/fsxwindowsfileserver_windows.go index cd2175c5d26..c868d78c589 100644 --- a/agent/taskresource/fsxwindowsfileserver/fsxwindowsfileserver_windows.go +++ b/agent/taskresource/fsxwindowsfileserver/fsxwindowsfileserver_windows.go @@ -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, "") + seelog.Errorf("Failed to map fsxwindowsfileserver resource on the container instance error: %v, out: %v", err, safeOutput) fv.setTerminalReason(err.Error()) return err }