Skip to content

Commit a88e797

Browse files
authored
Merge branch 'master' into remove_mistral
2 parents cb501c6 + 8a95cb7 commit a88e797

File tree

4 files changed

+85
-20
lines changed

4 files changed

+85
-20
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Changed
3131
that does not exist. It now reports a simplified log for cleaner reading. Addresses and Fixes #4979. (improvement) #4981
3232

3333
Contributed by Justin Sostre (@saucetray)
34+
* The built-in ``st2.action.file_writen`` trigger has been renamed to ``st2.action.file_written``
35+
to fix the typo (bug fix) #4992
3436

3537
Fixed
3638
~~~~~
@@ -56,6 +58,8 @@ Fixed
5658
up correctly, specifically when specifying a bastion host / jump box. (bug fix) #4973
5759

5860
Contributed by Nick Maludy (@nmaludy Encore Technologies)
61+
* Fixed a bytes/string encoding bug in the ``linux.dig`` action so it should work on Python 3
62+
(bug fix) #4993
5963

6064
* Fixed a bug where a python3 sensor using ssl needs to be monkey patched earlier. See also #4832, #4975 and gevent/gevent#1016 (bug fix) #4976
6165

@@ -68,12 +72,9 @@ Fixed
6872
Contributed by Bradley Bishop (@bishopbm1 Encore Technologies)
6973
* Fix a regression when updated ``dnspython`` pip dependency resulted in
7074
st2 services unable to connect to mongodb remote host (bug fix) #4997
75+
* Fixed a regression in the ``linux.dig`` action on Python 3. (bug fix) #4993
7176

72-
Changed
73-
~~~~~~~
74-
75-
* The built-in ``st2.action.file_writen`` trigger has been renamed to ``st2.action.file_written``
76-
to fix the typo (bug fix) #4992
77+
Contributed by @blag
7778

7879
Removed
7980
~~~~~~~

OWNERS.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ Have deep platform knowledge & experience and demonstrate technical leadership a
3232

