Skip to content

Fix slack engine to run on python2.6 - #33601

Merged
cachedout merged 4 commits into
saltstack:developfrom
mchugh19:slack-fix
Jun 1, 2016
Merged

cachedout merged 4 commits into
saltstack:developfrom
mchugh19:slack-fix

Conversation

@mchugh19

@mchugh19 mchugh19 commented May 28, 2016 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes issue where slack user doesn't have an is_bot key
Allows engine to run on rhel6 with python 2.6 with unicode conversion
Corrects for slack's autoparsing of url looking text. Commands like:
!salt test.ping target=hostname.domain.com should now be handled properly.

Tests written?

No

I am not a python unicode wizard, so please don't take my word for it. While this fixes the engine for my python2.6 environment, there might be better ways of handling something maybe with python 3 in mind. So this works for me and likely corrects it for others, but please review.

Christian McHugh added 2 commits May 27, 2016 22:06
Deduplicate alias handling to autodetect function selection.
Add error reporting to slack connectivty problems.
Cleanup slack's unicode conversion
@mchugh19

Copy link
Copy Markdown
Contributor Author

Just pushed a much cleaner version of unicode handling. While it might be a mild hack to convert to json and back, those modules handle the decoding properly and make the code future proof.

This commit also cleans up lint errors, evaluates alias commands the same as standard ones, properly prints json to slack allowing for correct syntax highlighting, and adds error reporting for connection issues.

All in all, this is a large bug fix over what was shipped in 2016.3 and after review should be evaluated for backport.

@cachedout

Copy link
Copy Markdown
Contributor

This looks pretty good to me. What do you think, @garethgreenaway ?

@cachedout

Copy link
Copy Markdown
Contributor

@garethgreenaway

Copy link
Copy Markdown
Contributor

@cachedout Looks good, just reviewing now.

Comment thread salt/engines/slack.py Outdated
cmdline = salt.utils.shlex_split(_text[len(trigger):])

# Remove inital salt item from list
if cmdline[0] == 'salt':

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure about this one. The first bit of the command is the trigger so if !salt is the trigger then is should get removed during the for loop on cmdline. Seems confusing to have ! be the trigger but also include salt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right you are. I had somehow gotten it into my head that the trigger was !salt service.restart...

Would it be appropriate to expand the trigger as a single "!" is pretty generic? There could be other integrations that also operate on a short triggers, so a unique key seems important.

@garethgreenaway

Copy link
Copy Markdown
Contributor

@cachedout Added some comments but overall looks great.

@cachedout

Copy link
Copy Markdown
Contributor

@garethgreenaway Thanks as always for the quick feedback!

@mchugh19 Let me know when you've had a chance to look all this over. Thank you!

@cachedout cachedout added the pending-discussion The issue or pull request needs more discussion before it can be closed or merged label May 31, 2016
@mchugh19

Copy link
Copy Markdown
Contributor Author

@cachedout fixed lint spacing error.

@garethgreenaway Whatever you think for the trigger. I like the !salt uniqueness and mirroring of the command line syntax, but this is a released module and that would be syntax change. So I can either make !salt the trigger, or can pull out the salt key deletion.

Also, I added a hipchat engine to mirror this one. So if we decide on "!" I'll update hipchat to match.

@garethgreenaway

Copy link
Copy Markdown
Contributor

@mchugh19 I personally like !salt too but it's configurable in the engine configuration using the trigger keyword, that keyword is then used in all the code to pull out the relevant Salt command bits. So detecting and pulling out salt from the first argument shouldn't really be necessary.

@mchugh19

Copy link
Copy Markdown
Contributor Author

@garethgreenaway Done and done.

@garethgreenaway

Copy link
Copy Markdown
Contributor

👍

@Ch3LL

Ch3LL commented Dec 22, 2016

Copy link
Copy Markdown
Contributor

ping @rallytime can we get this backported? It seems to be fixed in 2016.11 but users in 2016.3 will still be effected as shown in issue: #33618

@Ch3LL Ch3LL added the bugfix-bckport will be be back-ported to an older release branch by creating a PR against that branch label Dec 22, 2016
@rallytime rallytime added Bugfix - [Done] back-ported and removed bugfix-bckport will be be back-ported to an older release branch by creating a PR against that branch labels Jan 3, 2017
@rallytime

Copy link
Copy Markdown
Contributor

Sure. Please see #38531

cachedout pushed a commit that referenced this pull request Jan 4, 2017
@mchugh19
mchugh19 deleted the slack-fix branch February 18, 2017 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-discussion The issue or pull request needs more discussion before it can be closed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants