diff --git a/changelog/66249.fixed.md b/changelog/66249.fixed.md new file mode 100644 index 00000000000..dac7b563a49 --- /dev/null +++ b/changelog/66249.fixed.md @@ -0,0 +1 @@ +Fix batch mode hang indefinitely in some scenarios diff --git a/salt/cli/batch.py b/salt/cli/batch.py index 2e43b0ee22b..3a648c02b86 100644 --- a/salt/cli/batch.py +++ b/salt/cli/batch.py @@ -83,7 +83,14 @@ class Batch: ) break if m is not None: - fret.add(m) + if "failed" in ret[m] and ret[m]["failed"] is True: + log.debug( + "minion '%s' failed test.ping - will be returned as a down minion", + m, + ) + else: + fret.add(m) + return (list(fret), ping_gen, nret.difference(fret)) def get_bnum(self): @@ -292,11 +299,12 @@ class Batch: # We already know some minions didn't respond to the ping, so inform # inform user attempt to run a job failed salt.utils.stringutils.print_cli( - "Minion '%s' failed to respond to job sent", minion + f"Minion '{minion}' failed to respond to job sent" ) if self.opts.get("failhard"): failhard = True + ret[minion] = data else: # If we are executing multiple modules with the same cmd, # We use the highest retcode.