Skip to content

'sensu.client_delete' fails if client was already deleted #3

@arm4b

Description

@arm4b

The error

# st2 run sensu.client_delete client=st2-pkg-unstable-u14-ent-d01ba3d6c8.uswest2

.
id: 59372a4badf59216541c7566
status: failed
parameters: 
  client: st2-pkg-unstable-u14-ent-d01ba3d6c8.uswest2
result: 
  exit_code: 1
  result: None
  stderr: "No handlers could be found for logger "pysensu.api"
Traceback (most recent call last):
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 259, in <module>
    obj.run()
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/runners/python_action_wrapper.py", line 155, in run
    output = action.run(**self._parameters)
  File "/opt/stackstorm/packs/sensu/actions/client_delete.py", line 10, in run
    return self.api.delete_client(client)
  File "/opt/stackstorm/virtualenvs/sensu/lib/python2.7/site-packages/pysensu/api.py", line 99, in delete_client
    self._request('DELETE', '/clients/{}'.format(client))
  File "/opt/stackstorm/virtualenvs/sensu/lib/python2.7/site-packages/pysensu/api.py", line 64, in _request
    raise SensuAPIException('API bad response')
pysensu.api.SensuAPIException: API bad response
"
  stdout: ''

Sensu API response is 404 and it happens when client we want to delete doesn't exist.
According to specification this is correct: https://sensuapp.org/docs/latest/api/clients-api.html#clientsclient-delete


We should try to catch the exception and return Success action execution result if client we want to delete is already deleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions