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

[BUG] Slack salt engine stopped working February 24th due to deprecation of API #59612

Closed
cristian-popa opened this issue Feb 25, 2021 · 5 comments · Fixed by #60165
Closed
Assignees
Labels
Bug broken, incorrect, or confusing behavior severity-critical top severity, seen by most users, serious issues Silicon v3004.0 Release code name slack All salt stuff for slack

Comments

@cristian-popa
Copy link

cristian-popa commented Feb 25, 2021

Description
Salt slack engine stopped working today February 24th 2021. Based on my research I think is due to this: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api

"The final date for existing apps and custom integrations is now February 24th, 2021."

Setup

Slack engine that worked perfectly fine till today, no config changes. Debug log starting today. I've added a Diagnostic line in slack.py to check the data returned from slack api see lines between ========== lines in the debug output

.............
[DEBUG   ] Requesting URL https://slack.com/api/users.list?token=[removed] using GET method
[DEBUG   ] Using backend: tornado
[DEBUG   ] Response Status Code: 200
[DEBUG   ] Requesting URL https://slack.com/api/channels.list?token=[removed] using GET method
[DEBUG   ] Using backend: tornado
[DEBUG   ] Response Status Code: 200
===========================================================
Print Diagnostic line 229 of /usr/lib/python3.6/site-packages/salt/engines/slack.py:  print(ret["message"]) prints out method_deprecated 
=============================================================
[CRITICAL] Engine 'slack' could not be started!
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/engines/slack.py", line 949, in start
    client.run_commands_from_slack_async(message_generator, fire_all, tag, control)
  File "/usr/lib/python3.6/site-packages/salt/engines/slack.py", line 787, in run_commands_from_slack_async
    for msg in message_generator:
  File "/usr/lib/python3.6/site-packages/salt/engines/slack.py", line 513, in generate_triggered_messages
    token
  File "/usr/lib/python3.6/site-packages/salt/engines/slack.py", line 230, in get_slack_channels
    channels[item["id"]] = item["name"]
TypeError: string indices must be integers

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/engines/__init__.py", line 135, in run
    self.engine[self.fun](**kwargs)
  File "/usr/lib/python3.6/site-packages/salt/engines/slack.py", line 951, in start
    raise Exception("{}".format(traceback.format_exc()))
Exception: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/engines/slack.py", line 949, in start
    client.run_commands_from_slack_async(message_generator, fire_all, tag, control)
  File "/usr/lib/python3.6/site-packages/salt/engines/slack.py", line 787, in run_commands_from_slack_async
    for msg in message_generator:
  File "/usr/lib/python3.6/site-packages/salt/engines/slack.py", line 513, in generate_triggered_messages
    token
  File "/usr/lib/python3.6/site-packages/salt/engines/slack.py", line 230, in get_slack_channels
    channels[item["id"]] = item["name"]
TypeError: string indices must be integers

Steps to Reproduce the behavior
Try to use the slack engine, I used to have forced slack client=1.0.0 due to other issues but no slack client version is working now.

Expected behavior
Slack engine should work.

Screenshots

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
salt --versions-report
Salt Version:
          Salt: 3002.2
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: 4.0.5
     gitpython: 3.1.7
        Jinja2: 2.11.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov 16 2020, 16:55:22)
  python-gnupg: Not Installed
        PyYAML: 3.13
         PyZMQ: 17.0.0
         smmap: 3.0.4
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.1.4
 
System Versions:
          dist: centos 7 Core
        locale: UTF-8
       machine: x86_64
       release: 5.10.13-x86_64
        system: Linux
       version: CentOS Linux 7 Core
 

Additional context
I guess the only fix would be to migrate to slack SDK: https://slack.dev/python-slack-sdk/v3-migration/ . Am I missing any workaround?
Looks like Slack published these deprecations more than one year ago, curious if there is a process to stay ahead of these moving forward.

@cristian-popa cristian-popa added the Bug broken, incorrect, or confusing behavior label Feb 25, 2021
@welcome
Copy link

welcome bot commented Feb 25, 2021

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at core@saltstack.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@cristian-popa
Copy link
Author

Fixed my local version:
/usr/lib/python3.6/site-packages/salt/utils/slack.py
Line 54 change from:
"rooms": {"request": "channels.list", "response": "channels"},
to
"rooms": {"request": "conversations.list", "response": "channels"},

@sagetherage sagetherage added severity-critical top severity, seen by most users, serious issues and removed needs-triage labels Mar 31, 2021
@sagetherage sagetherage added this to the Silicon milestone Mar 31, 2021
@sagetherage sagetherage added the Silicon v3004.0 Release code name label Mar 31, 2021
@xeacott
Copy link
Contributor

xeacott commented May 6, 2021

@cristian-popa Would you like to make a PR for those changes? There's other changes that need to happen to the slack module due to the changes from Feb. 24th that we are also aware of.

@sagetherage sagetherage added the slack All salt stuff for slack label May 7, 2021
@ITJamie
Copy link
Contributor

ITJamie commented Sep 10, 2021

The above PR did not fix the engine itself. It still has issues.

Sep 10 09:45:20 saltdirector salt-master[440948]: [CRITICAL] Engine 'slack' could not be started!
Sep 10 09:45:20 saltdirector salt-master[440948]: Traceback (most recent call last):
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 933, in start
Sep 10 09:45:20 saltdirector salt-master[440948]:     client.run_commands_from_slack_async(message_generator, fire_all, tag, control)
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 777, in run_commands_from_slack_async
Sep 10 09:45:20 saltdirector salt-master[440948]:     for msg in message_generator:
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 504, in generate_triggered_messages
Sep 10 09:45:20 saltdirector salt-master[440948]:     all_slack_channels = self.get_slack_channels(
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 222, in get_slack_channels
Sep 10 09:45:20 saltdirector salt-master[440948]:     channels[item["id"]] = item["name"]
Sep 10 09:45:20 saltdirector salt-master[440948]: TypeError: string indices must be integers
Sep 10 09:45:20 saltdirector salt-master[440948]: During handling of the above exception, another exception occurred:
Sep 10 09:45:20 saltdirector salt-master[440948]: Traceback (most recent call last):
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/__init__.py", line 130, in run
Sep 10 09:45:20 saltdirector salt-master[440948]:     self.engine[self.fun](**kwargs)
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/loader.py", line 1241, in __call__
Sep 10 09:45:20 saltdirector salt-master[440948]:     return self.loader.run(run_func, *args, **kwargs)
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/loader.py", line 2274, in run
Sep 10 09:45:20 saltdirector salt-master[440948]:     return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/loader.py", line 2289, in _run_as
Sep 10 09:45:20 saltdirector salt-master[440948]:     return _func_or_method(*args, **kwargs)
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 935, in start
Sep 10 09:45:20 saltdirector salt-master[440948]:     raise Exception("{}".format(traceback.format_exc()))
Sep 10 09:45:20 saltdirector salt-master[440948]: Exception: Traceback (most recent call last):
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 933, in start
Sep 10 09:45:20 saltdirector salt-master[440948]:     client.run_commands_from_slack_async(message_generator, fire_all, tag, control)
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 777, in run_commands_from_slack_async
Sep 10 09:45:20 saltdirector salt-master[440948]:     for msg in message_generator:
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 504, in generate_triggered_messages
Sep 10 09:45:20 saltdirector salt-master[440948]:     all_slack_channels = self.get_slack_channels(
Sep 10 09:45:20 saltdirector salt-master[440948]:   File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 222, in get_slack_channels
Sep 10 09:45:20 saltdirector salt-master[440948]:     channels[item["id"]] = item["name"]
Sep 10 09:45:20 saltdirector salt-master[440948]: TypeError: string indices must be integers

sdklein added a commit to sdklein/salt that referenced this issue Dec 1, 2021
Per the issue/comment here: saltstack#59612 (comment)

The PR associated to that issue from xeacott did not have the reference updated in the comment.
@gediminasz
Copy link
Contributor

The error persists after upgrading to Salt 3005.1:

CRITICAL [salt.engines     :108 ][CRITICAL][155205] Engine could not be started!
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 940, in start
    client.run_commands_from_slack_async(message_generator, fire_all, tag, control)
  File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 778, in run_commands_from_slack_async
    for msg in message_generator:
  File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 506, in generate_triggered_messages
    token
  File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 222, in get_slack_channels
    channels[item["id"]] = item["name"]
TypeError: string indices must be integers
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/engines/__init__.py", line 103, in run
    self.engine[self.fun](**kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 942, in start
    raise Exception("{}".format(traceback.format_exc()))
Exception: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 940, in start
    client.run_commands_from_slack_async(message_generator, fire_all, tag, control)
  File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 778, in run_commands_from_slack_async
    for msg in message_generator:
  File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 506, in generate_triggered_messages
    token
  File "/usr/lib/python3/dist-packages/salt/engines/slack.py", line 222, in get_slack_channels
    channels[item["id"]] = item["name"]
TypeError: string indices must be integers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior severity-critical top severity, seen by most users, serious issues Silicon v3004.0 Release code name slack All salt stuff for slack
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants