Skip to content

Commit e4c6eb5

Browse files
authored
Merge pull request #2802 from StackStorm/1.5.1
Release branch for StackStorm v1.5.1
2 parents 49b938c + e7f13b2 commit e4c6eb5

File tree

24 files changed

+237
-61
lines changed

24 files changed

+237
-61
lines changed

CHANGELOG.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Changelog
22
=========
33

4+
1.5.1 - July 13, 2016
5+
---------------------
6+
7+
* Fix trigger registration when using st2-register-content script with ``--register-triggers``
8+
flag. (bug-fix)
9+
* Fix an issue with CronTimer sometimes not firing due to TriggerInstance creation failure.
10+
(bug-fix)
11+
Reported by Cody A. Ray
12+
* Add support for default values when a new pack configuration is used. Now if a default value
13+
is specified for a required config item in the config schema and a value for that item is not
14+
provided in the config, default value from config schema is used. (improvement)
15+
* Allow user to prevent execution parameter merging when re-running an execution by passing
16+
``?no_merge=true`` query parameter to the execution re-run API endpoint. (improvement)
17+
418
1.5.0 - June 24, 2016
519
---------------------
620

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
---
2-
payload:
3-
result: 10
4-
work: done
5-
type: st2.trigger
2+
name: sample_trigger
3+
description: Sample trigger

st2api/st2api/controllers/v1/actionexecutions.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from st2common.models.api.action import LiveActionAPI
3838
from st2common.models.api.action import LiveActionCreateAPI
3939
from st2common.models.api.base import jsexpose
40+
from st2common.models.api.base import cast_argument_value
4041
from st2common.models.api.execution import ActionExecutionAPI
4142
from st2common.persistence.liveaction import LiveAction
4243
from st2common.persistence.execution import ActionExecution
@@ -276,22 +277,25 @@ def validate(self):
276277
return self
277278

278279
@jsexpose(body_cls=ExecutionSpecificationAPI, status_code=http_client.CREATED)
279-
def post(self, spec, execution_id):
280+
def post(self, spec_api, execution_id, no_merge=False):
280281
"""
281282
Re-run the provided action execution optionally specifying override parameters.
282283
283284
Handles requests:
284285
285286
POST /executions/<id>/re_run
286287
"""
288+
no_merge = cast_argument_value(value_type=bool, value=no_merge)
287289
existing_execution = self._get_one(id=execution_id, exclude_fields=self.exclude_fields)
288290

289-
if spec.tasks and existing_execution.runner['name'] != 'mistral-v2':
291+
if spec_api.tasks and existing_execution.runner['name'] != 'mistral-v2':
290292
raise ValueError('Task option is only supported for Mistral workflows.')
291293

292294
# Merge in any parameters provided by the user
293-
new_parameters = copy.deepcopy(getattr(existing_execution, 'parameters', {}))
294-
new_parameters.update(spec.parameters)
295+
new_parameters = {}
296+
if not no_merge:
297+
new_parameters.update(getattr(existing_execution, 'parameters', {}))
298+
new_parameters.update(spec_api.parameters)
295299

296300
# Create object for the new execution
297301
action_ref = existing_execution.action['ref']
@@ -303,11 +307,11 @@ def post(self, spec, execution_id):
303307
}
304308
}
305309

306-
if spec.tasks:
307-
context['re-run']['tasks'] = spec.tasks
310+
if spec_api.tasks:
311+
context['re-run']['tasks'] = spec_api.tasks
308312

309-
if spec.reset:
310-
context['re-run']['reset'] = spec.reset
313+
if spec_api.reset:
314+
context['re-run']['reset'] = spec_api.reset
311315

312316
# Add trace to the new execution
313317
trace = trace_service.get_trace_db_by_action_execution(
@@ -319,7 +323,7 @@ def post(self, spec, execution_id):
319323
new_liveaction_api = LiveActionCreateAPI(action=action_ref,
320324
context=context,
321325
parameters=new_parameters,
322-
user=spec.user)
326+
user=spec_api.user)
323327

