diff --git a/pkg/cmd/clusterinfo/clusterinfo_dump.go b/pkg/cmd/clusterinfo/clusterinfo_dump.go index 4c0e28220..cfe5e8158 100644 --- a/pkg/cmd/clusterinfo/clusterinfo_dump.go +++ b/pkg/cmd/clusterinfo/clusterinfo_dump.go @@ -17,6 +17,7 @@ limitations under the License. package clusterinfo import ( + "context" "fmt" "io" "os" @@ -263,7 +264,7 @@ func (o *ClusterInfoDumpOptions) Run() error { } for _, request := range requests { - data, err := request.DoRaw() + data, err := request.DoRaw(context.TODO()) if err != nil { // Print error and return. writer.Write([]byte(fmt.Sprintf("Request log error: %s\n", err.Error()))) diff --git a/pkg/cmd/logs/logs.go b/pkg/cmd/logs/logs.go index 2ec7ffa77..3953a396a 100644 --- a/pkg/cmd/logs/logs.go +++ b/pkg/cmd/logs/logs.go @@ -18,6 +18,7 @@ package logs import ( "bufio" + "context" "errors" "fmt" "io" @@ -404,7 +405,7 @@ func (o LogsOptions) addPrefixIfNeeded(ref corev1.ObjectReference, writer io.Wri // Because the function is defined to read from request until io.EOF, it does // not treat an io.EOF as an error to be reported. func DefaultConsumeRequest(request rest.ResponseWrapper, out io.Writer) error { - readCloser, err := request.Stream() + readCloser, err := request.Stream(context.TODO()) if err != nil { return err } diff --git a/pkg/cmd/logs/logs_test.go b/pkg/cmd/logs/logs_test.go index cab646de5..93cd13cde 100644 --- a/pkg/cmd/logs/logs_test.go +++ b/pkg/cmd/logs/logs_test.go @@ -18,6 +18,7 @@ package logs import ( "bytes" + "context" "errors" "fmt" "io" @@ -667,12 +668,12 @@ type responseWrapperMock struct { err error } -func (r *responseWrapperMock) DoRaw() ([]byte, error) { +func (r *responseWrapperMock) DoRaw(context.Context) ([]byte, error) { data, _ := ioutil.ReadAll(r.data) return data, r.err } -func (r *responseWrapperMock) Stream() (io.ReadCloser, error) { +func (r *responseWrapperMock) Stream(context.Context) (io.ReadCloser, error) { return ioutil.NopCloser(r.data), r.err } @@ -687,7 +688,7 @@ type logTestMock struct { } func (l *logTestMock) mockConsumeRequest(request restclient.ResponseWrapper, out io.Writer) error { - readCloser, err := request.Stream() + readCloser, err := request.Stream(context.Background()) if err != nil { return err } diff --git a/pkg/metricsutil/metrics_client.go b/pkg/metricsutil/metrics_client.go index 73399b233..55a596edd 100644 --- a/pkg/metricsutil/metrics_client.go +++ b/pkg/metricsutil/metrics_client.go @@ -17,6 +17,7 @@ limitations under the License. package metricsutil import ( + "context" "encoding/json" "errors" "fmt" @@ -166,5 +167,5 @@ func (cli *HeapsterMetricsClient) GetPodMetrics(namespace string, podName string func GetHeapsterMetrics(cli *HeapsterMetricsClient, path string, params map[string]string) ([]byte, error) { return cli.SVCClient.Services(cli.HeapsterNamespace). ProxyGet(cli.HeapsterScheme, cli.HeapsterService, cli.HeapsterPort, path, params). - DoRaw() + DoRaw(context.TODO()) }