3333
# Maintainers *
3434
###### 1 vote points
35-
Being part of Technical Steering Committee (TSC) [@StackStorm/maintainers](https://github.com/orgs/StackStorm/teams/maintainers) provide significant and reliable value to the project helping it grow and improve through development and maintenance.
35+
Being part of Technical Steering Committee (TSC) [@StackStorm/maintainers](https://github.com/orgs/StackStorm/teams/maintainers) provide significant and reliable value to the project helping it grow and improve through development and maintenance. See [Maintainer Responsibilities](https://github.com/StackStorm/st2/blob/master/GOVERNANCE.md#maintainer-responsibilities) for more info.
36+
* Amanda McGuinness ([@amanda11](https://github.com/amanda11)) <<amanda.mcguinness@ammeonsolutions.com>>
37+
- Ansible, Core, deb/rpm packages, CI/CD, Deployments, StackStorm Exchange, Documentation.
3638
* JP Bourget ([@punkrokk](https://github.com/punkrokk)) <<jp.bourget@gmail.com>>
37-
- Systems, deb/rpm, Deployments, Community, StackStorm Exchange, SecOps, CircleCi
39+
- Systems, deb/rpm, Deployments, Community, StackStorm Exchange, SecOps, CircleCI.
3840
* Mick McGrath ([@mickmcgrath13](https://github.com/mickmcgrath13)) <<mick@bitovi.com>>
3941
- Systems, ST2 Exchange. [Case Study](https://stackstorm.com/case-study-bitovi/).
4042
* Nick Maludy ([@nmaludy](https://github.com/nmaludy)) <<nmaludy@gmail.com>>
@@ -44,9 +46,8 @@ Being part of Technical Steering Committee (TSC) [@StackStorm/maintainers](https
4446

4547
# Contributors
4648
Contributors are using and occasionally contributing back to the project, might be active in conversations or express their opinion on the project’s direction.
47-
They're not part of the TSC voting process, but appreciated for their contribution, involvement and may become Maintainers in future.
48-
<!-- [@StackStorm/contributors](https://github.com/orgs/StackStorm/teams/contributors) are invited to StackStorm Github organization and we appreciate their contribution and involvement. -->
49-
* Amanda McGuinness ([@amanda11](https://github.com/amanda11)) - StackStorm Exchange, Ansible, ChatOps, Documentation, core.
49+
They're not part of the TSC voting process, but appreciated for their contribution, involvement and may become Maintainers in the future depending on their effort and involvement. See [How to become a Maintainer?](https://github.com/StackStorm/st2/blob/master/GOVERNANCE.md#how-to-become-a-maintainer)
50+
[@StackStorm/contributors](https://github.com/orgs/StackStorm/teams/contributors) are invited to StackStorm Github organization and have permissions to help triage the Issues and review PRs.
5051
* Carlos ([@nzlosh](https://github.com/nzlosh)) - Chatops, Errbot, Community, Discussions, StackStorm Exchange.
5152
* Hiroyasu Ohyama ([@userlocalhost](https://github.com/userlocalhost)) - Orquesta, Workflows, st2 Japan Community. [Case Study](https://stackstorm.com/case-study-dmm/).
5253
* Jon Middleton ([@jjm](https://github.com/jjm)) - StackStorm Exchange, Core, Discussions.

contrib/linux/actions/dig.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
# limitations under the License.
1717

1818
import errno
19+
import locale
1920
import subprocess
2021
import random
21-
import re
22+
import sys
2223

2324
from st2common.runners.base_action import Action
2425

@@ -34,26 +35,33 @@ def run(self, rand, count, nameserver, hostname, queryopts):
3435
nameserver = '@' + nameserver
3536
cmd_args.append(nameserver)
3637

37-
if re.search(',', queryopts):
38+
if isinstance(queryopts, str) and ',' in queryopts:
3839
opt_list = queryopts.split(',')
3940
else:
4041
opt_list.append(queryopts)
41-
for k, v in enumerate(opt_list):
42-
cmd_args.append('+' + v)
42+
43+
cmd_args.extend(['+' + option for option in opt_list])
4344

4445
cmd_args.append(hostname)
4546

4647
try:
47-
result_list = filter(None, subprocess.Popen(cmd_args,
48-
stderr=subprocess.PIPE,
49-
stdout=subprocess.PIPE)
50-
.communicate()[0]
51-
.split('\n'))
48+
raw_result = subprocess.Popen(cmd_args,
49+
stderr=subprocess.PIPE,
50+
stdout=subprocess.PIPE).communicate()[0]
51+
52+
if sys.version_info >= (3,):
53+
# This function might call getpreferred encoding unless we pass
54+
# do_setlocale=False.
55+
encoding = locale.getpreferredencoding(do_setlocale=False)
56+
result_list_str = raw_result.decode(encoding)
57+
else:
58+
result_list_str = str(raw_result)
59+
60+
result_list = list(filter(None, result_list_str.split('\n')))
5261

5362
# NOTE: Python3 supports the FileNotFoundError, the errono.ENOENT is for py2 compat
5463
# for Python3:
5564
# except FileNotFoundError as e:
56-
5765
except OSError as e:
5866
if e.errno == errno.ENOENT:
5967
return False, "Can't find dig installed in the path (usually /usr/bin/dig). If " \
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright 2020 The StackStorm Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
from __future__ import absolute_import
18+
from st2tests.base import BaseActionTestCase
19+
20+
from dig import DigAction
21+
22+
23+
class DigActionTestCase(BaseActionTestCase):
24+
action_cls = DigAction
25+
26+
def test_run_with_empty_hostname(self):
27+
action = self.get_action_instance()
28+
29+
# Use the defaults from dig.yaml
30+
result = action.run(rand=False, count=0, nameserver=None, hostname='', queryopts='short')
31+
self.assertIsInstance(result, list)
32+
self.assertEqual(len(result), 0)
33+
34+
def test_run_with_empty_queryopts(self):
35+
action = self.get_action_instance()
36+
37+
results = action.run(rand=False, count=0, nameserver=None, hostname='google.com',
38+
queryopts='')
39+
self.assertIsInstance(results, list)
40+
41+
for result in results:
42+
self.assertIsInstance(result, str)
43+
self.assertGreater(len(result), 0)
44+
45+
def test_run(self):
46+
action = self.get_action_instance()
47+
48+
results = action.run(rand=False, count=0, nameserver=None, hostname='google.com',
49+
queryopts='short')
50+
self.assertIsInstance(results, list)
51+
self.assertGreater(len(results), 0)
52+
53+
for result in results:
54+
self.assertIsInstance(result, str)
55+
self.assertGreater(len(result), 0)

0 commit comments

Comments
 (0)