Skip to content

Commit

Permalink
RemoteManager returns errors when closing created shell
Browse files Browse the repository at this point in the history
Signed-off-by: Nitin Ravindran <nitin.ravindran@broadcom.com>
  • Loading branch information
aramprice authored and xtreme-nitin-ravindran committed Jul 18, 2024
1 parent 61cf194 commit 08a8f39
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions remotemanager/winrm_remotemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ func (w *WinRM) CanReachVM() error {
if err != nil {
return fmt.Errorf("host %s is unreachable. Please ensure WinRM is enabled and the IP is correct: %s", w.host, err)
}
conn.Close()
err = conn.Close()
if err != nil {
return fmt.Errorf("could not close connection to host %s: %s", w.host, err)
}

return nil
}

Expand All @@ -57,7 +61,11 @@ func (w *WinRM) CanLoginVM() error {
if err != nil {
return fmt.Errorf("failed to create winrm shell: %s", err)
}
s.Close()

err = s.Close()
if err != nil {
return fmt.Errorf("failed to close winrm shell: %s", err)
}

return nil
}
Expand Down Expand Up @@ -113,8 +121,10 @@ func (w *WinRM) ExecuteCommandWithTimeout(command string, timeout time.Duration)
}

func (w *WinRM) ExecuteCommand(command string) (int, error) {
//fmt.Printf("Executing %s\n", command)
exitCode, err := w.ExecuteCommandWithTimeout(command, WinRmTimeout)
//fmt.Printf("Exectued. exit code %d\n", exitCode)
return exitCode, err
if err != nil {
return exitCode, fmt.Errorf("error executing '%s': %w", command, err)
}

return exitCode, nil
}

0 comments on commit 08a8f39

Please sign in to comment.