From 253dbaa42c6bc0a6c0ea75dd8906e21473fb4e61 Mon Sep 17 00:00:00 2001 From: Lorenzo Fontana Date: Sun, 25 Nov 2018 15:25:26 +0100 Subject: [PATCH] fix(attach): set terminal size only if it is present Signed-off-by: Lorenzo Fontana --- pkg/attacher/attach.go | 17 ++++++++++------- pkg/cmd/delete.go | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pkg/attacher/attach.go b/pkg/attacher/attach.go index 9c35a5df..43d48988 100644 --- a/pkg/attacher/attach.go +++ b/pkg/attacher/attach.go @@ -54,9 +54,9 @@ func (a *Attacher) AttachJob(traceJobID types.UID, namespace string) { func (a *Attacher) Attach(selector, namespace string) { go wait.ExponentialBackoff(wait.Backoff{ Duration: time.Second * 1, - Factor: 2, - Jitter: 0, - Steps: 10, + Factor: 0.01, + Jitter: 0.0, + Steps: 100, }, func() (bool, error) { pl, err := a.CoreV1Client.Pods(namespace).List(metav1.ListOptions{ LabelSelector: selector, @@ -133,11 +133,14 @@ func (a attach) defaultAttachFunc() func() error { // since the TTY is always in raw mode when attaching do a fake resize // of the screen so that it will be redrawn during attach and detach tsize := a.tty.GetSize() - tsizeinc := *tsize - tsizeinc.Height++ - tsizeinc.Width++ + var terminalSizeQueue remotecommand.TerminalSizeQueue + if tsize != nil { + tsizeinc := *tsize + tsizeinc.Height++ + tsizeinc.Width++ + terminalSizeQueue = a.tty.MonitorSize(&tsizeinc, tsize) + } - terminalSizeQueue := a.tty.MonitorSize(&tsizeinc, tsize) return att.Attach("POST", req.URL(), a.config, a.tty.In, a.tty.Out, nil, a.tty.Raw, terminalSizeQueue) } } diff --git a/pkg/cmd/delete.go b/pkg/cmd/delete.go index dc61cf72..5c1da89d 100644 --- a/pkg/cmd/delete.go +++ b/pkg/cmd/delete.go @@ -125,6 +125,9 @@ func (o *DeleteOptions) Complete(factory factory.Factory, cmd *cobra.Command, ar return err } + if o.traceID == nil && o.traceName == nil && o.all == false { + return fmt.Errorf("when no trace id or trace name are specified you must specify --all=true to delete all the traces") + } return nil }