Skip to content

Confusing Salt error messages due to limited/incomplete PowerShell command error handling #17041

Closed

Description

@xenophonf

The function _parse_powershell_list does not parse errors returned by PowerShell or the ServerManager PS module, which results in confusing error messages in the Salt user interface. For example, instead of telling the Salt user that a computer is in a post-restart-pending-action state (e.g., after removing a server role), the Salt user interface reports an IndexError in an assignment operation in _parse_powershell_list. Instead, Salt should relay the PowerShell error message (e.g., that a particular user needs to log into the computer and run Server Manager to complete the configuration change), as this clearly indicates what went wrong and how to remediate the error condition.

Steps to Reproduce

Given a computer running a full installation of Windows Server 2008 R2 Standard Edition (with all patches applied) and version 2014.1.11 of the Salt minion (latest version at time of writing), with the minion ID of minion-id:

  1. Install the Web Server role interactively via Server Manager.

  2. Remove the Web Server role interactively via Server Manager.

  3. Reboot when prompted.

  4. Do not log into the computer once it finishes booting.

  5. From the Salt master, run the following command to re-install the Web Server role:

    salt minion-id state.single win_servermanager.installed name=Web-Server

  6. The above command will return the following error:

          ID: Web-Server
    Function: win_servermanager.installed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "salt/state.py", line 1379, in call
                File "salt/states/win_servermanager.py", line 51, in installed
                File "c:\salt\var\cache\salt\minion\extmods\modules\win_servermanager.py", line 97, in install
                  return _parse_powershell_list(out)
                File "c:\salt\var\cache\salt\minion\extmods\modules\win_servermanager.py", line 35, in _parse_powershell_list
                  ret[splt[0]] = splt[2]
              IndexError: list index out of range
     Changes:
    
  7. From the Salt master, run the following PowerShell command to re-install the Web Server role (which simulates the behavior of the win_servermanager.installed state):

    salt minion-id cmd.run 'Import-Module ServerManager ; Add-WindowsFeature -Name Web-Server -erroraction silentlycontinue | format-list' shell=powershell

  8. The above command will return the following error:

    Add-WindowsFeature : A configuration started by EXAMPLE\Administrator is current
    ly in progress. Before you can start a configuration, EXAMPLE\Administrator must
     log in to complete the current configuration or the configuration in progress
    must be canceled.
    At line:1 char:49
    + Import-Module ServerManager ; Add-WindowsFeature <<<<  -Name Web-Server  -err
    oraction silentlycontinue | format-list
        + CategoryInfo          : OperationStopped: (:) [Add-WindowsFeature], Exce
       ption
        + FullyQualifiedErrorId : PostRestartPendingAction,Microsoft.Windows.Serve
       rManager.Commands.AddWindowsFeatureCommand
    
  9. Log into the computer and acknowledge the Server Manager role removal.

  10. Re-run the win_servermanager.installed state. It will complete successfully.

Activity

  1. basepi commented on Oct 30, 2014

    @basepi
    Contributor

    Thanks for the report, we'll look into improving the error-handling here.

  2. added
    bug
    on Oct 30, 2014
  3. added this to the Approved milestone on Oct 30, 2014
  4. rallytime commented on Apr 8, 2015

    @rallytime
    Contributor

    @xenophonf I don't know if this has been addressed or not yet, but I know we made a lot of changes to the windows minion in 2014.7.4. Are you in a position to try this new package and see if this issue is fixed?

  5. added
    severity-low
    P1
    fixed-pls-verify
    and removed on Apr 8, 2015
  6. xenophonf commented on Apr 10, 2015

    @xenophonf
    ContributorAuthor

    Yes, I'd be happy to test the fix.

  7. self-assigned this
    on Apr 14, 2015
  8. xenophonf commented on Apr 21, 2015

    @xenophonf
    ContributorAuthor

    I tried 2014.7.4, but when I ran "salt-call state.highstate", it returned the error "zipimport.ZipImportError: not a Zip file". I don't have time to make my own 2014.7 build at the moment, but if that changes, I'll be sure to try again.

  9. rallytime commented on Apr 23, 2015

    @rallytime
    Contributor

    Ok, thanks for trying a newer release! I'll remove the "Fixed Pending Verification" label.

  10. removed
    fixed-pls-verify
    on Apr 23, 2015
  11. added
    Platform
    on May 26, 2015
  12. modified the milestones: Be 4, Approved on Jun 22, 2015
  13. xenophonf commented on Jun 23, 2015

    @xenophonf
    ContributorAuthor

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1PlatformWindowsZRELEASED - Berylliumbugseverity-low

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions