Skip to content

Commit b248d54

Browse files
committed
Add --stream-logs flag to run-errand command
This will use SCP to copy a specific log file (/var/vcap/sys/log/ERRAND-NAME/errand.log) from the running errand instances and print the new lines on a given interval (default: 30s). In the case of multiple-instance errands, their outputs will be interleaved when streaming. The standard errand Stdout summary will be suppressed when streaming. ai-assisted=yes
1 parent 67eaebd commit b248d54

File tree

12 files changed

+1248
-18
lines changed

12 files changed

+1248
-18
lines changed

cmd/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ func (c Cmd) Execute() (cmdErr error) {
226226
case *RunErrandOpts:
227227
director, deployment := c.directorAndDeployment()
228228
downloader := NewUIDownloader(director, deps.Time, deps.FS, deps.UI)
229-
return NewRunErrandCmd(deployment, downloader, deps.UI).Run(*opts)
229+
quietSCPRunner := boshssh.NewQuietSCPRunner(deps.CmdRunner, deps.FS, deps.Logger)
230+
return NewRunErrandCmd(deployment, downloader, deps.UI, quietSCPRunner, deps.FS, deps.Logger).Run(*opts)
230231

231232
case *AttachDiskOpts:
232233
return NewAttachDiskCmd(c.deployment()).Run(*opts)

cmd/factory.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ func (f Factory) New(args []string) (Cmd, error) {
9494
return nil
9595
}
9696

97-
boshOpts.SSH.GatewayFlags.UUIDGen = f.deps.UUIDGen //nolint:staticcheck
98-
boshOpts.SCP.GatewayFlags.UUIDGen = f.deps.UUIDGen //nolint:staticcheck
99-
boshOpts.Logs.GatewayFlags.UUIDGen = f.deps.UUIDGen //nolint:staticcheck
100-
boshOpts.Pcap.GatewayFlags.UUIDGen = f.deps.UUIDGen //nolint:staticcheck
97+
boshOpts.SSH.GatewayFlags.UUIDGen = f.deps.UUIDGen //nolint:staticcheck
98+
boshOpts.SCP.GatewayFlags.UUIDGen = f.deps.UUIDGen //nolint:staticcheck
99+
boshOpts.Logs.GatewayFlags.UUIDGen = f.deps.UUIDGen //nolint:staticcheck
100+
boshOpts.Pcap.GatewayFlags.UUIDGen = f.deps.UUIDGen //nolint:staticcheck
101+
boshOpts.RunErrand.GatewayFlags.UUIDGen = f.deps.UUIDGen //nolint:staticcheck
101102

102103
helpText := bytes.NewBufferString("")
103104
parser.WriteHelp(helpText)

cmd/opts/opts.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ type RunErrandOpts struct {
716716
DownloadLogs bool `long:"download-logs" description:"Download logs"`
717717
LogsDirectory DirOrCWDArg `long:"logs-dir" description:"Destination directory for logs" default:"."`
718718

719+
StreamLogs *int `long:"stream-logs" description:"Stream errand logs (only /var/vcap/sys/log/ERRAND-NAME/errand.log) from the instance during execution. Optionally specify poll interval in seconds" optional:"true" optional-value:"30"`
720+
721+
GatewayFlags
722+
719723
cmd
720724
}
721725

0 commit comments

Comments
 (0)