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

Salt api honors --log-file correctly #59881

Merged
merged 1 commit into from Mar 25, 2021
Merged

Conversation

dwoz
Copy link
Contributor

@dwoz dwoz commented Mar 23, 2021

Make sure we verify the proper path when the --log-file cli options is
passed via the commandline.

What issues does this PR fix or reference?

Fixes: #59880

@dwoz dwoz requested a review from a team as a code owner March 23, 2021 20:16
@dwoz dwoz requested review from dhiltonp and removed request for a team March 23, 2021 20:16
Make sure we verify the proper path when the --log-file cli options is
passed via the commandline. Fixes saltstack#59880
@dwoz dwoz requested a review from dhiltonp March 24, 2021 20:48
@dwoz dwoz added the Silicon v3004.0 Release code name label Mar 24, 2021
@Ch3LL Ch3LL merged commit 94492d8 into saltstack:master Mar 25, 2021
try:
os.remove(logfile)
except OSError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (non-blocking): Could add a contextmanager for this:

from contextlib import contextmanager

@contextmanager
def mktemp():
    fname = tempfile.mktemp()
    try:
        yield fname
    finally:
        try:
            os.remove(fname)
        except OSError:
            pass

Then it's just

with mktemp() as pidfile, mktemp() as logfile, patch.object(...):

and the rest of this boilerplate disappears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Silicon v3004.0 Release code name
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Salt api doesn't completely honor --log-file
5 participants