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

Avoid UnboundLocalError in beacons module #34935

Merged
merged 1 commit into from
Jul 26, 2016

Conversation

rallytime
Copy link
Contributor

@rallytime rallytime commented Jul 25, 2016

What does this PR do?

If something goes wrong with the event response call, we'll hit an UnboundLocalError stack trace during the if beacons check below. This avoids that stacktrace by instantiating beacons as None before trying the event call.

This imports the correct salt.utils.event lib (not just salt.utils - event.py is it's own file and there isn't an event reference in salt.utils.__init__.py).

What issues does this PR fix or reference?

None that I know of - found during the testing of the

Previous Behavior

When trying to perform a salt-call --local beacons.list function, the stacktrace happens when no beacons are configured:

Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/root/SaltStack/salt/salt/scripts.py", line 338, in salt_call
    client.run()
  File "/root/SaltStack/salt/salt/cli/call.py", line 53, in run
    caller.run()
  File "/root/SaltStack/salt/salt/cli/caller.py", line 134, in run
    ret = self.call()
  File "/root/SaltStack/salt/salt/cli/caller.py", line 197, in call
    ret['return'] = func(*args, **kwargs)
  File "/root/SaltStack/salt/salt/modules/beacons.py", line 56, in list_
    if beacons:
UnboundLocalError: local variable 'beacons' referenced before assignment

New Behavior

No more stacktrace:

root@rallytime:~# salt-call --local beacons.list
local:
    ----------
    beacons:
        ----------

Tests written?

No - there are already integration tests covering this feature in general. That's how this bug was found. Those tests started failing during the merge-forward in #34894.

Also import the correct salt.utils.event lib (not just salt.utils)
@cachedout cachedout merged commit deb1331 into saltstack:2016.3 Jul 26, 2016
@rallytime rallytime deleted the beacons-mod-cleanup branch July 26, 2016 17:01
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

2 participants