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

Handle exception when no Slack API key was provided #34923

Merged

Conversation

eliasp
Copy link
Contributor

@eliasp eliasp commented Jul 25, 2016

When no Slack API key was provided, the state execution will fail like this:

          ID: hello world
    Function: slack.post_message
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1723, in call                                                                                          
                  **cdata['kwargs'])                                                                                                                                               
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1650, in wrapper                                                                                      
                  return f(*args, **kwargs)                                                                                                                                        
                File "/usr/lib/python2.7/dist-packages/salt/states/slack.py", line 104, in post_message                                                                            
                  icon=icon,                                                                                                                                                       
                File "/usr/lib/python2.7/dist-packages/salt/modules/slack_notify.py", line 188, in post_message                                                                    
                  api_key = _get_api_key()                                                                                                                                         
                File "/usr/lib/python2.7/dist-packages/salt/modules/slack_notify.py", line 53, in _get_api_key                                                                     
                  raise SaltInvocationError('No Slack API key found.')                                                                                                             
              SaltInvocationError: No Slack API key found.                                                                                                                         
     Started: 07:38:49.258271
    Duration: 4.542 ms
     Changes:   

Make it fail a bit more graceful:

          ID: hello world
    Function: slack.post_message
      Result: False
     Comment: Failed to send message: hello world (No Slack API key found.)
     Started: 11:34:16.072458
    Duration: 1.063 ms
     Changes:   

rallytime pushed a commit to rallytime/salt that referenced this pull request Jul 25, 2016
@rallytime rallytime merged commit 69afcc4 into saltstack:2016.3 Jul 25, 2016
rallytime pushed a commit that referenced this pull request Jul 25, 2016
@rallytime
Copy link
Contributor

Great!

gitebra pushed a commit to gitebra/salt that referenced this pull request Jul 26, 2016
* upstream/develop: (153 commits)
  Increase all run_script timeouts to 30s (saltstack#34956)
  Fix grains integration tests for Windows (saltstack#34941)
  GCE Cloud tests (saltstack#34871)
  Create regdata before try/except (saltstack#34931)
  Add prune option to reg.list (saltstack#34934)
  Skip inode test in Windows (saltstack#34938)
  Remove use_carrier bond for Ubuntu Xenial later (saltstack#34779)
  Add jid to salt.function orchestration events
  [bashcompletion] replace ticks with bash subshell
  [bashcompletion] ignore salt-key headers
  Add jid to orchestration returns
  Avoid UnboundLocalError in beacons module
  [bash-completion] hide timeout in salt-output
  Master performance improvement (saltstack#34916)
  Update service_rh provider to exclude XenServer >= 7. (saltstack#34915)
  Lint fixes for saltstack#34923
  pv_present should execute pvcreate with -y if existing filesystem signature detected
  Handle exception when no Slack API key was provided
  zone absent with tests
  added zone_present state check
  ...
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