Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_dism: Return failure when package path does not exist #39426

Merged
merged 1 commit into from Feb 16, 2017
Merged

win_dism: Return failure when package path does not exist #39426

merged 1 commit into from Feb 16, 2017

Conversation

morganwillcock
Copy link
Contributor

What does this PR do?

Adds checks in the win_dism state module, so that trying to install or remove a package using a non-existent path does not return failure.

What issues does this PR fix or reference?

An exception is thrown when the package path isn't present, but is passed as the name to win_dism.package_installed or win_dism.package_removed. It's mostly an issue in test mode, because it's probably another function that is copying them to the disk, which would also be in test mode.

Previous Behavior

          ID: install_Windows6.1-KB3212646-x64
    Function: dism.package_installed
        Name: C:\Updates\Windows6.1-KB3212646-x64\Windows6.1-KB3212646-x64.cab
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "c:\salt\bin\lib\site-packages\salt\state.py", line 1745, in call
                  **cdata['kwargs'])
                File "c:\salt\bin\lib\site-packages\salt\loader.py", line 1702, in wrapper
                  return f(*args, **kwargs)
                File "c:\salt\bin\lib\site-packages\salt\states\win_dism.py", line 337, in package_installed
                  if package_info['Package Identity'] in old:
              KeyError: 'Package Identity'
     Started: 17:07:16.447000
    Duration: 1466.0 ms
     Changes:  

New Behavior

Test mode:

          ID: install_Windows6.1-KB3212646-x64
    Function: dism.package_installed
        Name: C:\Updates\Windows6.1-KB3212646-x64\Windows6.1-KB3212646-x64.cab
      Result: None
     Comment: Package path C:\Updates\Windows6.1-KB3212646-x64\Windows6.1-KB3212646-x64.cab does not exist
     Started: 17:35:55.028000
    Duration: 1.0 ms
     Changes:  

For real:

          ID: install_Windows6.1-KB3212646-x64
    Function: dism.package_installed
        Name: C:\Updates\Windows6.1-KB3212646-x64\Windows6.1-KB3212646-x64.cab
      Result: False
     Comment: Package path C:\Updates\Windows6.1-KB3212646-x64\Windows6.1-KB3212646-x64.cab does not exist
     Started: 17:36:46.323000
    Duration: 2.0 ms
     Changes: 

Tests written?

No

Please review Salt's Contributing Guide for best practices.

@cachedout
Copy link
Contributor

@twangboy and @opdude Any feedback on this?

@morganwillcock
Copy link
Contributor Author

Actually this may be the wrong approach. It might be better to look for ['retcode'] in the output of package_info and then try and match that to an error, or use the output for the comment. What's the best way to check if it's the correct dict?

Copy link
Contributor

@twangboy twangboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine.

@morganwillcock
Copy link
Contributor Author

Okay, thanks for taking a look.

@cachedout cachedout merged commit 9dbfba9 into saltstack:2016.3 Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants