Skip to content

Commit 4fbdbee

Browse files
David MeuDavidMeu
authored andcommitted
Merge branch 'master' into adding_get_by_ref
2 parents 89da5c1 + 38012c9 commit 4fbdbee

File tree

10 files changed

+63
-8
lines changed

10 files changed

+63
-8
lines changed

CHANGELOG.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,21 @@ Added
1313

1414
Contributed by @DavidMeu
1515

16+
Fixed
17+
~~~~~
18+
19+
* Fix Type error for ``time_diff`` critera comparison. convert the timediff value as float to match
20+
``timedelta.total_seconds()`` return. #5462
21+
22+
Contributed by @blackstrip
23+
1624
Added
1725
~~~~~
1826

27+
* Enable setting ttl for MockDatastoreService. #5468
28+
29+
Contributed by @ytjohn
30+
1931
* Added st2 API and CLI command for actions clone operation.
2032

2133
API endpoint ``/api/v1/actions/{ref_or_id}/clone`` takes ``ref_or_id`` of source action.
@@ -39,6 +51,10 @@ Added
3951

4052
Contributed by @khushboobhatia01
4153

54+
* Added pysocks python package for SOCKS proxy support. #5460
55+
56+
Contributed by @kingsleyadam
57+
4258
Fixed
4359
~~~~~
4460

@@ -48,6 +64,10 @@ Fixed
4864

4965
* Fix ``st2-self-check`` script reporting falsey success when the nested workflows runs failed. #5487
5066

67+
* Use byte type lock name which is supported by all tooz drivers. #5529
68+
69+
Contributed by @khushboobhatia01
70+
5171
3.6.0 - October 29, 2021
5272
------------------------
5373

@@ -4215,4 +4235,4 @@ v0.5.1 - November 3rd, 2014
42154235
Added
42164236
~~~~~
42174237

4218-
* Initial public release
4238+
* Initial public release

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ check-python-packages-nightly:
269269
@echo ""
270270

271271
test -f $(VIRTUALENV_COMPONENTS_DIR)/bin/activate || $(PYTHON_VERSION) -m venv $(VIRTUALENV_COMPONENTS_DIR) --system-site-packages
272+
$(VIRTUALENV_COMPONENTS_DIR)/bin/pip install wheel
272273
@for component in $(COMPONENTS_WITHOUT_ST2TESTS); do \
273274
echo "==========================================================="; \
274275
echo "Checking component:" $$component; \

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pyinotify==0.9.6; platform_system=="Linux"
5050
pymongo==3.11.3
5151
pyparsing<3
5252
pyrabbit
53+
pysocks
5354
python-dateutil==2.8.1
5455
python-editor==1.0.4
5556
python-json-logger

st2client/in-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ cryptography
1818
orjson
1919
# needed by requests
2020
chardet
21+
# required for SOCKS proxy support (HTTP_PROXY, HTTPS_PROXY, NO_PROXY)
22+
pysocks

st2client/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jsonschema==2.6.0
1515
orjson==3.5.2
1616
prettytable==2.1.0
1717
prompt-toolkit==1.0.15
18+
pysocks
1819
python-dateutil==2.8.1
1920
python-editor==1.0.4
2021
pytz==2021.1

st2common/st2common/operators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def _timediff(diff_target, period_seconds, operator):
314314
# Note: date_utils.parse uses dateutil.parse which is way more flexible then strptime and
315315
# supports many date formats
316316
diff_target_utc = date_utils.parse(diff_target)
317-
return operator((utc_now - diff_target_utc).total_seconds(), period_seconds)
317+
return operator((utc_now - diff_target_utc).total_seconds(), float(period_seconds))
318318

319319

320320
def timediff_lt(value, criteria_pattern):

