Jinja not rendered in rule trigger parameters
Open
@lakshmi-kannan is already working on this.
Since Oct 20, 2017.
complexity:medium
stale
status:under discussion
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
I have a rule that i'm trying to define using a cron timer with values from the key/value store.
---
name: full_backup_cron
pack: backups
description: "Executes a full backup on a cron schedule."
enabled: true
trigger:
type: "core.st2.CronTimer"
# http://apscheduler.readthedocs.io/en/3.0/modules/triggers/cron.html#api
parameters:
timezone: "{{ st2kv.system.backups.full_backup_cron.timezone }}"
day_of_week: "{{ st2kv.system.backups.full_backup_cron.day_of_week }}"
hour: "{{ st2kv.system.backups.full_backup_cron.hour }}"
minute: "{{ st2kv.system.backups.full_backup_cron.minute }}"
second: "{{ st2kv.system.backups.full_backup_cron.second }}"
action:
ref: "backups.full_backup"
When i try to register the rule i get the following error in st2api logs.
2017-08-16 21:28:18,008 83527792 AUDIT auth [-] Token with id "59946e2aa814c0066070ade8" is validated.
2017-08-16 21:28:18,020 83527792 ERROR router [-] Failed to call controller function "put" for operation "st2api.controllers.v1.rules:rule_controller.put": '{{ st2kv.system.backups.full_backup_cron.timezone }}'
Traceback (most recent call last):
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/router.py", line 426, in __call__
resp = func(**kw)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2api/controllers/v1/rules.py", line 145, in put
rule_db = RuleAPI.to_model(rule)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/models/api/rule.py", line 238, in to_model
parameters=parameters)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/validators/api/reactor.py", line 106, in validate_trigger_parameters
CronTrigger(**parameters)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/apscheduler/triggers/cron/__init__.py", line 50, in __init__
self.timezone = astimezone(timezone)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/apscheduler/util.py", line 78, in astimezone
return timezone(obj)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/pytz/__init__.py", line 181, in timezone
raise UnknownTimeZoneError(zone)
UnknownTimeZoneError: '{{ st2kv.system.backups.full_backup_cron.timezone }}'
2017-08-16 21:28:18,020 83527792 ERROR error_handling [-] API call failed: '{{ st2kv.system.backups.full_backup_cron.timezone }}'
Traceback (most recent call last):
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/middleware/error_handling.py", line 46, in __call__
return self.app(environ, start_response)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/router.py", line 472, in as_wsgi
resp = self(req)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/router.py", line 430, in __call__
raise e
UnknownTimeZoneError: '{{ st2kv.system.backups.full_backup_cron.timezone }}' (_exception_data={},_exception_class='UnknownTimeZoneError',_exception_message="'{{ st2kv.system.backups.full_backup_cron.timezone }}'")
2017-08-16 21:28:18,021 83527792 INFO logging [-] b1a61d2e-ad0c-4776-b680-dab9240ba8d0 - 500 46 14.663ms (content_length=46,request_id='b1a61d2e-ad0c-4776-b680-dab9240ba8d0',runtime=14.663,remote_addr='127.0.0.1',status=500,method='PUT',path='/v1/rules/5994ea75a814c02ce9813285')
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.