Skip to content

Commit

Permalink
Merge branch 'master' into config-changes-3
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Nov 12, 2020
2 parents 4feb4db + 31d79e1 commit d2a72ca
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 73 deletions.
3 changes: 0 additions & 3 deletions cylc/flow/cfgspec/globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,7 @@
Global site/user defaults for
:cylc:conf:`flow.cylc[runtime][<namespace>][mail]`.
'''):

Conf('from', VDR.V_STRING)
Conf('retry delays', VDR.V_INTERVAL_LIST)
Conf('smtp', VDR.V_STRING)
Conf('to', VDR.V_STRING)

# suite
Expand Down
33 changes: 19 additions & 14 deletions cylc/flow/cfgspec/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@
``mail footer = see http://myhost/%(owner)s/notes/%(suite)s``
''')
Conf('smtp', VDR.V_STRING, desc='''
Specify the SMTP server for sending suite email notifications.
''')
Conf('to', VDR.V_STRING, desc='''
A string containing a list of addresses which can be accepted
Expand Down Expand Up @@ -1156,13 +1152,6 @@
Specify an alternate ``from:`` email address for event
notifications.
''')
Conf('smtp', VDR.V_STRING, desc='''
Specify the SMTP server for sending email notifications.
Example:
``smtp.yourorg``
''')
Conf('to', VDR.V_STRING, desc='''
A list of email addresses to send task event
notifications. The list can be anything accepted by the
Expand Down Expand Up @@ -1378,19 +1367,35 @@ def upg(cfg, descr):
['cylc', 'mail', 'task event batch interval']
)
# Whole workflow task mail settings
for mail_setting in ['to', 'from', 'smtp', 'footer']:
for mail_setting in ['to', 'from', 'footer']:
u.deprecate(
'8.0.0',
['cylc', f'mail {mail_setting}'],
['cylc', 'events', f'mail {mail_setting}'],
['cylc', 'mail', mail_setting]
)
# Task mail settings in [runtime][TASK]
for mail_setting in ['to', 'from', 'smtp']:
for mail_setting in ['to', 'from']:
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'events', f'mail {mail_setting}'],
['runtime', '__MANY__', 'mail', mail_setting]
)
u.deprecate(
'8.0.0',
['cylc', 'events', 'mail smtp'],
None, # This is really a .obsolete(), just with a custom message
cvtr=converter(lambda x: x, (
'DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" '
'instead'))
)
u.deprecate(
'8.0.0',
['runtime', '__MANY__', 'events', 'mail smtp'],
None,
cvtr=converter(lambda x: x, (
'DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" '
'instead'))
)
u.deprecate(
'8.0.0',
['scheduling', 'max active cycle points'],
Expand Down
4 changes: 1 addition & 3 deletions cylc/flow/parsec/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,12 @@ def upgrade(self):
msg = self.show_keys(upg['old'])
if upg['new']:
msg += ' -> ' + self.show_keys(upg['new'])
else:
upg['new'] = upg['old']
msg += " - " + upg['cvt'].describe()
if not upg['silent']:
warnings.setdefault(vn, [])
warnings[vn].append(msg)
self.del_item(upg['old'])
if upg['cvt'].describe() != "DELETED (OBSOLETE)":
if upg['new']:
# check self.cfg does not already contain a
# non-deprecated item matching upg['new']:
try:
Expand Down
5 changes: 3 additions & 2 deletions cylc/flow/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ async def configure(self):
self.config.get_linearized_ancestors())
self.task_events_mgr.mail_interval = self.cylc_config['mail'][
"task event batch interval"]
self.task_events_mgr.mail_footer = self._get_events_conf(
"footer")
self.task_events_mgr.mail_smtp = self._get_events_conf("smtp")
self.task_events_mgr.mail_footer = self._get_events_conf("footer")
self.task_events_mgr.suite_url = self.config.cfg['meta']['URL']
self.task_events_mgr.suite_cfg = self.config.cfg
if self.options.genref:
Expand Down Expand Up @@ -973,6 +973,7 @@ def command_reload_suite(self):
self.pool.set_do_reload(self.config)
self.task_events_mgr.mail_interval = self.cylc_config['mail'][
'task event batch interval']
self.task_events_mgr.mail_smtp = self._get_events_conf("smtp")
self.task_events_mgr.mail_footer = self._get_events_conf("footer")

# Log tasks that have been added by the reload, removed tasks are
Expand Down
15 changes: 7 additions & 8 deletions cylc/flow/task_events_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

TaskEventMailContext = namedtuple(
"TaskEventMailContext",
["key", "ctx_type", "mail_from", "mail_to", "mail_smtp"])
["key", "ctx_type", "mail_from", "mail_to"])


TaskJobLogsRetrieveContext = namedtuple(
Expand Down Expand Up @@ -187,6 +187,7 @@ def __init__(self, suite, proc_pool, suite_db_mgr,
self.xtrigger_mgr = xtrigger_mgr
self.job_pool = job_pool
self.mail_interval = 0.0
self.mail_smtp = None
self.mail_footer = None
self.next_mail_time = None
self.event_timers = {}
Expand Down Expand Up @@ -646,9 +647,8 @@ def _process_event_email(self, schd_ctx, ctx, id_keys):
"suite": schd_ctx.suite}
# SMTP server
env = dict(os.environ)
mail_smtp = ctx.mail_smtp
if mail_smtp:
env["smtp"] = mail_smtp
if self.mail_smtp:
env["smtp"] = self.mail_smtp
self.proc_pool.put_command(
SubProcContext(
ctx, cmd, env=env, stdin_str=stdin_str, id_keys=id_keys,
Expand Down Expand Up @@ -1035,14 +1035,13 @@ def _setup_event_mail(self, itask, event):
"from",
"notifications@" + get_host(),
),
self._get_events_conf(itask, "to", get_user()), # mail_to
self._get_events_conf(itask, "smtp"), # mail_smtp
),
self._get_events_conf(itask, "to", get_user()) # mail_to
)
)

def _setup_custom_event_handlers(self, itask, event, message):
"""Set up custom task event handlers."""
handlers = self._get_events_conf(itask, event + ' handler')
handlers = self._get_events_conf(itask, f'{event} handler')
if (handlers is None and
event in self._get_events_conf(itask, 'handler events', [])):
handlers = self._get_events_conf(itask, 'handlers')
Expand Down
13 changes: 0 additions & 13 deletions tests/functional/cylc-get-config/00-simple/section2.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -142,7 +141,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -221,7 +219,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -302,7 +299,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -382,7 +378,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -462,7 +457,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -542,7 +536,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -622,7 +615,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -702,7 +694,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -782,7 +773,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -862,7 +852,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -942,7 +931,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down Expand Up @@ -1022,7 +1010,6 @@
custom handler =
[[[mail]]]
from =
smtp =
to =
[[[suite state polling]]]
user =
Expand Down
9 changes: 5 additions & 4 deletions tests/functional/deprecations/01-cylc8-basic/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
required run mode =
force run mode =
task event mail interval =
mail to =
mail from =
mail smtp =
mail footer =
disable automatic shutdown =
[[events]]
mail to =
mail from =
mail smtp =
mail footer =
[[reference test]]
allow task failures =
live mode suite timeout =
Expand Down
10 changes: 5 additions & 5 deletions tests/functional/deprecations/01-cylc8-basic/validation.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ WARNING - * (8.0.0) [runtime][foo, cat, dog][events][mail retry delays] - DELET
WARNING - * (8.0.0) [cylc][abort if any task fails] - DELETED (OBSOLETE)
WARNING - * (8.0.0) [cylc][disable automatic shutdown] - DELETED (OBSOLETE)
WARNING - * (8.0.0) [cylc][task event mail interval] -> [cylc][mail][task event batch interval] - value unchanged
WARNING - * (8.0.0) [cylc][mail to] -> [cylc][mail][to] - value unchanged
WARNING - * (8.0.0) [cylc][mail from] -> [cylc][mail][from] - value unchanged
WARNING - * (8.0.0) [cylc][mail smtp] -> [cylc][mail][smtp] - value unchanged
WARNING - * (8.0.0) [cylc][mail footer] -> [cylc][mail][footer] - value unchanged
WARNING - * (8.0.0) [cylc][events][mail to] -> [cylc][mail][to] - value unchanged
WARNING - * (8.0.0) [cylc][events][mail from] -> [cylc][mail][from] - value unchanged
WARNING - * (8.0.0) [cylc][events][mail footer] -> [cylc][mail][footer] - value unchanged
WARNING - * (8.0.0) [runtime][foo, cat, dog][events][mail to] -> [runtime][foo, cat, dog][mail][to] - value unchanged
WARNING - * (8.0.0) [runtime][foo, cat, dog][events][mail from] -> [runtime][foo, cat, dog][mail][from] - value unchanged
WARNING - * (8.0.0) [runtime][foo, cat, dog][events][mail smtp] -> [runtime][foo, cat, dog][mail][smtp] - value unchanged
WARNING - * (8.0.0) [cylc][events][mail smtp] - DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" instead
WARNING - * (8.0.0) [runtime][foo, cat, dog][events][mail smtp] - DELETED (OBSOLETE) - use "global.cylc[scheduler][mail]smtp" instead
WARNING - * (8.0.0) [scheduling][max active cycle points] -> [scheduling][runahead limit] - "n" -> "Pn"
WARNING - * (8.0.0) [cylc] -> [scheduler] - value unchanged
10 changes: 7 additions & 3 deletions tests/functional/events/09-task-event-mail.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ if [[ "${TEST_NAME_BASE}" == *-globalcfg ]]; then
[scheduler]
[[mail]]
footer = see: http://localhost/stuff/%(owner)s/%(suite)s/
smtp = ${TEST_SMTPD_HOST}
[task events]
mail events = failed, retry, succeeded
[task mail]
smtp = ${TEST_SMTPD_HOST}"
"
OPT_SET='-s GLOBALCFG=True'
else
OPT_SET="-s MAIL_SMTP=${TEST_SMTPD_HOST}"
create_test_global_config "
[scheduler]
[[mail]]
smtp = ${TEST_SMTPD_HOST}
"
fi

install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/events/09-task-event-mail/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@
{% if GLOBALCFG is not defined %}
[[[events]]]
mail events = failed, retry, succeeded
[[[mail]]]
smtp = {{MAIL_SMTP}}
{% endif %}{# not GLOBALCFG is not defined #}
6 changes: 5 additions & 1 deletion tests/functional/events/18-suite-event-mail.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ if [[ "${TEST_NAME_BASE}" == *-globalcfg ]]; then
smtp = ${TEST_SMTPD_HOST}"
OPT_SET='-s GLOBALCFG=True'
else
OPT_SET="-s MAIL_SMTP=${TEST_SMTPD_HOST}"
create_test_global_config "
[scheduler]
[[mail]]
smtp = ${TEST_SMTPD_HOST}
"
fi

install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
Expand Down
1 change: 0 additions & 1 deletion tests/functional/events/18-suite-event-mail/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{% if GLOBALCFG is not defined %}
[[mail]]
footer = see: http://localhost/stuff/%(owner)s/%(suite)s/
smtp = {{MAIL_SMTP}}
[[events]]
mail events = startup, shutdown
{% endif %}{# not GLOBALCFG is not defined #}
Expand Down
11 changes: 8 additions & 3 deletions tests/functional/events/29-task-event-mail-1.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ if ! command -v mail 2>'/dev/null'; then
skip_all '"mail" command not available'
fi
set_test_number 4

mock_smtpd_init
OPT_SET="-s MAIL_SMTP=${TEST_SMTPD_HOST}"
create_test_global_config "
[scheduler]
[[mail]]
smtp = ${TEST_SMTPD_HOST}
"

install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
# shellcheck disable=SC2086
run_ok "${TEST_NAME_BASE}-validate" \
cylc validate ${OPT_SET} "${SUITE_NAME}"
cylc validate "$SUITE_NAME"
# shellcheck disable=SC2086
suite_run_ok "${TEST_NAME_BASE}-run" \
cylc run --reference-test --debug --no-detach ${OPT_SET} "${SUITE_NAME}"
cylc run --reference-test --debug --no-detach "$SUITE_NAME"

contains_ok "${TEST_SMTPD_LOG}" <<__LOG__
b'retry: 1/t1/01'
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/events/29-task-event-mail-1/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@
execution retry delays = PT1S
[[[events]]]
mail events = failed, retry
[[[mail]]]
smtp = {{MAIL_SMTP}}
10 changes: 7 additions & 3 deletions tests/functional/events/30-task-event-mail-2.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ if [[ "${TEST_NAME_BASE}" == *-globalcfg ]]; then
[scheduler]
[[mail]]
footer = see: http://localhost/stuff/%(owner)s/%(suite)s/
smtp = ${TEST_SMTPD_HOST}
[task events]
mail events = failed, retry, succeeded
[task mail]
smtp = ${TEST_SMTPD_HOST}"
"
OPT_SET='-s GLOBALCFG=True'
else
OPT_SET="-s MAIL_SMTP=${TEST_SMTPD_HOST}"
create_test_global_config "
[scheduler]
[[mail]]
smtp = ${TEST_SMTPD_HOST}
"
fi

install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
Expand Down
Loading

0 comments on commit d2a72ca

Please sign in to comment.