Skip to content

Commit

Permalink
Make message when intercept handler container is ready configurable
Browse files Browse the repository at this point in the history
This message may vary depending on what the container is doing. If it
started a debugger, then the message should state that we're waiting
for a debugger frontend to attach. If not, the message should probably
be "type <ctrl>-C to exit...".

Signed-off-by: Thomas Hallgren <thomas@datawire.io>
  • Loading branch information
thallgren committed May 5, 2024
1 parent 2b49eb6 commit 6fec109
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/client/cli/intercept/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Command struct {
Mechanism string // --mechanism tcp
MechanismArgs []string
ExtendedInfo []byte
WaitMessage string // Message printed when a containerized intercept handler is started and waiting for an interrupt
FormattedOutput bool
DetailedOutput bool
Silent bool
Expand Down
9 changes: 7 additions & 2 deletions pkg/client/cli/intercept/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,16 @@ func (s *state) create(ctx context.Context) (acquired bool, err error) {
}

func (s *state) leave(ctx context.Context) error {
r, err := daemon.GetUserClient(ctx).RemoveIntercept(ctx, &manager.RemoveInterceptRequest2{Name: strings.TrimSpace(s.Name())})
n := strings.TrimSpace(s.Name())
dlog.Debugf(ctx, "Leaving intercept %s", n)
r, err := daemon.GetUserClient(ctx).RemoveIntercept(ctx, &manager.RemoveInterceptRequest2{Name: n})
if err != nil && grpcStatus.Code(err) == grpcCodes.Canceled {
// Deactivation was caused by a disconnect
err = nil
}
if err != nil {
dlog.Errorf(ctx, "Leaving intercept ended with error %v", err)
}
return Result(r, err)
}

Expand Down Expand Up @@ -383,7 +388,7 @@ func (s *state) runCommand(ctx context.Context) error {
if dr.err == nil {
dr.err = s.addInterceptorToDaemon(ctx, dr.cmd, dr.name)
spin.Message("started")
spin.DoneMsg("type <ctrl>-C to end...")
spin.DoneMsg(s.WaitMessage)
} else if spin != nil {
_ = spin.Error(dr.err)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/client/cli/internal/apiimpl/intercept.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ func toInterceptCmd(rq *api.InterceptRequest, ih api.InterceptHandler) *intercep
cmd.Cmdline = append(cmd.Cmdline, ih.Arguments...)
cmd.Mount = strconv.FormatBool(ih.Mount)
cmd.MountSet = true
cmd.WaitMessage = "type <ctrl>-C to end..."
case api.DockerBuildInterceptHandler:
cmd.DockerRun = true
if ih.Debug {
cmd.DockerDebug = ih.Context
cmd.WaitMessage = "waiting for a debugger frontend to attach..."
} else {
cmd.DockerBuild = ih.Context
cmd.WaitMessage = "type <ctrl>-C to end..."
}
cmd.DockerBuildOptions = ih.BuildOptions
cmd.Cmdline = appendOptions(ih.Options, cmd.Cmdline)
Expand Down

0 comments on commit 6fec109

Please sign in to comment.