st2common/st2common/services/executions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def update_execution(liveaction_db, publish=True, set_result_size=False):
196196
"""
197197
execution = ActionExecution.get(liveaction__id=str(liveaction_db.id))
198198

199-
with coordination.get_coordinator().get_lock(str(liveaction_db.id)):
199+
with coordination.get_coordinator().get_lock(str(liveaction_db.id).encode()):
200200
# Skip execution object update when action is already in completed state.
201201
if execution.status in action_constants.LIVEACTION_COMPLETED_STATES:
202202
LOG.debug(

st2common/st2common/services/workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ def handle_action_execution_completion(ac_ex_db):
938938
task_ex_id = ac_ex_db.context["orquesta"]["task_execution_id"]
939939

940940
# Acquire lock before write operations.
941-
with coord_svc.get_coordinator(start_heart=True).get_lock(wf_ex_id):
941+
with coord_svc.get_coordinator(start_heart=True).get_lock(str(wf_ex_id).encode()):
942942
# Get execution records for logging purposes.
943943
wf_ex_db = wf_db_access.WorkflowExecution.get_by_id(wf_ex_id)
944944
task_ex_db = wf_db_access.TaskExecution.get_by_id(task_ex_id)

st2common/tests/unit/test_operators.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,20 @@ def test_timediff_lt_fail(self):
943943
"Passed test_timediff_lt with None as criteria_pattern.",
944944
)
945945

946+
def test_timediff_lt_webui_value(self):
947+
op = operators.get_operator("timediff_lt")
948+
self.assertTrue(
949+
op(date_utils.get_datetime_utc_now().isoformat(), "10"),
950+
"Failed test_timediff_lt_webui_value.",
951+
)
952+
953+
def test_timediff_lt_webui_value_fail(self):
954+
op = operators.get_operator("timediff_lt")
955+
self.assertFalse(
956+
op("2014-07-01T00:01:01.000000", "10"),
957+
"Passed test_timediff_lt_webui_value.",
958+
)
959+
946960
def test_timediff_gt(self):
947961
op = operators.get_operator("timediff_gt")
948962
self.assertTrue(op("2014-07-01T00:01:01.000000", 1), "Failed test_timediff_gt.")
@@ -958,6 +972,20 @@ def test_timediff_gt_fail(self):
958972
"Passed test_timediff_gt with None as criteria_pattern.",
959973
)
960974

975+
def test_timediff_gt_webui_value(self):
976+
op = operators.get_operator("timediff_gt")
977+
self.assertTrue(
978+
op("2014-07-01T00:01:01.000000", "1"),
979+
"Failed test_timediff_gt_webui_value.",
980+
)
981+
982+
def test_timediff_gt_webui_value_fail(self):
983+
op = operators.get_operator("timediff_gt")
984+
self.assertFalse(
985+
op(date_utils.get_datetime_utc_now().isoformat(), "10"),
986+
"Passed test_timediff_gt_webui_value.",
987+
)
988+
961989
def test_exists(self):
962990
op = operators.get_operator("exists")
963991
self.assertTrue(op(False, None), "Should return True")

st2tests/st2tests/mocks/datastore.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, logger, pack_name, class_name, api_username=None):
3434
self._pack_name = pack_name
3535
self._class_name = class_name
3636
self._username = api_username or "admin"
37+
self._logger = logger
3738

3839
# Holds mock KeyValuePair objects
3940
# Key is a KeyValuePair name and value is the KeyValuePair object
@@ -96,17 +97,18 @@ def set_value(
9697
"""
9798
Store a value in a dictionary which is local to this class.
9899
"""
99-
if ttl:
100-
raise ValueError(
101-
'MockDatastoreService.set_value doesn\'t support "ttl" argument'
102-
)
103100

104101
name = self._get_full_key_name(name=name, local=local)
105102

106103
instance = KeyValuePair()
107104
instance.id = name
108105
instance.name = name
109106
instance.value = value
107+
if ttl:
108+
self._logger.warning(
109+
"MockDatastoreService is not able to expire keys based on ttl."
110+
)
111+
instance.ttl = ttl
110112

111113
self._datastore_items[name] = instance
112114
return True

0 commit comments

Comments
 (0)