@@ -2965,139 +2965,6 @@ async def test_worker_status_sync(s, a):
29652965 ]
29662966
29672967
2968- @gen_cluster (client = True )
2969- async def test_log_remove_worker (c , s , a , b ):
2970- # Computed task
2971- x = c .submit (inc , 1 , key = "x" , workers = a .address )
2972- await x
2973- ev = Event ()
2974- # Processing task
2975- y = c .submit (
2976- lambda ev : ev .wait (), ev , key = "y" , workers = a .address , allow_other_workers = True
2977- )
2978- await wait_for_state ("y" , "processing" , s )
2979- # Scattered task
2980- z = await c .scatter ({"z" : 3 }, workers = a .address )
2981-
2982- s ._broker .truncate ()
2983-
2984- with captured_logger ("distributed.scheduler" , level = logging .INFO ) as log :
2985- # Successful graceful shutdown
2986- await s .retire_workers ([a .address ], stimulus_id = "graceful" )
2987- # Refuse to retire gracefully as there's nowhere to put x and z
2988- await s .retire_workers ([b .address ], stimulus_id = "graceful_abort" )
2989- await asyncio .sleep (0.2 )
2990- # Ungraceful shutdown
2991- await s .remove_worker (b .address , stimulus_id = "ungraceful" )
2992- await asyncio .sleep (0.2 )
2993- await ev .set ()
2994-
2995- assert log .getvalue ().splitlines () == [
2996- # Successful graceful
2997- f"Retire worker addresses (stimulus_id='graceful') ['{ a .address } ']" ,
2998- f"Remove worker addr: { a .address } name: { a .name } (stimulus_id='graceful')" ,
2999- f"Retired worker '{ a .address } ' (stimulus_id='graceful')" ,
3000- # Aborted graceful
3001- f"Retire worker addresses (stimulus_id='graceful_abort') ['{ b .address } ']" ,
3002- f"Could not retire worker '{ b .address } ': unique data could not be "
3003- "moved to any other worker (stimulus_id='graceful_abort')" ,
3004- # Ungraceful
3005- f"Remove worker addr: { b .address } name: { b .name } (stimulus_id='ungraceful')" ,
3006- f"Removing worker '{ b .address } ' caused the cluster to lose already "
3007- "computed task(s), which will be recomputed elsewhere: {'x'} "
3008- "(stimulus_id='ungraceful')" ,
3009- f"Removing worker '{ b .address } ' caused the cluster to lose scattered "
3010- "data, which can't be recovered: {'z'} (stimulus_id='ungraceful')" ,
3011- "Lost all workers" ,
3012- ]
3013-
3014- events = {topic : [ev for _ , ev in evs ] for topic , evs in s .get_events ().items ()}
3015- for evs in events .values ():
3016- for ev in evs :
3017- if ev .get ("action" , None ) == "retire-workers" :
3018- for k in ("retired" , "could-not-retire" ):
3019- ev [k ] = {addr : "snip" for addr in ev [k ]}
3020- if "stimulus_id" in ev : # Strip timestamp
3021- ev ["stimulus_id" ] = ev ["stimulus_id" ].rsplit ("-" , 1 )[0 ]
3022-
3023- assert events == {
3024- a .address : [
3025- {
3026- "action" : "worker-status-change" ,
3027- "prev-status" : "running" ,
3028- "status" : "closing_gracefully" ,
3029- "stimulus_id" : "graceful" ,
3030- },
3031- {
3032- "action" : "remove-worker" ,
3033- "lost-computed-tasks" : set (),
3034- "lost-scattered-tasks" : set (),
3035- "processing-tasks" : {"y" },
3036- "expected" : True ,
3037- "stimulus_id" : "graceful" ,
3038- },
3039- {"action" : "retired" , "stimulus_id" : "graceful" },
3040- ],
3041- b .address : [
3042- {
3043- "action" : "worker-status-change" ,
3044- "prev-status" : "running" ,
3045- "status" : "closing_gracefully" ,
3046- "stimulus_id" : "graceful_abort" ,
3047- },
3048- {"action" : "could-not-retire" , "stimulus_id" : "graceful_abort" },
3049- {
3050- "action" : "worker-status-change" ,
3051- "prev-status" : "closing_gracefully" ,
3052- "status" : "running" ,
3053- "stimulus_id" : "worker-status-change" ,
3054- },
3055- {
3056- "action" : "remove-worker" ,
3057- "lost-computed-tasks" : {"x" },
3058- "lost-scattered-tasks" : {"z" },
3059- "processing-tasks" : {"y" },
3060- "expected" : False ,
3061- "stimulus_id" : "ungraceful" ,
3062- },
3063- {"action" : "closing-worker" , "reason" : "scheduler-remove-worker" },
3064- ],
3065- "all" : [
3066- {
3067- "action" : "remove-worker" ,
3068- "lost-computed-tasks" : set (),
3069- "lost-scattered-tasks" : set (),
3070- "processing-tasks" : {"y" },
3071- "expected" : True ,
3072- "stimulus_id" : "graceful" ,
3073- "worker" : a .address ,
3074- },
3075- {
3076- "action" : "retire-workers" ,
3077- "stimulus_id" : "graceful" ,
3078- "retired" : {a .address : "snip" },
3079- "could-not-retire" : {},
3080- },
3081- {
3082- "action" : "retire-workers" ,
3083- "stimulus_id" : "graceful_abort" ,
3084- "retired" : {},
3085- "could-not-retire" : {b .address : "snip" },
3086- },
3087- {
3088- "action" : "remove-worker" ,
3089- "lost-computed-tasks" : {"x" },
3090- "lost-scattered-tasks" : {"z" },
3091- "processing-tasks" : {"y" },
3092- "expected" : False ,
3093- "stimulus_id" : "ungraceful" ,
3094- "worker" : b .address ,
3095- },
3096- ],
3097- "worker-get-client" : [{"client" : c .id , "timeout" : 5 , "worker" : b .address }],
3098- }
3099-
3100-
31012968@gen_cluster (client = True )
31022969async def test_task_flight_compute_oserror (c , s , a , b ):
31032970 """If the remote worker dies while a task is in flight, the task may be
0 commit comments