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

Address file.managed with binary file #54480

Merged
merged 4 commits into from
Nov 15, 2019

Conversation

xeacott
Copy link
Contributor

@xeacott xeacott commented Sep 13, 2019

What does this PR do?

Allow windows minion to manage a binary file that originates with ext_pillar.

What issues does this PR fix or reference?

#53600

Previous Behavior

Previously, Salt would fail when applying a second state of file.managed like so:

DESKTOP-P56BQAV:
----------
          ID: dump_secret
    Function: file.managed
        Name: C:/random.bin
      Result: False
     Comment: Unable to manage file: 'ascii' codec can't decode byte 0xc0 in position 24: ordinal not in range(128)
     Started: 11:22:52.481000
    Duration: 20.0 ms
     Changes:

Summary for DESKTOP-P56BQAV
------------
Succeeded: 0
Failed:    1

New Behavior

Now, salt will report the file is in the correct state since no change has been made on it:

DESKTOP-P56BQAV:
----------
          ID: dump_secret
    Function: file.managed
        Name: C:/random.bin
      Result: True
     Comment: File C:/random.bin is in the correct state
     Started: 11:24:11.529000
    Duration: 118.0 ms
     Changes:

Summary for DESKTOP-P56BQAV
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time: 118.000 ms

Tests written?

Yes

Commits signed with GPG?

Yes

@xeacott xeacott force-pushed the fix/file.managed_binary_file branch from be34255 to c104f3a Compare October 8, 2019 17:51
@xeacott xeacott requested a review from a team as a code owner October 8, 2019 17:51
@ghost ghost requested a review from dwoz October 8, 2019 17:51
@xeacott xeacott changed the base branch from 2019.2.1 to master October 8, 2019 17:52
that the file is in the correct state.
'''
# Create a binary file
name = os.path.join(TMP, '1px.gif')
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW this could be rewritten using tempfile.NamedTemporaryFile, to avoid the try/except to try and cleanup.

@dwoz dwoz merged commit 00791c5 into saltstack:master Nov 15, 2019
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.

5 participants