summaryrefslogtreecommitdiff
path: root/internal/clients/maprclient.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-03 17:09:18 +0200
committerPaul Buetow <pbuetow@mimecast.com>2026-02-03 17:09:34 +0200
commitd89b9e6760e2aadf9779faa6f23678f67c731e1e (patch)
tree5e5136a70a0fd2f315c4751c31629fd97de4ece9 /internal/clients/maprclient.go
parent4cbd559c5d66a82358029dc4b00f5174c94c8ebc (diff)
Add SSH agent key selection and fix MapReduce outfile handling
This commit adds two major features and fixes: 1. SSH Agent Key Selection: - Add --agentKeyIndex flag to select specific SSH agent key (0-based) - Solves "too many authentication failures" with multiple SSH keys - Default -1 uses all keys (backwards compatible) - Available in dtail, dcat, dgrep, dmap commands 2. MapReduce Outfile Fixes: - CSV files now written at every interval, not just on exit - Proper signal handling (SIGTERM/SIGINT) with graceful shutdown - 5-second grace period for cleanup before force exit - Fixes issue where outfile remained as .tmp during execution Usage: dtail --servers host --agentKeyIndex 0 --query '...' outfile results.csv This is particularly useful with YubiKey/hardware tokens where many keys are loaded in the SSH agent, and for monitoring MapReduce results in real-time as they're computed. Co-authored-by: Cursor <cursoragent@cursor.com>
Diffstat (limited to 'internal/clients/maprclient.go')
-rw-r--r--internal/clients/maprclient.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/clients/maprclient.go b/internal/clients/maprclient.go
index 226f76c..cfbffee 100644
--- a/internal/clients/maprclient.go
+++ b/internal/clients/maprclient.go
@@ -99,9 +99,12 @@ func (c *MaprClient) Start(ctx context.Context, statsCh <-chan string) (status i
go c.periodicReportResults(ctx)
status = c.baseClient.Start(ctx, statsCh)
+
+ // Always write final result for cumulative mode (includes outfile case)
if c.cumulative {
- dlog.Client.Debug("Received final mapreduce result")
+ dlog.Client.Debug("Writing final mapreduce result")
c.reportResults(true)
+ dlog.Client.Debug("Final result written")
}
return
@@ -210,13 +213,16 @@ func (c *MaprClient) printResults() {
}
func (c *MaprClient) writeResultsToOutfile(finalResult bool) {
+ dlog.Client.Debug("writeResultsToOutfile called", "finalResult", finalResult, "cumulative", c.cumulative)
if c.cumulative {
if err := c.globalGroup.WriteResult(c.query, finalResult); err != nil {
dlog.Client.FatalPanic(err)
}
+ dlog.Client.Debug("WriteResult completed for cumulative mode")
return
}
if err := c.globalGroup.SwapOut().WriteResult(c.query, true); err != nil {
dlog.Client.FatalPanic(err)
}
+ dlog.Client.Debug("WriteResult completed for non-cumulative mode")
}