From f2b44e3338b062b6f0996b129b17103546bb3b4b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 28 Jul 2015 08:17:42 -0700 Subject: [PATCH] rmeove duplicate timeout option from diag License: MIT Signed-off-by: Jeromy --- core/commands/diag.go | 3 +-- diagnostics/diag.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core/commands/diag.go b/core/commands/diag.go index 4d3a82b25..a1aa8a404 100644 --- a/core/commands/diag.go +++ b/core/commands/diag.go @@ -85,7 +85,6 @@ that consume the dot format to generate graphs of the network. }, Options: []cmds.Option{ - cmds.StringOption("timeout", "diagnostic timeout duration"), cmds.StringOption("vis", "output vis. one of: "+strings.Join(visFmts, ", ")), }, @@ -122,7 +121,7 @@ that consume the dot format to generate graphs of the network. timeout = t } - info, err := n.Diagnostics.GetDiagnostic(timeout) + info, err := n.Diagnostics.GetDiagnostic(req.Context(), timeout) if err != nil { res.SetError(err, cmds.ErrNormal) return diff --git a/diagnostics/diag.go b/diagnostics/diag.go index 937e5d30e..104cb5977 100644 --- a/diagnostics/diag.go +++ b/diagnostics/diag.go @@ -134,9 +134,9 @@ func newID() string { } // GetDiagnostic runs a diagnostics request across the entire network -func (d *Diagnostics) GetDiagnostic(timeout time.Duration) ([]*DiagInfo, error) { +func (d *Diagnostics) GetDiagnostic(ctx context.Context, timeout time.Duration) ([]*DiagInfo, error) { log.Debug("Getting diagnostic.") - ctx, cancel := context.WithTimeout(context.TODO(), timeout) + ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel() diagID := newID()