Skip to content

Commit 8075c49

Browse files
committed
Prevent broadcast-broadcast clash
1 parent a703c10 commit 8075c49

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

cylc/flow/broadcast_mgr.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,22 @@ def put_broadcast(
310310
if namespace not in self.linearized_ancestors:
311311
bad_namespaces.append(namespace)
312312
elif not bad_point:
313+
# Check broadcast against config:
313314
self.check_for_old_and_new_platform_settings(
314315
self.schd.config.get_config(
315316
['runtime', namespace]
316317
).copy(),
317318
namespace,
318319
coerced_setting,
319320
)
321+
# Check broadcast against existing broadcasts:
322+
self.check_for_old_and_new_platform_settings(
323+
self.broadcasts.get(point_string, {})
324+
.get(namespace, {})
325+
.copy(),
326+
namespace,
327+
coerced_setting,
328+
)
320329

321330
if namespace not in self.broadcasts[point_string]:
322331
self.broadcasts[point_string][namespace] = {}

tests/integration/test_broadcast_mgr.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"""Tests for Broadcast Manager."""
1818

1919

20-
async def test_reject_invalid_broadcast_is_remote_clash(
20+
async def test_reject_valid_broadcast_is_remote_clash_with_config(
2121
one_conf, flow, start, scheduler, log_filter
2222
):
2323
"""`put_broadcast` gracefully rejects invalid broadcast:
@@ -39,3 +39,31 @@ async def test_reject_invalid_broadcast_is_remote_clash(
3939
settings=[{'remote': {'host': 'bar'}}]
4040
)
4141
assert log_filter(contains='Cannot apply broadcast')
42+
43+
44+
async def test_reject_valid_broadcast_is_remote_clash_with_broadcast(
45+
one_conf, flow, start, scheduler, log_filter
46+
):
47+
"""`put_broadcast` gracefully rejects invalid broadcast:
48+
49+
Existing Broadcast = [task][remote]host = foo
50+
New Broadcast = [task]platform = bar
51+
52+
https://github.com/cylc/cylc-flow/pull/6711/files#r2033457964
53+
"""
54+
schd = scheduler(flow(one_conf))
55+
async with start(schd):
56+
bc_mgr = schd.broadcast_mgr
57+
bc_mgr.put_broadcast(
58+
point_strings=['1'],
59+
namespaces=['one'],
60+
settings=[{'remote': {'host': 'bar'}}]
61+
)
62+
# this should not be allowed, if it is the scheduler will crash
63+
# when unpaused:
64+
bc_mgr.put_broadcast(
65+
point_strings=['1'],
66+
namespaces=['one'],
67+
settings=[{'platform': 'foo'}]
68+
)
69+
assert log_filter(contains='Cannot apply broadcast')

0 commit comments

Comments
 (0)