[pave] Move ctx.Cancel() handler inside inner xfer loop.
This should prevent the situation where the target constantly reports as
busy and we never handle a SIGTERM so it is perpetually in a broken
state.
Example: https://chrome-swarming.appspot.com/bot?id=build357-a7--bless-candy-wool-poem
Change-Id: I7ee482d2400f97c96ca47287fec2ef1380d77070
diff --git a/botanist/boot.go b/botanist/boot.go
index e0cdd1a..8526cd5 100644
--- a/botanist/boot.go
+++ b/botanist/boot.go
@@ -269,15 +269,15 @@
// This behavior more closely aligns with that of the bootserver.
return retry.Retry(ctx, retry.WithMaxRetries(retry.NewConstantBackoff(time.Second), 20), func() error {
for _, f := range files {
- select {
- case <-ctx.Done():
- return nil
- default:
- }
// Attempt to send a file. If the server tells us we need to wait, then try
// again as long as it keeps telling us this. ErrShouldWait implies the server
// is still responding and will eventually be able to handle our request.
for {
+ select {
+ case <-ctx.Done():
+ return nil
+ default:
+ }
log.Printf("attempting to send %s...\n", f.name)
reader, err := t.Send(tftpAddr, f.name, f.size)
switch {