mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-10 01:55:35 +00:00
cleanup req.Context() and ResponseWrapper
This commit is contained in:
@@ -247,14 +247,13 @@ func (rc *ResourceConsumer) sendConsumeCPURequest(millicores int) {
|
||||
proxyRequest, err := e2eservice.GetServicesProxyRequest(rc.clientSet, rc.clientSet.CoreV1().RESTClient().Post())
|
||||
framework.ExpectNoError(err)
|
||||
req := proxyRequest.Namespace(rc.nsName).
|
||||
Context(ctx).
|
||||
Name(rc.controllerName).
|
||||
Suffix("ConsumeCPU").
|
||||
Param("millicores", strconv.Itoa(millicores)).
|
||||
Param("durationSec", strconv.Itoa(rc.consumptionTimeInSeconds)).
|
||||
Param("requestSizeMillicores", strconv.Itoa(rc.requestSizeInMillicores))
|
||||
framework.Logf("ConsumeCPU URL: %v", *req.URL())
|
||||
_, err = req.DoRaw(context.TODO())
|
||||
_, err = req.DoRaw(ctx)
|
||||
if err != nil {
|
||||
framework.Logf("ConsumeCPU failure: %v", err)
|
||||
return false, nil
|
||||
@@ -274,14 +273,13 @@ func (rc *ResourceConsumer) sendConsumeMemRequest(megabytes int) {
|
||||
proxyRequest, err := e2eservice.GetServicesProxyRequest(rc.clientSet, rc.clientSet.CoreV1().RESTClient().Post())
|
||||
framework.ExpectNoError(err)
|
||||
req := proxyRequest.Namespace(rc.nsName).
|
||||
Context(ctx).
|
||||
Name(rc.controllerName).
|
||||
Suffix("ConsumeMem").
|
||||
Param("megabytes", strconv.Itoa(megabytes)).
|
||||
Param("durationSec", strconv.Itoa(rc.consumptionTimeInSeconds)).
|
||||
Param("requestSizeMegabytes", strconv.Itoa(rc.requestSizeInMegabytes))
|
||||
framework.Logf("ConsumeMem URL: %v", *req.URL())
|
||||
_, err = req.DoRaw(context.TODO())
|
||||
_, err = req.DoRaw(ctx)
|
||||
if err != nil {
|
||||
framework.Logf("ConsumeMem failure: %v", err)
|
||||
return false, nil
|
||||
@@ -301,7 +299,6 @@ func (rc *ResourceConsumer) sendConsumeCustomMetric(delta int) {
|
||||
proxyRequest, err := e2eservice.GetServicesProxyRequest(rc.clientSet, rc.clientSet.CoreV1().RESTClient().Post())
|
||||
framework.ExpectNoError(err)
|
||||
req := proxyRequest.Namespace(rc.nsName).
|
||||
Context(ctx).
|
||||
Name(rc.controllerName).
|
||||
Suffix("BumpMetric").
|
||||
Param("metric", customMetricName).
|
||||
@@ -309,7 +306,7 @@ func (rc *ResourceConsumer) sendConsumeCustomMetric(delta int) {
|
||||
Param("durationSec", strconv.Itoa(rc.consumptionTimeInSeconds)).
|
||||
Param("requestSizeMetrics", strconv.Itoa(rc.requestSizeCustomMetric))
|
||||
framework.Logf("ConsumeCustomMetric URL: %v", *req.URL())
|
||||
_, err = req.DoRaw(context.TODO())
|
||||
_, err = req.DoRaw(ctx)
|
||||
if err != nil {
|
||||
framework.Logf("ConsumeCustomMetric failure: %v", err)
|
||||
return false, nil
|
||||
|
||||
@@ -220,12 +220,11 @@ func GetStatsSummary(c clientset.Interface, nodeName string) (*kubeletstatsv1alp
|
||||
defer cancel()
|
||||
|
||||
data, err := c.CoreV1().RESTClient().Get().
|
||||
Context(ctx).
|
||||
Resource("nodes").
|
||||
SubResource("proxy").
|
||||
Name(fmt.Sprintf("%v:%v", nodeName, ports.KubeletPort)).
|
||||
Suffix("stats/summary").
|
||||
Do(context.TODO()).Raw()
|
||||
Do(ctx).Raw()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -98,12 +98,11 @@ func (r ProxyResponseChecker) CheckAllResponses() (done bool, err error) {
|
||||
defer cancel()
|
||||
|
||||
body, err := r.c.CoreV1().RESTClient().Get().
|
||||
Context(ctx).
|
||||
Namespace(r.ns).
|
||||
Resource("pods").
|
||||
SubResource("proxy").
|
||||
Name(string(pod.Name)).
|
||||
Do(context.TODO()).
|
||||
Do(ctx).
|
||||
Raw()
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -47,8 +47,7 @@ import (
|
||||
// rpc error: code = Unknown desc = Error: No such container: 41a...
|
||||
// when the pod gets deleted while streaming.
|
||||
func LogsForPod(ctx context.Context, cs clientset.Interface, ns, pod string, opts *v1.PodLogOptions) (io.ReadCloser, error) {
|
||||
req := cs.CoreV1().Pods(ns).GetLogs(pod, opts)
|
||||
return req.Context(ctx).Stream(context.TODO())
|
||||
return cs.CoreV1().Pods(ns).GetLogs(pod, opts).Stream(ctx)
|
||||
}
|
||||
|
||||
// LogOutput determines where output from CopyAllLogs goes.
|
||||
|
||||
@@ -294,12 +294,11 @@ func getStatsSummary(c clientset.Interface, nodeName string) (*kubeletstatsv1alp
|
||||
defer cancel()
|
||||
|
||||
data, err := c.CoreV1().RESTClient().Get().
|
||||
Context(ctx).
|
||||
Resource("nodes").
|
||||
SubResource("proxy").
|
||||
Name(fmt.Sprintf("%v:%v", nodeName, ports.KubeletPort)).
|
||||
Suffix("stats/summary").
|
||||
Do(context.TODO()).Raw()
|
||||
Do(ctx).Raw()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user