324328
return self._handle_schedule_execution(liveaction_api=new_liveaction_api)
325329

st2api/tests/unit/controllers/v1/test_base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ def test_wildcard_origin(self):
6565
self.assertEqual(response.status_int, 200)
6666
self.assertEqual(response.headers['Access-Control-Allow-Origin'],
6767
'*')
68+
69+
def test_valid_status_code_is_returned_on_invalid_path(self):
70+
# TypeError: get_all() takes exactly 1 argument (2 given)
71+
resp = self.app.get('/v1/executions/577f775b0640fd1451f2030b/re_run', expect_errors=True)
72+
self.assertEqual(resp.status_int, 404)
73+
74+
# get_one() takes exactly 2 arguments (4 given)
75+
resp = self.app.get('/v1/executions/577f775b0640fd1451f2030b/re_run/a/b',
76+
expect_errors=True)
77+
self.assertEqual(resp.status_int, 404)

st2client/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ pytz
66
pyyaml<4.0,>=3.11
77
requests<3.0,>=2.7.0
88
six==1.9.0
9+
argcomplete==1.4.1

st2client/st2client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
__version__ = '1.5.0'
16+
__version__ = '1.5.1'

st2common/st2common/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
__version__ = '1.5.0'
16+
__version__ = '1.5.1'

st2common/st2common/bootstrap/triggersregistrar.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
from st2common.constants.meta import ALLOWED_EXTS
2222
from st2common.bootstrap.base import ResourceRegistrar
2323
import st2common.content.utils as content_utils
24-
from st2common.models.api.trigger import TriggerTypeAPI
25-
from st2common.persistence.trigger import TriggerType
24+
from st2common.models.utils import sensor_type_utils
2625

2726
__all__ = [
2827
'TriggersRegistrar',
@@ -135,22 +134,9 @@ def _register_trigger_from_pack(self, pack, trigger):
135134
raise Exception('Model is in pack "%s" but field "pack" is different: %s' %
136135
(pack, pack_field))
137136

138-
trigger_api = TriggerTypeAPI(**content)
139-
trigger_model = TriggerTypeAPI.to_model(trigger_api)
140-
141-
trigger_types = TriggerType.query(pack=trigger_model.pack, name=trigger_model.name)
142-
if len(trigger_types) >= 1:
143-
trigger_type = trigger_types[0]
144-
LOG.debug('Found existing trigger id:%s with name:%s. Will update it.',
145-
trigger_type.id, trigger_type.name)
146-
trigger_model.id = trigger_type.id
147-
148-
try:
149-
trigger_model = TriggerType.add_or_update(trigger_model)
150-
except:
151-
LOG.exception('Failed creating trigger model for %s', trigger)
152-
153-
return trigger_model
137+
trigger_types = [content]
138+
result = sensor_type_utils.create_trigger_types(trigger_types=trigger_types)
139+
return result[0] if result else None
154140

155141

156142
def register_triggers(packs_base_paths=None, pack_dir=None, use_pack_cache=True,

st2common/st2common/models/db/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ def get_by_name(self, value):
169169
def get_by_id(self, value):
170170
return self.get(id=value, raise_exception=True)
171171

172+
def get_by_uid(self, value):
173+
return self.get(uid=value, raise_exception=True)
174+
172175
def get_by_ref(self, value):
173176
return self.get(ref=value, raise_exception=True)
174177

st2common/st2common/models/utils/action_param_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _merge_param_meta_values(action_meta=None, runner_meta=None):
4040
elif key in runner_meta_keys and key not in action_meta_keys:
4141
merged_meta[key] = runner_meta[key]
4242
else:
43-
if key in ['immutable', 'required']:
43+
if key in ['immutable']:
4444
merged_meta[key] = runner_meta.get(key, False) or action_meta.get(key, False)
4545
else:
4646
merged_meta[key] = action_meta.get(key)

0 commit comments

Comments
 (0)