refactor
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package testing
|
package testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
@@ -133,7 +134,7 @@ func StartTestServer(t Logger, customFlags []string) (result TestServer, err err
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(context.TODO())
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
if status == 200 {
|
if status == 200 {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -33,7 +34,7 @@ func WaitForAPIServer(client clientset.Interface, timeout time.Duration) error {
|
|||||||
|
|
||||||
err := wait.PollImmediate(time.Second, timeout, func() (bool, error) {
|
err := wait.PollImmediate(time.Second, timeout, func() (bool, error) {
|
||||||
healthStatus := 0
|
healthStatus := 0
|
||||||
result := client.Discovery().RESTClient().Get().AbsPath("/healthz").Do().StatusCode(&healthStatus)
|
result := client.Discovery().RESTClient().Get().AbsPath("/healthz").Do(context.TODO()).StatusCode(&healthStatus)
|
||||||
if result.Error() != nil {
|
if result.Error() != nil {
|
||||||
lastErr = fmt.Errorf("failed to get apiserver /healthz status: %v", result.Error())
|
lastErr = fmt.Errorf("failed to get apiserver /healthz status: %v", result.Error())
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package testing
|
package testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
@@ -210,7 +211,7 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(context.TODO())
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
if status == 200 {
|
if status == 200 {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package testing
|
package testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
@@ -133,7 +134,7 @@ func StartTestServer(t Logger, customFlags []string) (result TestServer, err err
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(context.TODO())
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
if status == 200 {
|
if status == 200 {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package options
|
package options
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -640,7 +641,7 @@ pluginConfig:
|
|||||||
|
|
||||||
// test the client talks to the endpoint we expect with the credentials we expect
|
// test the client talks to the endpoint we expect with the credentials we expect
|
||||||
username = ""
|
username = ""
|
||||||
_, err = config.Client.Discovery().RESTClient().Get().AbsPath("/").DoRaw()
|
_, err = config.Client.Discovery().RESTClient().Get().AbsPath("/").DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
@@ -135,7 +135,7 @@ func StartTestServer(t Logger, customFlags []string) (result TestServer, err err
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(context.TODO())
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
if status == 200 {
|
if status == 200 {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apiclient
|
package apiclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -77,7 +78,7 @@ func (w *KubeWaiter) WaitForAPI() error {
|
|||||||
start := time.Now()
|
start := time.Now()
|
||||||
return wait.PollImmediate(kubeadmconstants.APICallRetryInterval, w.timeout, func() (bool, error) {
|
return wait.PollImmediate(kubeadmconstants.APICallRetryInterval, w.timeout, func() (bool, error) {
|
||||||
healthStatus := 0
|
healthStatus := 0
|
||||||
w.client.Discovery().RESTClient().Get().AbsPath("/healthz").Do().StatusCode(&healthStatus)
|
w.client.Discovery().RESTClient().Get().AbsPath("/healthz").Do(context.TODO()).StatusCode(&healthStatus)
|
||||||
if healthStatus != http.StatusOK {
|
if healthStatus != http.StatusOK {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1authenticationapi "k8s.io/api/authentication/v1"
|
v1authenticationapi "k8s.io/api/authentication/v1"
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
@@ -207,7 +207,7 @@ func (b SAControllerClientBuilder) getAuthenticatedConfig(sa *v1.ServiceAccount,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
err = client.Get().AbsPath("/apis").Do().Error()
|
err = client.Get().AbsPath("/apis").Do(context.TODO()).Error()
|
||||||
if apierrors.IsUnauthorized(err) {
|
if apierrors.IsUnauthorized(err) {
|
||||||
klog.Warningf("Token for %s/%s did not authenticate correctly: %v", sa.Namespace, sa.Name, err)
|
klog.Warningf("Token for %s/%s did not authenticate correctly: %v", sa.Namespace, sa.Name, err)
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
|
@@ -291,7 +291,7 @@ func waitForServer(cfg restclient.Config, deadline time.Duration) error {
|
|||||||
|
|
||||||
var connected bool
|
var connected bool
|
||||||
wait.JitterUntil(func() {
|
wait.JitterUntil(func() {
|
||||||
if _, err := cli.Get().AbsPath("/healthz").Do().Raw(); err != nil {
|
if _, err := cli.Get().AbsPath("/healthz").Do(context.TODO()).Raw(); err != nil {
|
||||||
klog.Infof("Failed to connect to apiserver: %v", err)
|
klog.Infof("Failed to connect to apiserver: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package certificate
|
package certificate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -198,7 +199,7 @@ func TestRotateShutsDownConnections(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := client.Get().Do().Error(); err != nil {
|
if err := client.Get().Do(context.TODO()).Error(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
firstCertSerial := lastSerialNumber()
|
firstCertSerial := lastSerialNumber()
|
||||||
@@ -209,7 +210,7 @@ func TestRotateShutsDownConnections(t *testing.T) {
|
|||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
time.Sleep(time.Millisecond * 10)
|
time.Sleep(time.Millisecond * 10)
|
||||||
client.Get().Do()
|
client.Get().Do(context.TODO())
|
||||||
if firstCertSerial.Cmp(lastSerialNumber()) != 0 {
|
if firstCertSerial.Cmp(lastSerialNumber()) != 0 {
|
||||||
// The certificate changed!
|
// The certificate changed!
|
||||||
return
|
return
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package master
|
package master
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -210,7 +211,7 @@ func (c *Controller) RunKubernetesService(ch chan struct{}) {
|
|||||||
// wait until process is ready
|
// wait until process is ready
|
||||||
wait.PollImmediateUntil(100*time.Millisecond, func() (bool, error) {
|
wait.PollImmediateUntil(100*time.Millisecond, func() (bool, error) {
|
||||||
var code int
|
var code int
|
||||||
c.healthClient.Get().AbsPath("/healthz").Do().StatusCode(&code)
|
c.healthClient.Get().AbsPath("/healthz").Do(context.TODO()).StatusCode(&code)
|
||||||
return code == http.StatusOK, nil
|
return code == http.StatusOK, nil
|
||||||
}, ch)
|
}, ch)
|
||||||
|
|
||||||
|
@@ -174,7 +174,7 @@ func (a *Plugin) admitPod(ctx context.Context, pod *api.Pod, attributes admissio
|
|||||||
review.Status = entry.(v1alpha1.ImageReviewStatus)
|
review.Status = entry.(v1alpha1.ImageReviewStatus)
|
||||||
} else {
|
} else {
|
||||||
result := a.webhook.WithExponentialBackoff(ctx, func() rest.Result {
|
result := a.webhook.WithExponentialBackoff(ctx, func() rest.Result {
|
||||||
return a.webhook.RestClient.Post().Context(ctx).Body(review).Do()
|
return a.webhook.RestClient.Post().Context(ctx).Body(review).Do(context.TODO())
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
|
@@ -271,7 +271,7 @@ func (c *webhookConverter) Convert(in runtime.Object, toGV schema.GroupVersion)
|
|||||||
|
|
||||||
// TODO: Figure out if adding one second timeout make sense here.
|
// TODO: Figure out if adding one second timeout make sense here.
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
r := c.restClient.Post().Context(ctx).Body(request).Do()
|
r := c.restClient.Post().Context(ctx).Body(request).Do(context.TODO())
|
||||||
if err := r.Into(response); err != nil {
|
if err := r.Into(response); err != nil {
|
||||||
// TODO: Return a webhook specific error to be able to convert it to meta.Status
|
// TODO: Return a webhook specific error to be able to convert it to meta.Status
|
||||||
return nil, fmt.Errorf("conversion webhook for %v failed: %v", in.GetObjectKind().GroupVersionKind(), err)
|
return nil, fmt.Errorf("conversion webhook for %v failed: %v", in.GetObjectKind().GroupVersionKind(), err)
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package testing
|
package testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
@@ -170,7 +171,7 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(context.TODO())
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
if status == 200 {
|
if status == 200 {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ values:
|
|||||||
Name("mytest").
|
Name("mytest").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
@@ -82,7 +83,7 @@ values:
|
|||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Name("mytest").
|
Name("mytest").
|
||||||
Body([]byte(`{"values":{"numVal": 5}}`)).
|
Body([]byte(`{"values":{"numVal": 5}}`)).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
@@ -93,7 +94,7 @@ values:
|
|||||||
Name("mytest").
|
Name("mytest").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expecting to get conflicts when applying object, got no error: %s", result)
|
t.Fatalf("Expecting to get conflicts when applying object, got no error: %s", result)
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,7 @@ values:
|
|||||||
Param("force", "true").
|
Param("force", "true").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -1010,7 +1011,7 @@ func TestStatusGetAndPatch(t *testing.T) {
|
|||||||
Resource("customresourcedefinitions").
|
Resource("customresourcedefinitions").
|
||||||
Name(noxuDefinition.Name).
|
Name(noxuDefinition.Name).
|
||||||
SubResource("status").
|
SubResource("status").
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -71,7 +72,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsRequestEntityTooLargeError(err) {
|
if !apierrors.IsRequestEntityTooLargeError(err) {
|
||||||
t.Errorf("expected too large error, got %v", err)
|
t.Errorf("expected too large error, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected bad request, got %v", err)
|
t.Errorf("expected bad request, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -111,7 +112,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected bad request, got %v", err)
|
t.Errorf("expected bad request, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Body(jsonBody).
|
Body(jsonBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsRequestEntityTooLargeError(err) {
|
if !apierrors.IsRequestEntityTooLargeError(err) {
|
||||||
t.Errorf("expected too large error, got %v", err)
|
t.Errorf("expected too large error, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -153,7 +154,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Body(jsonBody).
|
Body(jsonBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected bad request, got %v", err)
|
t.Errorf("expected bad request, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -174,7 +175,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Body(jsonBody).
|
Body(jsonBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected bad request, got %v", err)
|
t.Errorf("expected bad request, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -183,7 +184,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
// Create instance to allow patching
|
// Create instance to allow patching
|
||||||
{
|
{
|
||||||
jsonBody := []byte(fmt.Sprintf(`{"apiVersion": %q, "kind": %q, "metadata": {"name": "test"}}`, apiVersion, kind))
|
jsonBody := []byte(fmt.Sprintf(`{"apiVersion": %q, "kind": %q, "metadata": {"name": "test"}}`, apiVersion, kind))
|
||||||
_, err := rest.Post().AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).Body(jsonBody).DoRaw()
|
_, err := rest.Post().AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).Body(jsonBody).DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error creating object: %v", err)
|
t.Fatalf("error creating object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -192,7 +193,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
t.Run("JSONPatchType nested patch under limit", func(t *testing.T) {
|
t.Run("JSONPatchType nested patch under limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`[{"op":"add","path":"/foo","value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}]`)
|
patchBody := []byte(`[{"op":"add","path":"/foo","value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}]`)
|
||||||
err = rest.Patch(types.JSONPatchType).AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "test").
|
err = rest.Patch(types.JSONPatchType).AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "test").
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected success or bad request err, got %v", err)
|
t.Errorf("expected success or bad request err, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -200,7 +201,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
t.Run("MergePatchType nested patch under limit", func(t *testing.T) {
|
t.Run("MergePatchType nested patch under limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
||||||
err = rest.Patch(types.MergePatchType).AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "test").
|
err = rest.Patch(types.MergePatchType).AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "test").
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected success or bad request err, got %v", err)
|
t.Errorf("expected success or bad request err, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -208,7 +209,7 @@ values: `+strings.Repeat("[", 3*1024*1024), apiVersion, kind))
|
|||||||
t.Run("ApplyPatchType nested patch under limit", func(t *testing.T) {
|
t.Run("ApplyPatchType nested patch under limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
||||||
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "test").
|
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "test").
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected bad request err, got %#v", err)
|
t.Errorf("expected bad request err, got %#v", err)
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -164,7 +165,7 @@ func TestTableGet(t *testing.T) {
|
|||||||
Resource(crd.Spec.Names.Plural).
|
Resource(crd.Spec.Names.Plural).
|
||||||
SetHeader("Accept", fmt.Sprintf("application/json;as=Table;v=%s;g=%s, application/json", metav1beta1.SchemeGroupVersion.Version, metav1beta1.GroupName)).
|
SetHeader("Accept", fmt.Sprintf("application/json;as=Table;v=%s;g=%s, application/json", metav1beta1.SchemeGroupVersion.Version, metav1beta1.GroupName)).
|
||||||
VersionedParams(&metav1beta1.TableOptions{}, parameterCodec).
|
VersionedParams(&metav1beta1.TableOptions{}, parameterCodec).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to list %v resources: %v", gvk, err)
|
t.Fatalf("failed to list %v resources: %v", gvk, err)
|
||||||
@@ -262,7 +263,7 @@ func TestTableGet(t *testing.T) {
|
|||||||
Resource(crd.Spec.Names.Plural).
|
Resource(crd.Spec.Names.Plural).
|
||||||
SetHeader("Accept", fmt.Sprintf("application/json;as=Table;v=%s;g=%s, application/json", metav1.SchemeGroupVersion.Version, metav1.GroupName)).
|
SetHeader("Accept", fmt.Sprintf("application/json;as=Table;v=%s;g=%s, application/json", metav1.SchemeGroupVersion.Version, metav1.GroupName)).
|
||||||
VersionedParams(&metav1.TableOptions{}, parameterCodec).
|
VersionedParams(&metav1.TableOptions{}, parameterCodec).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to list %v resources: %v", gvk, err)
|
t.Fatalf("failed to list %v resources: %v", gvk, err)
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -67,7 +68,7 @@ func TestYAML(t *testing.T) {
|
|||||||
result, err := rest.Get().
|
result, err := rest.Get().
|
||||||
SetHeader("Accept", "application/yaml").
|
SetHeader("Accept", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
@@ -88,7 +89,7 @@ func TestYAML(t *testing.T) {
|
|||||||
result, err := rest.Get().
|
result, err := rest.Get().
|
||||||
SetHeader("Accept", "application/yaml").
|
SetHeader("Accept", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "missingname").
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "missingname").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !errors.IsNotFound(err) {
|
if !errors.IsNotFound(err) {
|
||||||
t.Fatalf("expected not found, got %v", err)
|
t.Fatalf("expected not found, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -124,7 +125,7 @@ values:
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
@@ -159,7 +160,7 @@ values:
|
|||||||
result, err := rest.Get().
|
result, err := rest.Get().
|
||||||
SetHeader("Accept", "application/yaml").
|
SetHeader("Accept", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest").
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -192,7 +193,7 @@ values:
|
|||||||
result, err := rest.Get().
|
result, err := rest.Get().
|
||||||
SetHeader("Accept", "application/yaml").
|
SetHeader("Accept", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
@@ -237,7 +238,7 @@ values:
|
|||||||
SetHeader("Accept", "application/yaml").
|
SetHeader("Accept", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Param("watch", "true").
|
Param("watch", "true").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !errors.IsNotAcceptable(err) {
|
if !errors.IsNotAcceptable(err) {
|
||||||
t.Fatalf("expected not acceptable error, got %v (%s)", err, string(result))
|
t.Fatalf("expected not acceptable error, got %v (%s)", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -274,7 +275,7 @@ values:
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest").
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
@@ -315,7 +316,7 @@ values:
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest").
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !errors.IsUnsupportedMediaType(err) {
|
if !errors.IsUnsupportedMediaType(err) {
|
||||||
t.Fatalf("Expected bad request, got %v\n%s", err, string(result))
|
t.Fatalf("Expected bad request, got %v\n%s", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -336,7 +337,7 @@ values:
|
|||||||
result, err := rest.Delete().
|
result, err := rest.Delete().
|
||||||
SetHeader("Accept", "application/yaml").
|
SetHeader("Accept", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest").
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
@@ -398,7 +399,7 @@ spec:
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
@@ -427,7 +428,7 @@ spec:
|
|||||||
result, err := rest.Get().
|
result, err := rest.Get().
|
||||||
SetHeader("Accept", "application/yaml").
|
SetHeader("Accept", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest", "status").
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest", "status").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -467,7 +468,7 @@ status:
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest", "status").
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest", "status").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err, string(result))
|
t.Fatal(err, string(result))
|
||||||
}
|
}
|
||||||
@@ -500,7 +501,7 @@ status:
|
|||||||
result, err := rest.Get().
|
result, err := rest.Get().
|
||||||
SetHeader("Accept", "application/yaml").
|
SetHeader("Accept", "application/yaml").
|
||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest", "scale").
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural, "mytest", "scale").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
jsonpatch "github.com/evanphx/json-patch"
|
jsonpatch "github.com/evanphx/json-patch"
|
||||||
|
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
@@ -250,7 +251,7 @@ func (a *mutatingDispatcher) callAttrMutatingHook(ctx context.Context, h *admiss
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Do().Into(response); err != nil {
|
if err := r.Do(context.TODO()).Into(response); err != nil {
|
||||||
return false, &webhookutil.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
return false, &webhookutil.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
||||||
}
|
}
|
||||||
trace.Step("Request completed")
|
trace.Step("Request completed")
|
||||||
|
@@ -22,7 +22,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/api/admissionregistration/v1"
|
v1 "k8s.io/api/admissionregistration/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
@@ -211,7 +211,7 @@ func (d *validatingDispatcher) callHook(ctx context.Context, h *v1.ValidatingWeb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Do().Into(response); err != nil {
|
if err := r.Do(context.TODO()).Into(response); err != nil {
|
||||||
return &webhookutil.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
return &webhookutil.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
||||||
}
|
}
|
||||||
trace.Step("Request completed")
|
trace.Step("Request completed")
|
||||||
|
@@ -37,7 +37,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd/api/v1"
|
v1 "k8s.io/client-go/tools/clientcmd/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -397,7 +397,7 @@ func TestTLSConfig(t *testing.T) {
|
|||||||
wh, err := NewGenericWebhook(runtime.NewScheme(), scheme.Codecs, configFile, groupVersions, retryBackoff)
|
wh, err := NewGenericWebhook(runtime.NewScheme(), scheme.Codecs, configFile, groupVersions, retryBackoff)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = wh.RestClient.Get().Do().Error()
|
err = wh.RestClient.Get().Do(context.TODO()).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -466,7 +466,7 @@ func TestRequestTimeout(t *testing.T) {
|
|||||||
|
|
||||||
resultCh := make(chan rest.Result)
|
resultCh := make(chan rest.Result)
|
||||||
|
|
||||||
go func() { resultCh <- wh.RestClient.Get().Do() }()
|
go func() { resultCh <- wh.RestClient.Get().Do(context.TODO()) }()
|
||||||
select {
|
select {
|
||||||
case <-time.After(time.Second * 5):
|
case <-time.After(time.Second * 5):
|
||||||
t.Errorf("expected request to timeout after %s", requestTimeout)
|
t.Errorf("expected request to timeout after %s", requestTimeout)
|
||||||
@@ -552,7 +552,7 @@ func TestWithExponentialBackoff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result := wh.WithExponentialBackoff(context.Background(), func() rest.Result {
|
result := wh.WithExponentialBackoff(context.Background(), func() rest.Result {
|
||||||
return wh.RestClient.Get().Do()
|
return wh.RestClient.Get().Do(context.TODO())
|
||||||
})
|
})
|
||||||
|
|
||||||
var statusCode int
|
var statusCode int
|
||||||
@@ -564,7 +564,7 @@ func TestWithExponentialBackoff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = wh.WithExponentialBackoff(context.Background(), func() rest.Result {
|
result = wh.WithExponentialBackoff(context.Background(), func() rest.Result {
|
||||||
return wh.RestClient.Get().Do()
|
return wh.RestClient.Get().Do(context.TODO())
|
||||||
})
|
})
|
||||||
|
|
||||||
result.StatusCode(&statusCode)
|
result.StatusCode(&statusCode)
|
||||||
|
@@ -124,7 +124,7 @@ func (b *backend) processEvents(ev ...*auditinternal.Event) error {
|
|||||||
// allow enough time for the serialization/deserialization of audit events, which
|
// allow enough time for the serialization/deserialization of audit events, which
|
||||||
// contain nested request and response objects plus additional event fields.
|
// contain nested request and response objects plus additional event fields.
|
||||||
defer trace.LogIfLong(time.Duration(50+25*len(list.Items)) * time.Millisecond)
|
defer trace.LogIfLong(time.Duration(50+25*len(list.Items)) * time.Millisecond)
|
||||||
return b.w.RestClient.Post().Body(&list).Do()
|
return b.w.RestClient.Post().Body(&list).Do(context.TODO())
|
||||||
}).Error()
|
}).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -198,7 +198,7 @@ type tokenReviewV1Client struct {
|
|||||||
|
|
||||||
func (t *tokenReviewV1Client) CreateContext(ctx context.Context, review *authenticationv1.TokenReview) (*authenticationv1.TokenReview, error) {
|
func (t *tokenReviewV1Client) CreateContext(ctx context.Context, review *authenticationv1.TokenReview) (*authenticationv1.TokenReview, error) {
|
||||||
result := &authenticationv1.TokenReview{}
|
result := &authenticationv1.TokenReview{}
|
||||||
err := t.w.RestClient.Post().Context(ctx).Body(review).Do().Into(result)
|
err := t.w.RestClient.Post().Context(ctx).Body(review).Do(context.TODO()).Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ type tokenReviewV1beta1Client struct {
|
|||||||
func (t *tokenReviewV1beta1Client) CreateContext(ctx context.Context, review *authenticationv1.TokenReview) (*authenticationv1.TokenReview, error) {
|
func (t *tokenReviewV1beta1Client) CreateContext(ctx context.Context, review *authenticationv1.TokenReview) (*authenticationv1.TokenReview, error) {
|
||||||
v1beta1Review := &authenticationv1beta1.TokenReview{Spec: v1SpecToV1beta1Spec(&review.Spec)}
|
v1beta1Review := &authenticationv1beta1.TokenReview{Spec: v1SpecToV1beta1Spec(&review.Spec)}
|
||||||
v1beta1Result := &authenticationv1beta1.TokenReview{}
|
v1beta1Result := &authenticationv1beta1.TokenReview{}
|
||||||
err := t.w.RestClient.Post().Context(ctx).Body(v1beta1Review).Do().Into(v1beta1Result)
|
err := t.w.RestClient.Post().Context(ctx).Body(v1beta1Review).Do(context.TODO()).Into(v1beta1Result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -289,7 +289,7 @@ type subjectAccessReviewV1Client struct {
|
|||||||
|
|
||||||
func (t *subjectAccessReviewV1Client) CreateContext(ctx context.Context, subjectAccessReview *authorizationv1.SubjectAccessReview) (*authorizationv1.SubjectAccessReview, error) {
|
func (t *subjectAccessReviewV1Client) CreateContext(ctx context.Context, subjectAccessReview *authorizationv1.SubjectAccessReview) (*authorizationv1.SubjectAccessReview, error) {
|
||||||
result := &authorizationv1.SubjectAccessReview{}
|
result := &authorizationv1.SubjectAccessReview{}
|
||||||
err := t.w.RestClient.Post().Context(ctx).Body(subjectAccessReview).Do().Into(result)
|
err := t.w.RestClient.Post().Context(ctx).Body(subjectAccessReview).Do(context.TODO()).Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ type subjectAccessReviewV1beta1Client struct {
|
|||||||
func (t *subjectAccessReviewV1beta1Client) CreateContext(ctx context.Context, subjectAccessReview *authorizationv1.SubjectAccessReview) (*authorizationv1.SubjectAccessReview, error) {
|
func (t *subjectAccessReviewV1beta1Client) CreateContext(ctx context.Context, subjectAccessReview *authorizationv1.SubjectAccessReview) (*authorizationv1.SubjectAccessReview, error) {
|
||||||
v1beta1Review := &authorizationv1beta1.SubjectAccessReview{Spec: v1SpecToV1beta1Spec(&subjectAccessReview.Spec)}
|
v1beta1Review := &authorizationv1beta1.SubjectAccessReview{Spec: v1SpecToV1beta1Spec(&subjectAccessReview.Spec)}
|
||||||
v1beta1Result := &authorizationv1beta1.SubjectAccessReview{}
|
v1beta1Result := &authorizationv1beta1.SubjectAccessReview{}
|
||||||
err := t.w.RestClient.Post().Context(ctx).Body(v1beta1Review).Do().Into(v1beta1Result)
|
err := t.w.RestClient.Post().Context(ctx).Body(v1beta1Review).Do(context.TODO()).Into(v1beta1Result)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
subjectAccessReview.Status = v1beta1StatusToV1Status(&v1beta1Result.Status)
|
subjectAccessReview.Status = v1beta1StatusToV1Status(&v1beta1Result.Status)
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package resource
|
package resource
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
@@ -72,7 +73,7 @@ func (m *Helper) Get(namespace, name string, export bool) (runtime.Object, error
|
|||||||
// TODO: I should be part of GetOptions
|
// TODO: I should be part of GetOptions
|
||||||
req.Param("export", strconv.FormatBool(export))
|
req.Param("export", strconv.FormatBool(export))
|
||||||
}
|
}
|
||||||
return req.Do().Get()
|
return req.Do(context.TODO()).Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Helper) List(namespace, apiVersion string, export bool, options *metav1.ListOptions) (runtime.Object, error) {
|
func (m *Helper) List(namespace, apiVersion string, export bool, options *metav1.ListOptions) (runtime.Object, error) {
|
||||||
@@ -84,7 +85,7 @@ func (m *Helper) List(namespace, apiVersion string, export bool, options *metav1
|
|||||||
// TODO: I should be part of ListOptions
|
// TODO: I should be part of ListOptions
|
||||||
req.Param("export", strconv.FormatBool(export))
|
req.Param("export", strconv.FormatBool(export))
|
||||||
}
|
}
|
||||||
return req.Do().Get()
|
return req.Do(context.TODO()).Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Helper) Watch(namespace, apiVersion string, options *metav1.ListOptions) (watch.Interface, error) {
|
func (m *Helper) Watch(namespace, apiVersion string, options *metav1.ListOptions) (watch.Interface, error) {
|
||||||
@@ -93,7 +94,7 @@ func (m *Helper) Watch(namespace, apiVersion string, options *metav1.ListOptions
|
|||||||
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
NamespaceIfScoped(namespace, m.NamespaceScoped).
|
||||||
Resource(m.Resource).
|
Resource(m.Resource).
|
||||||
VersionedParams(options, metav1.ParameterCodec).
|
VersionedParams(options, metav1.ParameterCodec).
|
||||||
Watch()
|
Watch(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Helper) WatchSingle(namespace, name, resourceVersion string) (watch.Interface, error) {
|
func (m *Helper) WatchSingle(namespace, name, resourceVersion string) (watch.Interface, error) {
|
||||||
@@ -105,7 +106,7 @@ func (m *Helper) WatchSingle(namespace, name, resourceVersion string) (watch.Int
|
|||||||
Watch: true,
|
Watch: true,
|
||||||
FieldSelector: fields.OneTermEqualSelector("metadata.name", name).String(),
|
FieldSelector: fields.OneTermEqualSelector("metadata.name", name).String(),
|
||||||
}, metav1.ParameterCodec).
|
}, metav1.ParameterCodec).
|
||||||
Watch()
|
Watch(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Helper) Delete(namespace, name string) (runtime.Object, error) {
|
func (m *Helper) Delete(namespace, name string) (runtime.Object, error) {
|
||||||
@@ -125,7 +126,7 @@ func (m *Helper) DeleteWithOptions(namespace, name string, options *metav1.Delet
|
|||||||
Resource(m.Resource).
|
Resource(m.Resource).
|
||||||
Name(name).
|
Name(name).
|
||||||
Body(options).
|
Body(options).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +164,7 @@ func (m *Helper) createResource(c RESTClient, resource, namespace string, obj ru
|
|||||||
Resource(resource).
|
Resource(resource).
|
||||||
VersionedParams(options, metav1.ParameterCodec).
|
VersionedParams(options, metav1.ParameterCodec).
|
||||||
Body(obj).
|
Body(obj).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
}
|
}
|
||||||
func (m *Helper) Patch(namespace, name string, pt types.PatchType, data []byte, options *metav1.PatchOptions) (runtime.Object, error) {
|
func (m *Helper) Patch(namespace, name string, pt types.PatchType, data []byte, options *metav1.PatchOptions) (runtime.Object, error) {
|
||||||
@@ -179,7 +180,7 @@ func (m *Helper) Patch(namespace, name string, pt types.PatchType, data []byte,
|
|||||||
Name(name).
|
Name(name).
|
||||||
VersionedParams(options, metav1.ParameterCodec).
|
VersionedParams(options, metav1.ParameterCodec).
|
||||||
Body(data).
|
Body(data).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +199,7 @@ func (m *Helper) Replace(namespace, name string, overwrite bool, obj runtime.Obj
|
|||||||
}
|
}
|
||||||
if version == "" && overwrite {
|
if version == "" && overwrite {
|
||||||
// Retrieve the current version of the object to overwrite the server object
|
// Retrieve the current version of the object to overwrite the server object
|
||||||
serverObj, err := c.Get().NamespaceIfScoped(namespace, m.NamespaceScoped).Resource(m.Resource).Name(name).Do().Get()
|
serverObj, err := c.Get().NamespaceIfScoped(namespace, m.NamespaceScoped).Resource(m.Resource).Name(name).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// The object does not exist, but we want it to be created
|
// The object does not exist, but we want it to be created
|
||||||
return m.replaceResource(c, m.Resource, namespace, name, obj, options)
|
return m.replaceResource(c, m.Resource, namespace, name, obj, options)
|
||||||
@@ -222,6 +223,6 @@ func (m *Helper) replaceResource(c RESTClient, resource, namespace, name string,
|
|||||||
Name(name).
|
Name(name).
|
||||||
VersionedParams(options, metav1.ParameterCodec).
|
VersionedParams(options, metav1.ParameterCodec).
|
||||||
Body(obj).
|
Body(obj).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ package resource
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -30,6 +31,8 @@ import (
|
|||||||
"golang.org/x/text/encoding/unicode"
|
"golang.org/x/text/encoding/unicode"
|
||||||
"golang.org/x/text/transform"
|
"golang.org/x/text/transform"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/pkg/fs"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -40,7 +43,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/yaml"
|
"k8s.io/apimachinery/pkg/util/yaml"
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/cli-runtime/pkg/kustomize"
|
"k8s.io/cli-runtime/pkg/kustomize"
|
||||||
"sigs.k8s.io/kustomize/pkg/fs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -100,7 +102,7 @@ func (i *Info) Get() (err error) {
|
|||||||
obj, err := NewHelper(i.Client, i.Mapping).Get(i.Namespace, i.Name, i.Export)
|
obj, err := NewHelper(i.Client, i.Mapping).Get(i.Namespace, i.Name, i.Export)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.IsNotFound(err) && len(i.Namespace) > 0 && i.Namespace != metav1.NamespaceDefault && i.Namespace != metav1.NamespaceAll {
|
if errors.IsNotFound(err) && len(i.Namespace) > 0 && i.Namespace != metav1.NamespaceDefault && i.Namespace != metav1.NamespaceAll {
|
||||||
err2 := i.Client.Get().AbsPath("api", "v1", "namespaces", i.Namespace).Do().Error()
|
err2 := i.Client.Get().AbsPath("api", "v1", "namespaces", i.Namespace).Do(context.TODO()).Error()
|
||||||
if err2 != nil && errors.IsNotFound(err2) {
|
if err2 != nil && errors.IsNotFound(err2) {
|
||||||
return err2
|
return err2
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package discovery
|
package discovery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -155,7 +156,7 @@ func apiVersionsToAPIGroup(apiVersions *metav1.APIVersions) (apiGroup metav1.API
|
|||||||
func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err error) {
|
func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err error) {
|
||||||
// Get the groupVersions exposed at /api
|
// Get the groupVersions exposed at /api
|
||||||
v := &metav1.APIVersions{}
|
v := &metav1.APIVersions{}
|
||||||
err = d.restClient.Get().AbsPath(d.LegacyPrefix).Do().Into(v)
|
err = d.restClient.Get().AbsPath(d.LegacyPrefix).Do(context.TODO()).Into(v)
|
||||||
apiGroup := metav1.APIGroup{}
|
apiGroup := metav1.APIGroup{}
|
||||||
if err == nil && len(v.Versions) != 0 {
|
if err == nil && len(v.Versions) != 0 {
|
||||||
apiGroup = apiVersionsToAPIGroup(v)
|
apiGroup = apiVersionsToAPIGroup(v)
|
||||||
@@ -166,7 +167,7 @@ func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err
|
|||||||
|
|
||||||
// Get the groupVersions exposed at /apis
|
// Get the groupVersions exposed at /apis
|
||||||
apiGroupList = &metav1.APIGroupList{}
|
apiGroupList = &metav1.APIGroupList{}
|
||||||
err = d.restClient.Get().AbsPath("/apis").Do().Into(apiGroupList)
|
err = d.restClient.Get().AbsPath("/apis").Do(context.TODO()).Into(apiGroupList)
|
||||||
if err != nil && !errors.IsNotFound(err) && !errors.IsForbidden(err) {
|
if err != nil && !errors.IsNotFound(err) && !errors.IsForbidden(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -196,7 +197,7 @@ func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (r
|
|||||||
resources = &metav1.APIResourceList{
|
resources = &metav1.APIResourceList{
|
||||||
GroupVersion: groupVersion,
|
GroupVersion: groupVersion,
|
||||||
}
|
}
|
||||||
err = d.restClient.Get().AbsPath(url.String()).Do().Into(resources)
|
err = d.restClient.Get().AbsPath(url.String()).Do(context.TODO()).Into(resources)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// ignore 403 or 404 error to be compatible with an v1.0 server.
|
// ignore 403 or 404 error to be compatible with an v1.0 server.
|
||||||
if groupVersion == "v1" && (errors.IsNotFound(err) || errors.IsForbidden(err)) {
|
if groupVersion == "v1" && (errors.IsNotFound(err) || errors.IsForbidden(err)) {
|
||||||
@@ -405,7 +406,7 @@ func ServerPreferredNamespacedResources(d DiscoveryInterface) ([]*metav1.APIReso
|
|||||||
|
|
||||||
// ServerVersion retrieves and parses the server's version (git version).
|
// ServerVersion retrieves and parses the server's version (git version).
|
||||||
func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
|
func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
|
||||||
body, err := d.restClient.Get().AbsPath("/version").Do().Raw()
|
body, err := d.restClient.Get().AbsPath("/version").Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -419,12 +420,12 @@ func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
|
|||||||
|
|
||||||
// OpenAPISchema fetches the open api schema using a rest client and parses the proto.
|
// OpenAPISchema fetches the open api schema using a rest client and parses the proto.
|
||||||
func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) {
|
func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) {
|
||||||
data, err := d.restClient.Get().AbsPath("/openapi/v2").SetHeader("Accept", mimePb).Do().Raw()
|
data, err := d.restClient.Get().AbsPath("/openapi/v2").SetHeader("Accept", mimePb).Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.IsForbidden(err) || errors.IsNotFound(err) || errors.IsNotAcceptable(err) {
|
if errors.IsForbidden(err) || errors.IsNotFound(err) || errors.IsNotAcceptable(err) {
|
||||||
// single endpoint not found/registered in old server, try to fetch old endpoint
|
// single endpoint not found/registered in old server, try to fetch old endpoint
|
||||||
// TODO: remove this when kubectl/client-go don't work with 1.9 server
|
// TODO: remove this when kubectl/client-go don't work with 1.9 server
|
||||||
data, err = d.restClient.Get().AbsPath("/swagger-2.0.0.pb-v1").Do().Raw()
|
data, err = d.restClient.Get().AbsPath("/swagger-2.0.0.pb-v1").Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package dynamic
|
package dynamic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
@@ -111,7 +112,7 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, opts meta
|
|||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(outBytes).
|
Body(outBytes).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -146,7 +147,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts meta
|
|||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(outBytes).
|
Body(outBytes).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -182,7 +183,7 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opt
|
|||||||
AbsPath(append(c.makeURLSegments(name), "status")...).
|
AbsPath(append(c.makeURLSegments(name), "status")...).
|
||||||
Body(outBytes).
|
Body(outBytes).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -214,7 +215,7 @@ func (c *dynamicResourceClient) Delete(name string, opts *metav1.DeleteOptions,
|
|||||||
Delete().
|
Delete().
|
||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(deleteOptionsByte).
|
Body(deleteOptionsByte).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
return result.Error()
|
return result.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +233,7 @@ func (c *dynamicResourceClient) DeleteCollection(opts *metav1.DeleteOptions, lis
|
|||||||
AbsPath(c.makeURLSegments("")...).
|
AbsPath(c.makeURLSegments("")...).
|
||||||
Body(deleteOptionsByte).
|
Body(deleteOptionsByte).
|
||||||
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
return result.Error()
|
return result.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +241,7 @@ func (c *dynamicResourceClient) Get(name string, opts metav1.GetOptions, subreso
|
|||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
return nil, fmt.Errorf("name is required")
|
return nil, fmt.Errorf("name is required")
|
||||||
}
|
}
|
||||||
result := c.client.client.Get().AbsPath(append(c.makeURLSegments(name), subresources...)...).SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).Do()
|
result := c.client.client.Get().AbsPath(append(c.makeURLSegments(name), subresources...)...).SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -256,7 +257,7 @@ func (c *dynamicResourceClient) Get(name string, opts metav1.GetOptions, subreso
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *dynamicResourceClient) List(opts metav1.ListOptions) (*unstructured.UnstructuredList, error) {
|
func (c *dynamicResourceClient) List(opts metav1.ListOptions) (*unstructured.UnstructuredList, error) {
|
||||||
result := c.client.client.Get().AbsPath(c.makeURLSegments("")...).SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).Do()
|
result := c.client.client.Get().AbsPath(c.makeURLSegments("")...).SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -283,7 +284,7 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
|
|||||||
opts.Watch = true
|
opts.Watch = true
|
||||||
return c.client.client.Get().AbsPath(c.makeURLSegments("")...).
|
return c.client.client.Get().AbsPath(c.makeURLSegments("")...).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Watch()
|
Watch(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error) {
|
func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error) {
|
||||||
@@ -295,7 +296,7 @@ func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []by
|
|||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(data).
|
Body(data).
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ func (c *tokenReviews) CreateContext(ctx context.Context, tokenReview *authentic
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("tokenreviews").
|
Resource("tokenreviews").
|
||||||
Body(tokenReview).
|
Body(tokenReview).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ func (c *tokenReviews) CreateContext(ctx context.Context, tokenReview *authentic
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("tokenreviews").
|
Resource("tokenreviews").
|
||||||
Body(tokenReview).
|
Body(tokenReview).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ func (c *localSubjectAccessReviews) CreateContext(ctx context.Context, sar *auth
|
|||||||
Namespace(c.ns).
|
Namespace(c.ns).
|
||||||
Resource("localsubjectaccessreviews").
|
Resource("localsubjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ func (c *selfSubjectAccessReviews) CreateContext(ctx context.Context, sar *autho
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("selfsubjectaccessreviews").
|
Resource("selfsubjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ func (c *selfSubjectRulesReviews) CreateContext(ctx context.Context, srr *author
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("selfsubjectrulesreviews").
|
Resource("selfsubjectrulesreviews").
|
||||||
Body(srr).
|
Body(srr).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ func (c *subjectAccessReviews) CreateContext(ctx context.Context, sar *authoriza
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("subjectaccessreviews").
|
Resource("subjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ func (c *localSubjectAccessReviews) CreateContext(ctx context.Context, sar *auth
|
|||||||
Namespace(c.ns).
|
Namespace(c.ns).
|
||||||
Resource("localsubjectaccessreviews").
|
Resource("localsubjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ func (c *selfSubjectAccessReviews) CreateContext(ctx context.Context, sar *autho
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("selfsubjectaccessreviews").
|
Resource("selfsubjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ func (c *selfSubjectRulesReviews) CreateContext(ctx context.Context, srr *author
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("selfsubjectrulesreviews").
|
Resource("selfsubjectrulesreviews").
|
||||||
Body(srr).
|
Body(srr).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ func (c *subjectAccessReviews) CreateContext(ctx context.Context, sar *authoriza
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Resource("subjectaccessreviews").
|
Resource("subjectaccessreviews").
|
||||||
Body(sar).
|
Body(sar).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
certificates "k8s.io/api/certificates/v1beta1"
|
certificates "k8s.io/api/certificates/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ func (c *certificateSigningRequests) UpdateApproval(certificateSigningRequest *c
|
|||||||
Name(certificateSigningRequest.Name).
|
Name(certificateSigningRequest.Name).
|
||||||
Body(certificateSigningRequest).
|
Body(certificateSigningRequest).
|
||||||
SubResource("approval").
|
SubResource("approval").
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -17,9 +17,10 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@@ -54,7 +55,7 @@ func (e *events) CreateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
|||||||
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
||||||
Resource("events").
|
Resource("events").
|
||||||
Body(event).
|
Body(event).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ func (e *events) UpdateWithEventNamespace(event *v1.Event) (*v1.Event, error) {
|
|||||||
Resource("events").
|
Resource("events").
|
||||||
Name(event.Name).
|
Name(event.Name).
|
||||||
Body(event).
|
Body(event).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,7 @@ func (e *events) PatchWithEventNamespace(incompleteEvent *v1.Event, data []byte)
|
|||||||
Resource("events").
|
Resource("events").
|
||||||
Name(incompleteEvent.Name).
|
Name(incompleteEvent.Name).
|
||||||
Body(data).
|
Body(data).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,11 @@ limitations under the License.
|
|||||||
|
|
||||||
package v1
|
package v1
|
||||||
|
|
||||||
import "k8s.io/api/core/v1"
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
|
)
|
||||||
|
|
||||||
// The NamespaceExpansion interface allows manually adding extra methods to the NamespaceInterface.
|
// The NamespaceExpansion interface allows manually adding extra methods to the NamespaceInterface.
|
||||||
type NamespaceExpansion interface {
|
type NamespaceExpansion interface {
|
||||||
@@ -26,6 +30,6 @@ type NamespaceExpansion interface {
|
|||||||
// Finalize takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs.
|
// Finalize takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs.
|
||||||
func (c *namespaces) Finalize(namespace *v1.Namespace) (result *v1.Namespace, err error) {
|
func (c *namespaces) Finalize(namespace *v1.Namespace) (result *v1.Namespace, err error) {
|
||||||
result = &v1.Namespace{}
|
result = &v1.Namespace{}
|
||||||
err = c.client.Put().Resource("namespaces").Name(namespace.Name).SubResource("finalize").Body(namespace).Do().Into(result)
|
err = c.client.Put().Resource("namespaces").Name(namespace.Name).SubResource("finalize").Body(namespace).Do(context.TODO()).Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,9 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/api/core/v1"
|
"context"
|
||||||
|
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -37,7 +39,7 @@ func (c *nodes) PatchStatus(nodeName string, data []byte) (*v1.Node, error) {
|
|||||||
Name(nodeName).
|
Name(nodeName).
|
||||||
SubResource("status").
|
SubResource("status").
|
||||||
Body(data).
|
Body(data).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,9 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/api/core/v1"
|
"context"
|
||||||
|
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
policy "k8s.io/api/policy/v1beta1"
|
policy "k8s.io/api/policy/v1beta1"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
@@ -32,11 +34,11 @@ type PodExpansion interface {
|
|||||||
|
|
||||||
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
||||||
func (c *pods) Bind(binding *v1.Binding) error {
|
func (c *pods) Bind(binding *v1.Binding) error {
|
||||||
return c.client.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do().Error()
|
return c.client.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do(context.TODO()).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *pods) Evict(eviction *policy.Eviction) error {
|
func (c *pods) Evict(eviction *policy.Eviction) error {
|
||||||
return c.client.Post().Namespace(c.ns).Resource("pods").Name(eviction.Name).SubResource("eviction").Body(eviction).Do().Error()
|
return c.client.Post().Namespace(c.ns).Resource("pods").Name(eviction.Name).SubResource("eviction").Body(eviction).Do(context.TODO()).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get constructs a request for getting the logs for a pod
|
// Get constructs a request for getting the logs for a pod
|
||||||
|
@@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
authenticationv1 "k8s.io/api/authentication/v1"
|
authenticationv1 "k8s.io/api/authentication/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,7 +37,7 @@ func (c *serviceAccounts) CreateToken(name string, tr *authenticationv1.TokenReq
|
|||||||
SubResource("token").
|
SubResource("token").
|
||||||
Name(name).
|
Name(name).
|
||||||
Body(tr).
|
Body(tr).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/api/events/v1beta1"
|
"k8s.io/api/events/v1beta1"
|
||||||
@@ -51,7 +52,7 @@ func (e *events) CreateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event,
|
|||||||
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
|
||||||
Resource("events").
|
Resource("events").
|
||||||
Body(event).
|
Body(event).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ func (e *events) UpdateWithEventNamespace(event *v1beta1.Event) (*v1beta1.Event,
|
|||||||
Resource("events").
|
Resource("events").
|
||||||
Name(event.Name).
|
Name(event.Name).
|
||||||
Body(event).
|
Body(event).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -92,7 +93,7 @@ func (e *events) PatchWithEventNamespace(event *v1beta1.Event, data []byte) (*v1
|
|||||||
Resource("events").
|
Resource("events").
|
||||||
Name(event.Name).
|
Name(event.Name).
|
||||||
Body(data).
|
Body(data).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(result)
|
Into(result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,11 @@ limitations under the License.
|
|||||||
|
|
||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import "k8s.io/api/extensions/v1beta1"
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"k8s.io/api/extensions/v1beta1"
|
||||||
|
)
|
||||||
|
|
||||||
// The DeploymentExpansion interface allows manually adding extra methods to the DeploymentInterface.
|
// The DeploymentExpansion interface allows manually adding extra methods to the DeploymentInterface.
|
||||||
type DeploymentExpansion interface {
|
type DeploymentExpansion interface {
|
||||||
@@ -25,5 +29,5 @@ type DeploymentExpansion interface {
|
|||||||
|
|
||||||
// Rollback applied the provided DeploymentRollback to the named deployment in the current namespace.
|
// Rollback applied the provided DeploymentRollback to the named deployment in the current namespace.
|
||||||
func (c *deployments) Rollback(deploymentRollback *v1beta1.DeploymentRollback) error {
|
func (c *deployments) Rollback(deploymentRollback *v1beta1.DeploymentRollback) error {
|
||||||
return c.client.Post().Namespace(c.ns).Resource("deployments").Name(deploymentRollback.Name).SubResource("rollback").Body(deploymentRollback).Do().Error()
|
return c.client.Post().Namespace(c.ns).Resource("deployments").Name(deploymentRollback.Name).SubResource("rollback").Body(deploymentRollback).Do(context.TODO()).Error()
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package v1beta1
|
package v1beta1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
policy "k8s.io/api/policy/v1beta1"
|
policy "k8s.io/api/policy/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,6 +35,6 @@ func (c *evictions) Evict(eviction *policy.Eviction) error {
|
|||||||
Name(eviction.Name).
|
Name(eviction.Name).
|
||||||
SubResource("eviction").
|
SubResource("eviction").
|
||||||
Body(eviction).
|
Body(eviction).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Error()
|
Error()
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package metadata
|
package metadata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
@@ -135,7 +136,7 @@ func (c *client) Delete(name string, opts *metav1.DeleteOptions, subresources ..
|
|||||||
Delete().
|
Delete().
|
||||||
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
Body(deleteOptionsByte).
|
Body(deleteOptionsByte).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
return result.Error()
|
return result.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +155,7 @@ func (c *client) DeleteCollection(opts *metav1.DeleteOptions, listOptions metav1
|
|||||||
AbsPath(c.makeURLSegments("")...).
|
AbsPath(c.makeURLSegments("")...).
|
||||||
Body(deleteOptionsByte).
|
Body(deleteOptionsByte).
|
||||||
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
return result.Error()
|
return result.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +167,7 @@ func (c *client) Get(name string, opts metav1.GetOptions, subresources ...string
|
|||||||
result := c.client.client.Get().AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
result := c.client.client.Get().AbsPath(append(c.makeURLSegments(name), subresources...)...).
|
||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -202,7 +203,7 @@ func (c *client) List(opts metav1.ListOptions) (*metav1.PartialObjectMetadataLis
|
|||||||
result := c.client.client.Get().AbsPath(c.makeURLSegments("")...).
|
result := c.client.client.Get().AbsPath(c.makeURLSegments("")...).
|
||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json").
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -242,7 +243,7 @@ func (c *client) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
|||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Timeout(timeout).
|
Timeout(timeout).
|
||||||
Watch()
|
Watch(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch modifies the named resource in the specified scope (namespace or cluster).
|
// Patch modifies the named resource in the specified scope (namespace or cluster).
|
||||||
@@ -256,7 +257,7 @@ func (c *client) Patch(name string, pt types.PatchType, data []byte, opts metav1
|
|||||||
Body(data).
|
Body(data).
|
||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json").
|
||||||
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package scale
|
package scale
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
autoscaling "k8s.io/api/autoscaling/v1"
|
autoscaling "k8s.io/api/autoscaling/v1"
|
||||||
@@ -154,7 +155,7 @@ func (c *namespacedScaleClient) Get(resource schema.GroupResource, name string)
|
|||||||
Resource(gvr.Resource).
|
Resource(gvr.Resource).
|
||||||
Name(name).
|
Name(name).
|
||||||
SubResource("scale").
|
SubResource("scale").
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -196,7 +197,7 @@ func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *aut
|
|||||||
Name(scale.Name).
|
Name(scale.Name).
|
||||||
SubResource("scale").
|
SubResource("scale").
|
||||||
Body(scaleUpdateBytes).
|
Body(scaleUpdateBytes).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
// propagate "raw" error from the API
|
// propagate "raw" error from the API
|
||||||
// this allows callers to interpret underlying Reason field
|
// this allows callers to interpret underlying Reason field
|
||||||
@@ -216,7 +217,7 @@ func (c *namespacedScaleClient) Patch(gvr schema.GroupVersionResource, name stri
|
|||||||
Name(name).
|
Name(name).
|
||||||
SubResource("scale").
|
SubResource("scale").
|
||||||
Body(data).
|
Body(data).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if err := result.Error(); err != nil {
|
if err := result.Error(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,8 @@ limitations under the License.
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@@ -82,7 +84,7 @@ func NewFilteredListWatchFromClient(c Getter, resource string, namespace string,
|
|||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Resource(resource).
|
Resource(resource).
|
||||||
VersionedParams(&options, metav1.ParameterCodec).
|
VersionedParams(&options, metav1.ParameterCodec).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
}
|
}
|
||||||
watchFunc := func(options metav1.ListOptions) (watch.Interface, error) {
|
watchFunc := func(options metav1.ListOptions) (watch.Interface, error) {
|
||||||
@@ -92,7 +94,7 @@ func NewFilteredListWatchFromClient(c Getter, resource string, namespace string,
|
|||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Resource(resource).
|
Resource(resource).
|
||||||
VersionedParams(&options, metav1.ParameterCodec).
|
VersionedParams(&options, metav1.ParameterCodec).
|
||||||
Watch()
|
Watch(context.TODO())
|
||||||
}
|
}
|
||||||
return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
|
return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ package rawhttp
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -80,7 +81,7 @@ func raw(restClient *rest.RESTClient, streams genericclioptions.IOStreams, url,
|
|||||||
return fmt.Errorf("unknown requestType: %q", requestType)
|
return fmt.Errorf("unknown requestType: %q", requestType)
|
||||||
}
|
}
|
||||||
|
|
||||||
stream, err := request.Stream()
|
stream, err := request.Stream(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package custom_metrics
|
package custom_metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
@@ -116,7 +117,7 @@ func (m *rootScopedMetrics) getForNamespace(namespace string, metricName string,
|
|||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Name(metricName).
|
Name(metricName).
|
||||||
VersionedParams(params, scheme.ParameterCodec).
|
VersionedParams(params, scheme.ParameterCodec).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
|
|
||||||
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -158,7 +159,7 @@ func (m *rootScopedMetrics) GetForObject(groupKind schema.GroupKind, name string
|
|||||||
Name(name).
|
Name(name).
|
||||||
SubResource(metricName).
|
SubResource(metricName).
|
||||||
VersionedParams(params, scheme.ParameterCodec).
|
VersionedParams(params, scheme.ParameterCodec).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
|
|
||||||
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -201,7 +202,7 @@ func (m *rootScopedMetrics) GetForObjects(groupKind schema.GroupKind, selector l
|
|||||||
Name(v1beta1.AllObjects).
|
Name(v1beta1.AllObjects).
|
||||||
SubResource(metricName).
|
SubResource(metricName).
|
||||||
VersionedParams(params, scheme.ParameterCodec).
|
VersionedParams(params, scheme.ParameterCodec).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
|
|
||||||
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -240,7 +241,7 @@ func (m *namespacedMetrics) GetForObject(groupKind schema.GroupKind, name string
|
|||||||
Name(name).
|
Name(name).
|
||||||
SubResource(metricName).
|
SubResource(metricName).
|
||||||
VersionedParams(params, scheme.ParameterCodec).
|
VersionedParams(params, scheme.ParameterCodec).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
|
|
||||||
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -279,7 +280,7 @@ func (m *namespacedMetrics) GetForObjects(groupKind schema.GroupKind, selector l
|
|||||||
Name(v1beta1.AllObjects).
|
Name(v1beta1.AllObjects).
|
||||||
SubResource(metricName).
|
SubResource(metricName).
|
||||||
VersionedParams(params, scheme.ParameterCodec).
|
VersionedParams(params, scheme.ParameterCodec).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
|
|
||||||
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
metricObj, err := versionConverter.ConvertResultToVersion(result, v1beta2.SchemeGroupVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package external_metrics
|
package external_metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -88,7 +89,7 @@ func (m *namespacedMetrics) List(metricName string, metricSelector labels.Select
|
|||||||
VersionedParams(&metav1.ListOptions{
|
VersionedParams(&metav1.ListOptions{
|
||||||
LabelSelector: metricSelector.String(),
|
LabelSelector: metricSelector.String(),
|
||||||
}, metav1.ParameterCodec).
|
}, metav1.ParameterCodec).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Into(res)
|
Into(res)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apimachinery
|
package apimachinery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -365,7 +366,7 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
|
|||||||
|
|
||||||
request := restClient.Get().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders")
|
request := restClient.Get().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders")
|
||||||
request.SetHeader("Accept", "application/json")
|
request.SetHeader("Accept", "application/json")
|
||||||
_, err := request.DoRaw()
|
_, err := request.DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
status, ok := err.(*apierrors.StatusError)
|
status, ok := err.(*apierrors.StatusError)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -405,7 +406,7 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
|
|||||||
// curl -k -v -XPOST https://localhost/apis/wardle.example.com/v1alpha1/namespaces/default/flunders
|
// curl -k -v -XPOST https://localhost/apis/wardle.example.com/v1alpha1/namespaces/default/flunders
|
||||||
// Request Body: {"apiVersion":"wardle.example.com/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"test-flunder","namespace":"default"}}
|
// Request Body: {"apiVersion":"wardle.example.com/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"test-flunder","namespace":"default"}}
|
||||||
flunder := `{"apiVersion":"wardle.example.com/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"` + flunderName + `","namespace":"default"}}`
|
flunder := `{"apiVersion":"wardle.example.com/v1alpha1","kind":"Flunder","metadata":{"labels":{"sample-label":"true"},"name":"` + flunderName + `","namespace":"default"}}`
|
||||||
result := restClient.Post().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders").Body([]byte(flunder)).SetHeader("Accept", "application/json").Do()
|
result := restClient.Post().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders").Body([]byte(flunder)).SetHeader("Accept", "application/json").Do(context.TODO())
|
||||||
framework.ExpectNoError(result.Error(), "creating a new flunders resource")
|
framework.ExpectNoError(result.Error(), "creating a new flunders resource")
|
||||||
var statusCode int
|
var statusCode int
|
||||||
result.StatusCode(&statusCode)
|
result.StatusCode(&statusCode)
|
||||||
@@ -425,7 +426,7 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
|
|||||||
|
|
||||||
// kubectl get flunders -v 9
|
// kubectl get flunders -v 9
|
||||||
// curl -k -v -XGET https://localhost/apis/wardle.example.com/v1alpha1/namespaces/default/flunders
|
// curl -k -v -XGET https://localhost/apis/wardle.example.com/v1alpha1/namespaces/default/flunders
|
||||||
contents, err := restClient.Get().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders").SetHeader("Accept", "application/json").DoRaw()
|
contents, err := restClient.Get().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders").SetHeader("Accept", "application/json").DoRaw(context.TODO())
|
||||||
framework.ExpectNoError(err, "attempting to get a newly created flunders resource")
|
framework.ExpectNoError(err, "attempting to get a newly created flunders resource")
|
||||||
var flundersList samplev1alpha1.FlunderList
|
var flundersList samplev1alpha1.FlunderList
|
||||||
err = json.Unmarshal(contents, &flundersList)
|
err = json.Unmarshal(contents, &flundersList)
|
||||||
@@ -436,12 +437,12 @@ func TestSampleAPIServer(f *framework.Framework, aggrclient *aggregatorclient.Cl
|
|||||||
|
|
||||||
// kubectl delete flunder test-flunder -v 9
|
// kubectl delete flunder test-flunder -v 9
|
||||||
// curl -k -v -XDELETE https://35.193.112.40/apis/wardle.example.com/v1alpha1/namespaces/default/flunders/test-flunder
|
// curl -k -v -XDELETE https://35.193.112.40/apis/wardle.example.com/v1alpha1/namespaces/default/flunders/test-flunder
|
||||||
_, err = restClient.Delete().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders/" + flunderName).DoRaw()
|
_, err = restClient.Delete().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders/" + flunderName).DoRaw(context.TODO())
|
||||||
validateErrorWithDebugInfo(f, err, pods, "attempting to delete a newly created flunders(%v) resource", flundersList.Items)
|
validateErrorWithDebugInfo(f, err, pods, "attempting to delete a newly created flunders(%v) resource", flundersList.Items)
|
||||||
|
|
||||||
// kubectl get flunders -v 9
|
// kubectl get flunders -v 9
|
||||||
// curl -k -v -XGET https://localhost/apis/wardle.example.com/v1alpha1/namespaces/default/flunders
|
// curl -k -v -XGET https://localhost/apis/wardle.example.com/v1alpha1/namespaces/default/flunders
|
||||||
contents, err = restClient.Get().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders").SetHeader("Accept", "application/json").DoRaw()
|
contents, err = restClient.Get().AbsPath("/apis/wardle.example.com/v1alpha1/namespaces/default/flunders").SetHeader("Accept", "application/json").DoRaw(context.TODO())
|
||||||
framework.ExpectNoError(err, "confirming delete of a newly created flunders resource")
|
framework.ExpectNoError(err, "confirming delete of a newly created flunders resource")
|
||||||
err = json.Unmarshal(contents, &flundersList)
|
err = json.Unmarshal(contents, &flundersList)
|
||||||
validateErrorWithDebugInfo(f, err, pods, "Error in unmarshalling %T response from server %s", contents, "/apis/wardle.example.com/v1alpha1")
|
validateErrorWithDebugInfo(f, err, pods, "Error in unmarshalling %T response from server %s", contents, "/apis/wardle.example.com/v1alpha1")
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apimachinery
|
package apimachinery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -197,7 +198,7 @@ var _ = SIGDescribe("CustomResourceDefinition resources [Privileged:ClusterAdmin
|
|||||||
{
|
{
|
||||||
ginkgo.By("fetching the /apis discovery document")
|
ginkgo.By("fetching the /apis discovery document")
|
||||||
apiGroupList := &metav1.APIGroupList{}
|
apiGroupList := &metav1.APIGroupList{}
|
||||||
err := f.ClientSet.Discovery().RESTClient().Get().AbsPath("/apis").Do().Into(apiGroupList)
|
err := f.ClientSet.Discovery().RESTClient().Get().AbsPath("/apis").Do(context.TODO()).Into(apiGroupList)
|
||||||
framework.ExpectNoError(err, "fetching /apis")
|
framework.ExpectNoError(err, "fetching /apis")
|
||||||
|
|
||||||
ginkgo.By("finding the apiextensions.k8s.io API group in the /apis discovery document")
|
ginkgo.By("finding the apiextensions.k8s.io API group in the /apis discovery document")
|
||||||
@@ -224,7 +225,7 @@ var _ = SIGDescribe("CustomResourceDefinition resources [Privileged:ClusterAdmin
|
|||||||
{
|
{
|
||||||
ginkgo.By("fetching the /apis/apiextensions.k8s.io discovery document")
|
ginkgo.By("fetching the /apis/apiextensions.k8s.io discovery document")
|
||||||
group := &metav1.APIGroup{}
|
group := &metav1.APIGroup{}
|
||||||
err := f.ClientSet.Discovery().RESTClient().Get().AbsPath("/apis/apiextensions.k8s.io").Do().Into(group)
|
err := f.ClientSet.Discovery().RESTClient().Get().AbsPath("/apis/apiextensions.k8s.io").Do(context.TODO()).Into(group)
|
||||||
framework.ExpectNoError(err, "fetching /apis/apiextensions.k8s.io")
|
framework.ExpectNoError(err, "fetching /apis/apiextensions.k8s.io")
|
||||||
framework.ExpectEqual(group.Name, v1.GroupName, "verifying API group name in /apis/apiextensions.k8s.io discovery document")
|
framework.ExpectEqual(group.Name, v1.GroupName, "verifying API group name in /apis/apiextensions.k8s.io discovery document")
|
||||||
|
|
||||||
@@ -242,7 +243,7 @@ var _ = SIGDescribe("CustomResourceDefinition resources [Privileged:ClusterAdmin
|
|||||||
{
|
{
|
||||||
ginkgo.By("fetching the /apis/apiextensions.k8s.io/v1 discovery document")
|
ginkgo.By("fetching the /apis/apiextensions.k8s.io/v1 discovery document")
|
||||||
apiResourceList := &metav1.APIResourceList{}
|
apiResourceList := &metav1.APIResourceList{}
|
||||||
err := f.ClientSet.Discovery().RESTClient().Get().AbsPath("/apis/apiextensions.k8s.io/v1").Do().Into(apiResourceList)
|
err := f.ClientSet.Discovery().RESTClient().Get().AbsPath("/apis/apiextensions.k8s.io/v1").Do(context.TODO()).Into(apiResourceList)
|
||||||
framework.ExpectNoError(err, "fetching /apis/apiextensions.k8s.io/v1")
|
framework.ExpectNoError(err, "fetching /apis/apiextensions.k8s.io/v1")
|
||||||
framework.ExpectEqual(apiResourceList.GroupVersion, v1.SchemeGroupVersion.String(), "verifying API group/version in /apis/apiextensions.k8s.io/v1 discovery document")
|
framework.ExpectEqual(apiResourceList.GroupVersion, v1.SchemeGroupVersion.String(), "verifying API group/version in /apis/apiextensions.k8s.io/v1 discovery document")
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ import (
|
|||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
|
||||||
authorizationv1 "k8s.io/api/authorization/v1"
|
authorizationv1 "k8s.io/api/authorization/v1"
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
|
||||||
@@ -59,7 +59,7 @@ var _ = SIGDescribe("Servers with support for Table transformation", func() {
|
|||||||
framework.ExpectNoError(err, "failed to create pod %s in namespace: %s", podName, ns)
|
framework.ExpectNoError(err, "failed to create pod %s in namespace: %s", podName, ns)
|
||||||
|
|
||||||
table := &metav1beta1.Table{}
|
table := &metav1beta1.Table{}
|
||||||
err = c.CoreV1().RESTClient().Get().Resource("pods").Namespace(ns).Name(podName).SetHeader("Accept", "application/json;as=Table;v=v1beta1;g=meta.k8s.io").Do().Into(table)
|
err = c.CoreV1().RESTClient().Get().Resource("pods").Namespace(ns).Name(podName).SetHeader("Accept", "application/json;as=Table;v=v1beta1;g=meta.k8s.io").Do(context.TODO()).Into(table)
|
||||||
framework.ExpectNoError(err, "failed to get pod %s in Table form in namespace: %s", podName, ns)
|
framework.ExpectNoError(err, "failed to get pod %s in Table form in namespace: %s", podName, ns)
|
||||||
framework.Logf("Table: %#v", table)
|
framework.Logf("Table: %#v", table)
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ var _ = SIGDescribe("Servers with support for Table transformation", func() {
|
|||||||
err := c.CoreV1().RESTClient().Get().Namespace(ns).Resource("podtemplates").
|
err := c.CoreV1().RESTClient().Get().Namespace(ns).Resource("podtemplates").
|
||||||
VersionedParams(&metav1.ListOptions{Limit: 2}, metav1.ParameterCodec).
|
VersionedParams(&metav1.ListOptions{Limit: 2}, metav1.ParameterCodec).
|
||||||
SetHeader("Accept", "application/json;as=Table;v=v1beta1;g=meta.k8s.io").
|
SetHeader("Accept", "application/json;as=Table;v=v1beta1;g=meta.k8s.io").
|
||||||
Do().Into(pagedTable)
|
Do(context.TODO()).Into(pagedTable)
|
||||||
framework.ExpectNoError(err, "failed to get pod templates in Table form in namespace: %s", ns)
|
framework.ExpectNoError(err, "failed to get pod templates in Table form in namespace: %s", ns)
|
||||||
framework.ExpectEqual(len(pagedTable.Rows), 2)
|
framework.ExpectEqual(len(pagedTable.Rows), 2)
|
||||||
framework.ExpectNotEqual(pagedTable.ResourceVersion, "")
|
framework.ExpectNotEqual(pagedTable.ResourceVersion, "")
|
||||||
@@ -119,7 +119,7 @@ var _ = SIGDescribe("Servers with support for Table transformation", func() {
|
|||||||
err = c.CoreV1().RESTClient().Get().Namespace(ns).Resource("podtemplates").
|
err = c.CoreV1().RESTClient().Get().Namespace(ns).Resource("podtemplates").
|
||||||
VersionedParams(&metav1.ListOptions{Continue: pagedTable.Continue}, metav1.ParameterCodec).
|
VersionedParams(&metav1.ListOptions{Continue: pagedTable.Continue}, metav1.ParameterCodec).
|
||||||
SetHeader("Accept", "application/json;as=Table;v=v1beta1;g=meta.k8s.io").
|
SetHeader("Accept", "application/json;as=Table;v=v1beta1;g=meta.k8s.io").
|
||||||
Do().Into(pagedTable)
|
Do(context.TODO()).Into(pagedTable)
|
||||||
framework.ExpectNoError(err, "failed to get pod templates in Table form in namespace: %s", ns)
|
framework.ExpectNoError(err, "failed to get pod templates in Table form in namespace: %s", ns)
|
||||||
gomega.Expect(len(pagedTable.Rows)).To(gomega.BeNumerically(">", 0))
|
gomega.Expect(len(pagedTable.Rows)).To(gomega.BeNumerically(">", 0))
|
||||||
framework.ExpectEqual(pagedTable.Rows[0].Cells[0], "template-0002")
|
framework.ExpectEqual(pagedTable.Rows[0].Cells[0], "template-0002")
|
||||||
@@ -129,7 +129,7 @@ var _ = SIGDescribe("Servers with support for Table transformation", func() {
|
|||||||
c := f.ClientSet
|
c := f.ClientSet
|
||||||
|
|
||||||
table := &metav1beta1.Table{}
|
table := &metav1beta1.Table{}
|
||||||
err := c.CoreV1().RESTClient().Get().Resource("nodes").SetHeader("Accept", "application/json;as=Table;v=v1beta1;g=meta.k8s.io").Do().Into(table)
|
err := c.CoreV1().RESTClient().Get().Resource("nodes").SetHeader("Accept", "application/json;as=Table;v=v1beta1;g=meta.k8s.io").Do(context.TODO()).Into(table)
|
||||||
framework.ExpectNoError(err, "failed to get nodes in Table form across all namespaces")
|
framework.ExpectNoError(err, "failed to get nodes in Table form across all namespaces")
|
||||||
framework.Logf("Table: %#v", table)
|
framework.Logf("Table: %#v", table)
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ var _ = SIGDescribe("Servers with support for Table transformation", func() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err := c.AuthorizationV1().RESTClient().Post().Resource("selfsubjectaccessreviews").SetHeader("Accept", "application/json;as=Table;v=v1;g=meta.k8s.io").Body(sar).Do().Into(table)
|
err := c.AuthorizationV1().RESTClient().Post().Resource("selfsubjectaccessreviews").SetHeader("Accept", "application/json;as=Table;v=v1;g=meta.k8s.io").Body(sar).Do(context.TODO()).Into(table)
|
||||||
framework.ExpectError(err, "failed to return error when posting self subject access review: %+v, to a backend that does not implement metadata", sar)
|
framework.ExpectError(err, "failed to return error when posting self subject access review: %+v, to a backend that does not implement metadata", sar)
|
||||||
framework.ExpectEqual(err.(apierrors.APIStatus).Status().Code, int32(406))
|
framework.ExpectEqual(err.(apierrors.APIStatus).Status().Code, int32(406))
|
||||||
})
|
})
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apimachinery
|
package apimachinery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -114,7 +115,7 @@ var _ = SIGDescribe("AdmissionWebhook [Privileged:ClusterAdmin]", func() {
|
|||||||
{
|
{
|
||||||
ginkgo.By("fetching the /apis discovery document")
|
ginkgo.By("fetching the /apis discovery document")
|
||||||
apiGroupList := &metav1.APIGroupList{}
|
apiGroupList := &metav1.APIGroupList{}
|
||||||
err := client.Discovery().RESTClient().Get().AbsPath("/apis").Do().Into(apiGroupList)
|
err := client.Discovery().RESTClient().Get().AbsPath("/apis").Do(context.TODO()).Into(apiGroupList)
|
||||||
framework.ExpectNoError(err, "fetching /apis")
|
framework.ExpectNoError(err, "fetching /apis")
|
||||||
|
|
||||||
ginkgo.By("finding the admissionregistration.k8s.io API group in the /apis discovery document")
|
ginkgo.By("finding the admissionregistration.k8s.io API group in the /apis discovery document")
|
||||||
@@ -141,7 +142,7 @@ var _ = SIGDescribe("AdmissionWebhook [Privileged:ClusterAdmin]", func() {
|
|||||||
{
|
{
|
||||||
ginkgo.By("fetching the /apis/admissionregistration.k8s.io discovery document")
|
ginkgo.By("fetching the /apis/admissionregistration.k8s.io discovery document")
|
||||||
group := &metav1.APIGroup{}
|
group := &metav1.APIGroup{}
|
||||||
err := client.Discovery().RESTClient().Get().AbsPath("/apis/admissionregistration.k8s.io").Do().Into(group)
|
err := client.Discovery().RESTClient().Get().AbsPath("/apis/admissionregistration.k8s.io").Do(context.TODO()).Into(group)
|
||||||
framework.ExpectNoError(err, "fetching /apis/admissionregistration.k8s.io")
|
framework.ExpectNoError(err, "fetching /apis/admissionregistration.k8s.io")
|
||||||
framework.ExpectEqual(group.Name, admissionregistrationv1.GroupName, "verifying API group name in /apis/admissionregistration.k8s.io discovery document")
|
framework.ExpectEqual(group.Name, admissionregistrationv1.GroupName, "verifying API group name in /apis/admissionregistration.k8s.io discovery document")
|
||||||
|
|
||||||
@@ -159,7 +160,7 @@ var _ = SIGDescribe("AdmissionWebhook [Privileged:ClusterAdmin]", func() {
|
|||||||
{
|
{
|
||||||
ginkgo.By("fetching the /apis/admissionregistration.k8s.io/v1 discovery document")
|
ginkgo.By("fetching the /apis/admissionregistration.k8s.io/v1 discovery document")
|
||||||
apiResourceList := &metav1.APIResourceList{}
|
apiResourceList := &metav1.APIResourceList{}
|
||||||
err := client.Discovery().RESTClient().Get().AbsPath("/apis/admissionregistration.k8s.io/v1").Do().Into(apiResourceList)
|
err := client.Discovery().RESTClient().Get().AbsPath("/apis/admissionregistration.k8s.io/v1").Do(context.TODO()).Into(apiResourceList)
|
||||||
framework.ExpectNoError(err, "fetching /apis/admissionregistration.k8s.io/v1")
|
framework.ExpectNoError(err, "fetching /apis/admissionregistration.k8s.io/v1")
|
||||||
framework.ExpectEqual(apiResourceList.GroupVersion, admissionregistrationv1.SchemeGroupVersion.String(), "verifying API group/version in /apis/admissionregistration.k8s.io/v1 discovery document")
|
framework.ExpectEqual(apiResourceList.GroupVersion, admissionregistrationv1.SchemeGroupVersion.String(), "verifying API group/version in /apis/admissionregistration.k8s.io/v1 discovery document")
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -733,7 +734,7 @@ func expectEvents(f *framework.Framework, expectedEvents []utils.AuditEvent) {
|
|||||||
pollingTimeout := 5 * time.Minute
|
pollingTimeout := 5 * time.Minute
|
||||||
err := wait.Poll(pollingInterval, pollingTimeout, func() (bool, error) {
|
err := wait.Poll(pollingInterval, pollingTimeout, func() (bool, error) {
|
||||||
// Fetch the log stream.
|
// Fetch the log stream.
|
||||||
stream, err := f.ClientSet.CoreV1().RESTClient().Get().AbsPath("/logs/kube-apiserver-audit.log").Stream()
|
stream, err := f.ClientSet.CoreV1().RESTClient().Get().AbsPath("/logs/kube-apiserver-audit.log").Stream(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
@@ -18,11 +18,12 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
@@ -64,7 +65,7 @@ var _ = framework.KubeDescribe("Kubelet", func() {
|
|||||||
})
|
})
|
||||||
gomega.Eventually(func() string {
|
gomega.Eventually(func() string {
|
||||||
sinceTime := metav1.NewTime(time.Now().Add(time.Duration(-1 * time.Hour)))
|
sinceTime := metav1.NewTime(time.Now().Add(time.Duration(-1 * time.Hour)))
|
||||||
rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{SinceTime: &sinceTime}).Stream()
|
rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{SinceTime: &sinceTime}).Stream(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -167,7 +168,7 @@ var _ = framework.KubeDescribe("Kubelet", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
gomega.Eventually(func() error {
|
gomega.Eventually(func() error {
|
||||||
rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{}).Stream()
|
rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{}).Stream(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -215,7 +216,7 @@ var _ = framework.KubeDescribe("Kubelet", func() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
gomega.Eventually(func() string {
|
gomega.Eventually(func() string {
|
||||||
rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{}).Stream()
|
rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{}).Stream(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,7 @@ import (
|
|||||||
testutils "k8s.io/kubernetes/test/utils"
|
testutils "k8s.io/kubernetes/test/utils"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
|
|
||||||
scaleclient "k8s.io/client-go/scale"
|
scaleclient "k8s.io/client-go/scale"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
)
|
)
|
||||||
@@ -253,7 +254,7 @@ func (rc *ResourceConsumer) sendConsumeCPURequest(millicores int) {
|
|||||||
Param("durationSec", strconv.Itoa(rc.consumptionTimeInSeconds)).
|
Param("durationSec", strconv.Itoa(rc.consumptionTimeInSeconds)).
|
||||||
Param("requestSizeMillicores", strconv.Itoa(rc.requestSizeInMillicores))
|
Param("requestSizeMillicores", strconv.Itoa(rc.requestSizeInMillicores))
|
||||||
framework.Logf("ConsumeCPU URL: %v", *req.URL())
|
framework.Logf("ConsumeCPU URL: %v", *req.URL())
|
||||||
_, err = req.DoRaw()
|
_, err = req.DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("ConsumeCPU failure: %v", err)
|
framework.Logf("ConsumeCPU failure: %v", err)
|
||||||
return false, nil
|
return false, nil
|
||||||
@@ -280,7 +281,7 @@ func (rc *ResourceConsumer) sendConsumeMemRequest(megabytes int) {
|
|||||||
Param("durationSec", strconv.Itoa(rc.consumptionTimeInSeconds)).
|
Param("durationSec", strconv.Itoa(rc.consumptionTimeInSeconds)).
|
||||||
Param("requestSizeMegabytes", strconv.Itoa(rc.requestSizeInMegabytes))
|
Param("requestSizeMegabytes", strconv.Itoa(rc.requestSizeInMegabytes))
|
||||||
framework.Logf("ConsumeMem URL: %v", *req.URL())
|
framework.Logf("ConsumeMem URL: %v", *req.URL())
|
||||||
_, err = req.DoRaw()
|
_, err = req.DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("ConsumeMem failure: %v", err)
|
framework.Logf("ConsumeMem failure: %v", err)
|
||||||
return false, nil
|
return false, nil
|
||||||
@@ -308,7 +309,7 @@ func (rc *ResourceConsumer) sendConsumeCustomMetric(delta int) {
|
|||||||
Param("durationSec", strconv.Itoa(rc.consumptionTimeInSeconds)).
|
Param("durationSec", strconv.Itoa(rc.consumptionTimeInSeconds)).
|
||||||
Param("requestSizeMetrics", strconv.Itoa(rc.requestSizeCustomMetric))
|
Param("requestSizeMetrics", strconv.Itoa(rc.requestSizeCustomMetric))
|
||||||
framework.Logf("ConsumeCustomMetric URL: %v", *req.URL())
|
framework.Logf("ConsumeCustomMetric URL: %v", *req.URL())
|
||||||
_, err = req.DoRaw()
|
_, err = req.DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("ConsumeCustomMetric failure: %v", err)
|
framework.Logf("ConsumeCustomMetric failure: %v", err)
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@@ -98,7 +98,7 @@ func ProxyRequest(c clientset.Interface, node, endpoint string, port int) (restc
|
|||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(fmt.Sprintf("%v:%v", node, port)).
|
Name(fmt.Sprintf("%v:%v", node, port)).
|
||||||
Suffix(endpoint).
|
Suffix(endpoint).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
|
|
||||||
finished <- struct{}{}
|
finished <- struct{}{}
|
||||||
}()
|
}()
|
||||||
@@ -225,7 +225,7 @@ func GetStatsSummary(c clientset.Interface, nodeName string) (*kubeletstatsv1alp
|
|||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(fmt.Sprintf("%v:%v", nodeName, ports.KubeletPort)).
|
Name(fmt.Sprintf("%v:%v", nodeName, ports.KubeletPort)).
|
||||||
Suffix("stats/summary").
|
Suffix("stats/summary").
|
||||||
Do().Raw()
|
Do(context.TODO()).Raw()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -246,7 +246,7 @@ func getNodeStatsSummary(c clientset.Interface, nodeName string) (*kubeletstatsv
|
|||||||
Name(fmt.Sprintf("%v:%v", nodeName, ports.KubeletPort)).
|
Name(fmt.Sprintf("%v:%v", nodeName, ports.KubeletPort)).
|
||||||
Suffix("stats/summary").
|
Suffix("stats/summary").
|
||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
Do().Raw()
|
Do(context.TODO()).Raw()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@@ -16,7 +16,11 @@ limitations under the License.
|
|||||||
|
|
||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import "k8s.io/component-base/metrics/testutil"
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"k8s.io/component-base/metrics/testutil"
|
||||||
|
)
|
||||||
|
|
||||||
// APIServerMetrics is metrics for API server
|
// APIServerMetrics is metrics for API server
|
||||||
type APIServerMetrics testutil.Metrics
|
type APIServerMetrics testutil.Metrics
|
||||||
@@ -40,7 +44,7 @@ func parseAPIServerMetrics(data string) (APIServerMetrics, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Grabber) getMetricsFromAPIServer() (string, error) {
|
func (g *Grabber) getMetricsFromAPIServer() (string, error) {
|
||||||
rawOutput, err := g.client.CoreV1().RESTClient().Get().RequestURI("/metrics").Do().Raw()
|
rawOutput, err := g.client.CoreV1().RESTClient().Get().RequestURI("/metrics").Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -85,7 +86,7 @@ func (g *Grabber) getMetricsFromNode(nodeName string, kubeletPort int) (string,
|
|||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(fmt.Sprintf("%v:%v", nodeName, kubeletPort)).
|
Name(fmt.Sprintf("%v:%v", nodeName, kubeletPort)).
|
||||||
Suffix("metrics").
|
Suffix("metrics").
|
||||||
Do().Raw()
|
Do(context.TODO()).Raw()
|
||||||
finished <- struct{}{}
|
finished <- struct{}{}
|
||||||
}()
|
}()
|
||||||
select {
|
select {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -241,7 +242,7 @@ func (g *Grabber) getMetricsFromPod(client clientset.Interface, podName string,
|
|||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(fmt.Sprintf("%v:%v", podName, port)).
|
Name(fmt.Sprintf("%v:%v", podName, port)).
|
||||||
Suffix("metrics").
|
Suffix("metrics").
|
||||||
Do().Raw()
|
Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@@ -103,7 +103,7 @@ func (r ProxyResponseChecker) CheckAllResponses() (done bool, err error) {
|
|||||||
Resource("pods").
|
Resource("pods").
|
||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(string(pod.Name)).
|
Name(string(pod.Name)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Raw()
|
Raw()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -516,7 +516,7 @@ func getPodLogsInternal(c clientset.Interface, namespace, podName, containerName
|
|||||||
Name(podName).SubResource("log").
|
Name(podName).SubResource("log").
|
||||||
Param("container", containerName).
|
Param("container", containerName).
|
||||||
Param("previous", strconv.FormatBool(previous)).
|
Param("previous", strconv.FormatBool(previous)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Raw()
|
Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@@ -36,7 +36,7 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
)
|
)
|
||||||
@@ -48,7 +48,7 @@ import (
|
|||||||
// when the pod gets deleted while streaming.
|
// when the pod gets deleted while streaming.
|
||||||
func LogsForPod(ctx context.Context, cs clientset.Interface, ns, pod string, opts *v1.PodLogOptions) (io.ReadCloser, error) {
|
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)
|
req := cs.CoreV1().Pods(ns).GetLogs(pod, opts)
|
||||||
return req.Context(ctx).Stream()
|
return req.Context(ctx).Stream(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogOutput determines where output from CopyAllLogs goes.
|
// LogOutput determines where output from CopyAllLogs goes.
|
||||||
|
@@ -299,7 +299,7 @@ func getStatsSummary(c clientset.Interface, nodeName string) (*kubeletstatsv1alp
|
|||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(fmt.Sprintf("%v:%v", nodeName, ports.KubeletPort)).
|
Name(fmt.Sprintf("%v:%v", nodeName, ports.KubeletPort)).
|
||||||
Suffix("stats/summary").
|
Suffix("stats/summary").
|
||||||
Do().Raw()
|
Do(context.TODO()).Raw()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@@ -38,6 +38,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/websocket"
|
"golang.org/x/net/websocket"
|
||||||
|
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
@@ -1017,7 +1018,7 @@ func getKubeletPods(c clientset.Interface, node string) (*v1.PodList, error) {
|
|||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(fmt.Sprintf("%v:%v", node, ports.KubeletPort)).
|
Name(fmt.Sprintf("%v:%v", node, ports.KubeletPort)).
|
||||||
Suffix("pods").
|
Suffix("pods").
|
||||||
Do()
|
Do(context.TODO())
|
||||||
|
|
||||||
finished <- struct{}{}
|
finished <- struct{}{}
|
||||||
}()
|
}()
|
||||||
|
@@ -96,7 +96,7 @@ func ClusterLevelLoggingWithKibana(f *framework.Framework) {
|
|||||||
_, err = req.Namespace(metav1.NamespaceSystem).
|
_, err = req.Namespace(metav1.NamespaceSystem).
|
||||||
Context(ctx).
|
Context(ctx).
|
||||||
Name("kibana-logging").
|
Name("kibana-logging").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("Proxy call to kibana-logging failed: %v", err)
|
framework.Logf("Proxy call to kibana-logging failed: %v", err)
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package elasticsearch
|
package elasticsearch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -100,7 +101,7 @@ func (p *esLogProvider) Init() error {
|
|||||||
// Query against the root URL for Elasticsearch.
|
// Query against the root URL for Elasticsearch.
|
||||||
response := proxyRequest.Namespace(api.NamespaceSystem).
|
response := proxyRequest.Namespace(api.NamespaceSystem).
|
||||||
Name("elasticsearch-logging").
|
Name("elasticsearch-logging").
|
||||||
Do()
|
Do(context.TODO())
|
||||||
err = response.Error()
|
err = response.Error()
|
||||||
response.StatusCode(&statusCode)
|
response.StatusCode(&statusCode)
|
||||||
|
|
||||||
@@ -135,7 +136,7 @@ func (p *esLogProvider) Init() error {
|
|||||||
Name("elasticsearch-logging").
|
Name("elasticsearch-logging").
|
||||||
Suffix("_cluster/health").
|
Suffix("_cluster/health").
|
||||||
Param("level", "indices").
|
Param("level", "indices").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -189,9 +190,8 @@ func (p *esLogProvider) ReadEntries(name string) []utils.LogEntry {
|
|||||||
Name("elasticsearch-logging").
|
Name("elasticsearch-logging").
|
||||||
Suffix("_search").
|
Suffix("_search").
|
||||||
Param("q", query).
|
Param("q", query).
|
||||||
// Ask for more in case we included some unrelated records in our query
|
|
||||||
Param("size", strconv.Itoa(searchPageSize)).
|
Param("size", strconv.Itoa(searchPageSize)).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("Failed to make proxy call to elasticsearch-logging: %v", err)
|
framework.Logf("Failed to make proxy call to elasticsearch-logging: %v", err)
|
||||||
return nil
|
return nil
|
||||||
|
@@ -42,6 +42,8 @@ import (
|
|||||||
"github.com/elazarl/goproxy"
|
"github.com/elazarl/goproxy"
|
||||||
openapi_v2 "github.com/googleapis/gnostic/OpenAPIv2"
|
openapi_v2 "github.com/googleapis/gnostic/OpenAPIv2"
|
||||||
|
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
@@ -83,7 +85,6 @@ import (
|
|||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
uexec "k8s.io/utils/exec"
|
uexec "k8s.io/utils/exec"
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/pointer"
|
||||||
"sigs.k8s.io/yaml"
|
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
@@ -2373,7 +2374,7 @@ func makeRequestToGuestbook(c clientset.Interface, cmd, value string, ns string)
|
|||||||
Param("cmd", cmd).
|
Param("cmd", cmd).
|
||||||
Param("key", "messages").
|
Param("key", "messages").
|
||||||
Param("value", value).
|
Param("value", value).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Raw()
|
Raw()
|
||||||
return string(result), err
|
return string(result), err
|
||||||
}
|
}
|
||||||
@@ -2458,7 +2459,7 @@ func getUDData(jpgExpected string, ns string) func(clientset.Interface, string)
|
|||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(podID).
|
Name(podID).
|
||||||
Suffix("data.json").
|
Suffix("data.json").
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Raw()
|
Raw()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -26,6 +26,7 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
dnsutil "github.com/miekg/dns"
|
dnsutil "github.com/miekg/dns"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
@@ -533,7 +534,7 @@ func assertFilesContain(fileNames []string, fileDir string, pod *v1.Pod, client
|
|||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(pod.Name).
|
Name(pod.Name).
|
||||||
Suffix(fileDir, fileName).
|
Suffix(fileDir, fileName).
|
||||||
Do().Raw()
|
Do(context.TODO()).Raw()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
|
@@ -26,6 +26,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
@@ -194,7 +195,7 @@ func waitForServiceResponding(c clientset.Interface, ns, name string) error {
|
|||||||
body, err := proxyRequest.Namespace(ns).
|
body, err := proxyRequest.Namespace(ns).
|
||||||
Context(ctx).
|
Context(ctx).
|
||||||
Name(name).
|
Name(name).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Raw()
|
Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -138,7 +139,7 @@ var _ = SIGDescribe("Networking", func() {
|
|||||||
ginkgo.By(fmt.Sprintf("testing: %s", test.path))
|
ginkgo.By(fmt.Sprintf("testing: %s", test.path))
|
||||||
data, err := f.ClientSet.CoreV1().RESTClient().Get().
|
data, err := f.ClientSet.CoreV1().RESTClient().Get().
|
||||||
AbsPath(test.path).
|
AbsPath(test.path).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Failf("ginkgo.Failed: %v\nBody: %s", err, string(data))
|
framework.Failf("ginkgo.Failed: %v\nBody: %s", err, string(data))
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ limitations under the License.
|
|||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -249,7 +250,7 @@ var _ = SIGDescribe("Proxy", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(errs) != 0 {
|
if len(errs) != 0 {
|
||||||
body, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).GetLogs(pods[0].Name, &v1.PodLogOptions{}).Do().Raw()
|
body, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).GetLogs(pods[0].Name, &v1.PodLogOptions{}).Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("Error getting logs for pod %s: %v", pods[0].Name, err)
|
framework.Logf("Error getting logs for pod %s: %v", pods[0].Name, err)
|
||||||
} else {
|
} else {
|
||||||
@@ -270,7 +271,7 @@ func doProxy(f *framework.Framework, path string, i int) (body []byte, statusCod
|
|||||||
// chance of the things we are talking to being confused for an error
|
// chance of the things we are talking to being confused for an error
|
||||||
// that apiserver would have emitted.
|
// that apiserver would have emitted.
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
body, err = f.ClientSet.CoreV1().RESTClient().Get().AbsPath(path).Do().StatusCode(&statusCode).Raw()
|
body, err = f.ClientSet.CoreV1().RESTClient().Get().AbsPath(path).Do(context.TODO()).StatusCode(&statusCode).Raw()
|
||||||
d = time.Since(start)
|
d = time.Since(start)
|
||||||
if len(body) > 0 {
|
if len(body) > 0 {
|
||||||
framework.Logf("(%v) %v: %s (%v; %v)", i, path, truncate(body, maxDisplayBodyLen), statusCode, d)
|
framework.Logf("(%v) %v: %s (%v; %v)", i, path, truncate(body, maxDisplayBodyLen), statusCode, d)
|
||||||
|
@@ -18,6 +18,7 @@ package network
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@@ -674,7 +675,7 @@ func restartKubeProxy(host string) error {
|
|||||||
// waitForApiserverUp waits for the kube-apiserver to be up.
|
// waitForApiserverUp waits for the kube-apiserver to be up.
|
||||||
func waitForApiserverUp(c clientset.Interface) error {
|
func waitForApiserverUp(c clientset.Interface) error {
|
||||||
for start := time.Now(); time.Since(start) < time.Minute; time.Sleep(5 * time.Second) {
|
for start := time.Now(); time.Since(start) < time.Minute; time.Sleep(5 * time.Second) {
|
||||||
body, err := c.CoreV1().RESTClient().Get().AbsPath("/healthz").Do().Raw()
|
body, err := c.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(context.TODO()).Raw()
|
||||||
if err == nil && string(body) == "ok" {
|
if err == nil && string(body) == "ok" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package node
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -103,7 +104,7 @@ var _ = SIGDescribe("Pods Extended", func() {
|
|||||||
ginkgo.By("deleting the pod gracefully")
|
ginkgo.By("deleting the pod gracefully")
|
||||||
var lastPod v1.Pod
|
var lastPod v1.Pod
|
||||||
var statusCode int
|
var statusCode int
|
||||||
err = f.ClientSet.CoreV1().RESTClient().Delete().AbsPath("/api/v1/namespaces", pod.Namespace, "pods", pod.Name).Param("gracePeriodSeconds", "30").Do().StatusCode(&statusCode).Into(&lastPod)
|
err = f.ClientSet.CoreV1().RESTClient().Delete().AbsPath("/api/v1/namespaces", pod.Namespace, "pods", pod.Name).Param("gracePeriodSeconds", "30").Do(context.TODO()).StatusCode(&statusCode).Into(&lastPod)
|
||||||
framework.ExpectNoError(err, "failed to use http client to send delete")
|
framework.ExpectNoError(err, "failed to use http client to send delete")
|
||||||
framework.ExpectEqual(statusCode, http.StatusOK, "failed to delete gracefully by client request")
|
framework.ExpectEqual(statusCode, http.StatusOK, "failed to delete gracefully by client request")
|
||||||
|
|
||||||
|
@@ -141,7 +141,7 @@ func testPreStop(c clientset.Interface, ns string) {
|
|||||||
SubResource("proxy").
|
SubResource("proxy").
|
||||||
Name(podDescr.Name).
|
Name(podDescr.Name).
|
||||||
Suffix("read").
|
Suffix("read").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package testsuites
|
package testsuites
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -608,7 +609,7 @@ func StopPod(c clientset.Interface, pod *v1.Pod) {
|
|||||||
if pod == nil {
|
if pod == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
body, err := c.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &v1.PodLogOptions{}).Do().Raw()
|
body, err := c.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &v1.PodLogOptions{}).Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("Error getting logs for pod %s: %v", pod.Name, err)
|
framework.Logf("Error getting logs for pod %s: %v", pod.Name, err)
|
||||||
} else {
|
} else {
|
||||||
|
@@ -75,7 +75,7 @@ var _ = SIGDescribe("Kubernetes Dashboard [Feature:Dashboard]", func() {
|
|||||||
Context(ctx).
|
Context(ctx).
|
||||||
Name(utilnet.JoinSchemeNamePort("https", uiServiceName, "")).
|
Name(utilnet.JoinSchemeNamePort("https", uiServiceName, "")).
|
||||||
Timeout(framework.SingleCallTimeout).
|
Timeout(framework.SingleCallTimeout).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
StatusCode(&status).
|
StatusCode(&status).
|
||||||
Error()
|
Error()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -19,12 +19,13 @@ limitations under the License.
|
|||||||
package e2enode
|
package e2enode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
@@ -383,7 +384,7 @@ var _ = framework.KubeDescribe("NodeProblemDetector [NodeFeature:NodeProblemDete
|
|||||||
gomega.Expect(c.CoreV1().Events(eventNamespace).DeleteCollection(metav1.NewDeleteOptions(0), eventListOptions)).To(gomega.Succeed())
|
gomega.Expect(c.CoreV1().Events(eventNamespace).DeleteCollection(metav1.NewDeleteOptions(0), eventListOptions)).To(gomega.Succeed())
|
||||||
ginkgo.By("Clean up the node condition")
|
ginkgo.By("Clean up the node condition")
|
||||||
patch := []byte(fmt.Sprintf(`{"status":{"conditions":[{"$patch":"delete","type":"%s"}]}}`, condition))
|
patch := []byte(fmt.Sprintf(`{"status":{"conditions":[{"$patch":"delete","type":"%s"}]}}`, condition))
|
||||||
c.CoreV1().RESTClient().Patch(types.StrategicMergePatchType).Resource("nodes").Name(framework.TestContext.NodeName).SubResource("status").Body(patch).Do()
|
c.CoreV1().RESTClient().Patch(types.StrategicMergePatchType).Resource("nodes").Name(framework.TestContext.NodeName).SubResource("status").Body(patch).Do(context.TODO())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package inclusterclient
|
package inclusterclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"flag"
|
"flag"
|
||||||
@@ -77,7 +78,7 @@ func main(cmd *cobra.Command, args []string) {
|
|||||||
for {
|
for {
|
||||||
<-t
|
<-t
|
||||||
klog.Infof("calling /healthz")
|
klog.Infof("calling /healthz")
|
||||||
b, err := c.Get().AbsPath("/healthz").Do().Raw()
|
b, err := c.Get().AbsPath("/healthz").Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("status=failed")
|
klog.Errorf("status=failed")
|
||||||
klog.Errorf("error checking /healthz: %v\n%s\n", err, string(b))
|
klog.Errorf("error checking /healthz: %v\n%s\n", err, string(b))
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package admissionwebhook
|
package admissionwebhook
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -1016,11 +1017,11 @@ func testPodConnectSubresource(c *testContext) {
|
|||||||
var err error
|
var err error
|
||||||
switch c.gvr {
|
switch c.gvr {
|
||||||
case gvr("", "v1", "pods/exec"):
|
case gvr("", "v1", "pods/exec"):
|
||||||
err = c.clientset.CoreV1().RESTClient().Verb(httpMethod).Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("exec").Do().Error()
|
err = c.clientset.CoreV1().RESTClient().Verb(httpMethod).Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("exec").Do(context.TODO()).Error()
|
||||||
case gvr("", "v1", "pods/attach"):
|
case gvr("", "v1", "pods/attach"):
|
||||||
err = c.clientset.CoreV1().RESTClient().Verb(httpMethod).Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("attach").Do().Error()
|
err = c.clientset.CoreV1().RESTClient().Verb(httpMethod).Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("attach").Do(context.TODO()).Error()
|
||||||
case gvr("", "v1", "pods/portforward"):
|
case gvr("", "v1", "pods/portforward"):
|
||||||
err = c.clientset.CoreV1().RESTClient().Verb(httpMethod).Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("portforward").Do().Error()
|
err = c.clientset.CoreV1().RESTClient().Verb(httpMethod).Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("portforward").Do(context.TODO()).Error()
|
||||||
default:
|
default:
|
||||||
c.t.Errorf("unknown subresource %#v", c.gvr)
|
c.t.Errorf("unknown subresource %#v", c.gvr)
|
||||||
return
|
return
|
||||||
@@ -1061,19 +1062,19 @@ func testPodBindingEviction(c *testContext) {
|
|||||||
err = c.clientset.CoreV1().RESTClient().Post().Namespace(pod.GetNamespace()).Resource("bindings").Body(&corev1.Binding{
|
err = c.clientset.CoreV1().RESTClient().Post().Namespace(pod.GetNamespace()).Resource("bindings").Body(&corev1.Binding{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: pod.GetName()},
|
ObjectMeta: metav1.ObjectMeta{Name: pod.GetName()},
|
||||||
Target: corev1.ObjectReference{Name: "foo", Kind: "Node", APIVersion: "v1"},
|
Target: corev1.ObjectReference{Name: "foo", Kind: "Node", APIVersion: "v1"},
|
||||||
}).Do().Error()
|
}).Do(context.TODO()).Error()
|
||||||
|
|
||||||
case gvr("", "v1", "pods/binding"):
|
case gvr("", "v1", "pods/binding"):
|
||||||
err = c.clientset.CoreV1().RESTClient().Post().Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("binding").Body(&corev1.Binding{
|
err = c.clientset.CoreV1().RESTClient().Post().Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("binding").Body(&corev1.Binding{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: pod.GetName()},
|
ObjectMeta: metav1.ObjectMeta{Name: pod.GetName()},
|
||||||
Target: corev1.ObjectReference{Name: "foo", Kind: "Node", APIVersion: "v1"},
|
Target: corev1.ObjectReference{Name: "foo", Kind: "Node", APIVersion: "v1"},
|
||||||
}).Do().Error()
|
}).Do(context.TODO()).Error()
|
||||||
|
|
||||||
case gvr("", "v1", "pods/eviction"):
|
case gvr("", "v1", "pods/eviction"):
|
||||||
err = c.clientset.CoreV1().RESTClient().Post().Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("eviction").Body(&policyv1beta1.Eviction{
|
err = c.clientset.CoreV1().RESTClient().Post().Namespace(pod.GetNamespace()).Resource("pods").Name(pod.GetName()).SubResource("eviction").Body(&policyv1beta1.Eviction{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: pod.GetName()},
|
ObjectMeta: metav1.ObjectMeta{Name: pod.GetName()},
|
||||||
DeleteOptions: forceDelete,
|
DeleteOptions: forceDelete,
|
||||||
}).Do().Error()
|
}).Do(context.TODO()).Error()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
c.t.Errorf("unhandled resource %#v", c.gvr)
|
c.t.Errorf("unhandled resource %#v", c.gvr)
|
||||||
@@ -1124,7 +1125,7 @@ func testSubresourceProxy(c *testContext) {
|
|||||||
// set expectations
|
// set expectations
|
||||||
c.admissionHolder.expect(c.gvr, gvk(c.resource.Group, c.resource.Version, c.resource.Kind), schema.GroupVersionKind{}, v1beta1.Connect, obj.GetName(), obj.GetNamespace(), true, false, false)
|
c.admissionHolder.expect(c.gvr, gvk(c.resource.Group, c.resource.Version, c.resource.Kind), schema.GroupVersionKind{}, v1beta1.Connect, obj.GetName(), obj.GetNamespace(), true, false, false)
|
||||||
// run the request. we don't actually care if the request is successful, just that admission gets called as expected
|
// run the request. we don't actually care if the request is successful, just that admission gets called as expected
|
||||||
err = request.Resource(gvrWithoutSubresources.Resource).Name(obj.GetName()).SubResource(subresources...).Do().Error()
|
err = request.Resource(gvrWithoutSubresources.Resource).Name(obj.GetName()).SubResource(subresources...).Do(context.TODO()).Error()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.t.Logf("debug: result of subresource proxy (error expected): %v", err)
|
c.t.Logf("debug: result of subresource proxy (error expected): %v", err)
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package admissionwebhook
|
package admissionwebhook
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -291,7 +292,7 @@ func testWebhookTimeout(t *testing.T, watchCache bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the timeout parameter manually so we don't actually cut off the request client-side, and wait for the server response
|
// set the timeout parameter manually so we don't actually cut off the request client-side, and wait for the server response
|
||||||
err = client.CoreV1().RESTClient().Post().Resource("pods").Namespace(ns).Body(body).Param("timeout", fmt.Sprintf("%ds", tt.timeoutSeconds)).Do().Error()
|
err = client.CoreV1().RESTClient().Post().Resource("pods").Namespace(ns).Body(body).Param("timeout", fmt.Sprintf("%ds", tt.timeoutSeconds)).Do(context.TODO()).Error()
|
||||||
// _, err = testClient.CoreV1().Pods(ns).Create(pod)
|
// _, err = testClient.CoreV1().Pods(ns).Create(pod)
|
||||||
|
|
||||||
if tt.expectError {
|
if tt.expectError {
|
||||||
|
@@ -188,7 +188,7 @@ func Test4xxStatusCodeInvalidPatch(t *testing.T) {
|
|||||||
AbsPath("/apis/apps/v1").
|
AbsPath("/apis/apps/v1").
|
||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Body(obj).Do().Get()
|
Body(obj).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object: %v: %v", err, resp)
|
t.Fatalf("Failed to create object: %v: %v", err, resp)
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ func Test4xxStatusCodeInvalidPatch(t *testing.T) {
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Body([]byte(`{"metadata":{"annotations":{"foo":["bar"]}}}`)).Do()
|
Body([]byte(`{"metadata":{"annotations":{"foo":["bar"]}}}`)).Do(context.TODO())
|
||||||
var statusCode int
|
var statusCode int
|
||||||
result.StatusCode(&statusCode)
|
result.StatusCode(&statusCode)
|
||||||
if statusCode != 422 {
|
if statusCode != 422 {
|
||||||
@@ -208,7 +208,7 @@ func Test4xxStatusCodeInvalidPatch(t *testing.T) {
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Body([]byte(`{"metadata":{"annotations":{"foo":["bar"]}}}`)).Do()
|
Body([]byte(`{"metadata":{"annotations":{"foo":["bar"]}}}`)).Do(context.TODO())
|
||||||
result.StatusCode(&statusCode)
|
result.StatusCode(&statusCode)
|
||||||
if statusCode != 422 {
|
if statusCode != 422 {
|
||||||
t.Fatalf("Expected status code to be 422, got %v (%#v)", statusCode, result)
|
t.Fatalf("Expected status code to be 422, got %v (%#v)", statusCode, result)
|
||||||
@@ -998,7 +998,7 @@ func TestAPICRDProtobuf(t *testing.T) {
|
|||||||
w, err := client.Get().
|
w, err := client.Get().
|
||||||
Resource(resource).NamespaceIfScoped(obj.GetNamespace(), len(obj.GetNamespace()) > 0).Name(obj.GetName()).SubResource(tc.subresource).
|
Resource(resource).NamespaceIfScoped(obj.GetNamespace(), len(obj.GetNamespace()) > 0).Name(obj.GetName()).SubResource(tc.subresource).
|
||||||
SetHeader("Accept", tc.accept).
|
SetHeader("Accept", tc.accept).
|
||||||
Stream()
|
Stream(context.TODO())
|
||||||
if (tc.wantErr != nil) != (err != nil) {
|
if (tc.wantErr != nil) != (err != nil) {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1611,7 +1611,7 @@ func TestTransform(t *testing.T) {
|
|||||||
FieldSelector: fields.OneTermEqualSelector("metadata.name", obj.GetName()).String(),
|
FieldSelector: fields.OneTermEqualSelector("metadata.name", obj.GetName()).String(),
|
||||||
}, metav1.ParameterCodec).
|
}, metav1.ParameterCodec).
|
||||||
Param("includeObject", string(tc.includeObject)).
|
Param("includeObject", string(tc.includeObject)).
|
||||||
Stream()
|
Stream(context.TODO())
|
||||||
if (tc.wantErr != nil) != (err != nil) {
|
if (tc.wantErr != nil) != (err != nil) {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apiserver
|
package apiserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -81,7 +82,7 @@ spec:
|
|||||||
Name(name).
|
Name(name).
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create custom resource with apply: %v:\n%v", err, string(result))
|
t.Fatalf("failed to create custom resource with apply: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -92,7 +93,7 @@ spec:
|
|||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Name(name).
|
Name(name).
|
||||||
Body([]byte(`{"spec":{"replicas": 5}}`)).
|
Body([]byte(`{"spec":{"replicas": 5}}`)).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to update number of replicas with merge patch: %v:\n%v", err, string(result))
|
t.Fatalf("failed to update number of replicas with merge patch: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -104,7 +105,7 @@ spec:
|
|||||||
Name(name).
|
Name(name).
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expecting to get conflicts when applying object after updating replicas, got no error: %s", result)
|
t.Fatalf("Expecting to get conflicts when applying object after updating replicas, got no error: %s", result)
|
||||||
}
|
}
|
||||||
@@ -123,7 +124,7 @@ spec:
|
|||||||
Param("force", "true").
|
Param("force", "true").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to apply object with force after updating replicas: %v:\n%v", err, string(result))
|
t.Fatalf("failed to apply object with force after updating replicas: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -241,7 +242,7 @@ spec:
|
|||||||
Name(name).
|
Name(name).
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create custom resource with apply: %v:\n%v", err, string(result))
|
t.Fatalf("failed to create custom resource with apply: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -255,7 +256,7 @@ spec:
|
|||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Name(name).
|
Name(name).
|
||||||
Body([]byte(`{"metadata":{"finalizers":["test-finalizer","another-one"]}}`)).
|
Body([]byte(`{"metadata":{"finalizers":["test-finalizer","another-one"]}}`)).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to add finalizer with merge patch: %v:\n%v", err, string(result))
|
t.Fatalf("failed to add finalizer with merge patch: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -270,7 +271,7 @@ spec:
|
|||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
SetHeader("Accept", "application/json").
|
SetHeader("Accept", "application/json").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to apply same config after adding a finalizer: %v:\n%v", err, string(result))
|
t.Fatalf("failed to apply same config after adding a finalizer: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -283,7 +284,7 @@ spec:
|
|||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Name(name).
|
Name(name).
|
||||||
Body([]byte(`{"spec":{"replicas": 5}}`)).
|
Body([]byte(`{"spec":{"replicas": 5}}`)).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to update number of replicas with merge patch: %v:\n%v", err, string(result))
|
t.Fatalf("failed to update number of replicas with merge patch: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -295,7 +296,7 @@ spec:
|
|||||||
Name(name).
|
Name(name).
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expecting to get conflicts when applying object after updating replicas, got no error: %s", result)
|
t.Fatalf("Expecting to get conflicts when applying object after updating replicas, got no error: %s", result)
|
||||||
}
|
}
|
||||||
@@ -314,7 +315,7 @@ spec:
|
|||||||
Param("force", "true").
|
Param("force", "true").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to apply object with force after updating replicas: %v:\n%v", err, string(result))
|
t.Fatalf("failed to apply object with force after updating replicas: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -335,7 +336,7 @@ spec:
|
|||||||
- name: "y"
|
- name: "y"
|
||||||
containerPort: 80
|
containerPort: 80
|
||||||
protocol: TCP`, apiVersion, kind, name))).
|
protocol: TCP`, apiVersion, kind, name))).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expecting to get conflicts when a different applier updates existing list item, got no error: %s", result)
|
t.Fatalf("Expecting to get conflicts when a different applier updates existing list item, got no error: %s", result)
|
||||||
}
|
}
|
||||||
@@ -363,7 +364,7 @@ spec:
|
|||||||
containerPort: 8080
|
containerPort: 8080
|
||||||
protocol: TCP`, apiVersion, kind, name))).
|
protocol: TCP`, apiVersion, kind, name))).
|
||||||
SetHeader("Accept", "application/json").
|
SetHeader("Accept", "application/json").
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to add a new list item to the object as a different applier: %v:\n%v", err, string(result))
|
t.Fatalf("failed to add a new list item to the object as a different applier: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -447,7 +448,7 @@ spec:
|
|||||||
Name(name).
|
Name(name).
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create custom resource with apply: %v:\n%v", err, string(result))
|
t.Fatalf("failed to create custom resource with apply: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -460,7 +461,7 @@ spec:
|
|||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Name(name).
|
Name(name).
|
||||||
Body([]byte(`{"metadata":{"finalizers":["test-finalizer","another-one"]}}`)).
|
Body([]byte(`{"metadata":{"finalizers":["test-finalizer","another-one"]}}`)).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to add finalizer with merge patch: %v:\n%v", err, string(result))
|
t.Fatalf("failed to add finalizer with merge patch: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -475,7 +476,7 @@ spec:
|
|||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
SetHeader("Accept", "application/json").
|
SetHeader("Accept", "application/json").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to apply same config after adding a finalizer: %v:\n%v", err, string(result))
|
t.Fatalf("failed to apply same config after adding a finalizer: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -488,7 +489,7 @@ spec:
|
|||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Name(name).
|
Name(name).
|
||||||
Body([]byte(`{"spec":{"replicas": 5}}`)).
|
Body([]byte(`{"spec":{"replicas": 5}}`)).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to update number of replicas with merge patch: %v:\n%v", err, string(result))
|
t.Fatalf("failed to update number of replicas with merge patch: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -500,7 +501,7 @@ spec:
|
|||||||
Name(name).
|
Name(name).
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expecting to get conflicts when applying object after updating replicas, got no error: %s", result)
|
t.Fatalf("Expecting to get conflicts when applying object after updating replicas, got no error: %s", result)
|
||||||
}
|
}
|
||||||
@@ -519,7 +520,7 @@ spec:
|
|||||||
Param("force", "true").
|
Param("force", "true").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to apply object with force after updating replicas: %v:\n%v", err, string(result))
|
t.Fatalf("failed to apply object with force after updating replicas: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -671,7 +672,7 @@ spec:
|
|||||||
Name(name).
|
Name(name).
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create custom resource with apply: %v:\n%v", err, string(result))
|
t.Fatalf("failed to create custom resource with apply: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -682,7 +683,7 @@ spec:
|
|||||||
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
AbsPath("/apis", noxuDefinition.Spec.Group, noxuDefinition.Spec.Version, noxuDefinition.Spec.Names.Plural).
|
||||||
Name(name).
|
Name(name).
|
||||||
Body([]byte(`{"spec":{"replicas": 5}}`)).
|
Body([]byte(`{"spec":{"replicas": 5}}`)).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to update number of replicas with merge patch: %v:\n%v", err, string(result))
|
t.Fatalf("failed to update number of replicas with merge patch: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
@@ -694,7 +695,7 @@ spec:
|
|||||||
Name(name).
|
Name(name).
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expecting to get conflicts when applying object after updating replicas, got no error: %s", result)
|
t.Fatalf("Expecting to get conflicts when applying object after updating replicas, got no error: %s", result)
|
||||||
}
|
}
|
||||||
@@ -713,7 +714,7 @@ spec:
|
|||||||
Param("force", "true").
|
Param("force", "true").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to apply object with force after updating replicas: %v:\n%v", err, string(result))
|
t.Fatalf("failed to apply object with force after updating replicas: %v:\n%v", err, string(result))
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apiserver
|
package apiserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -27,6 +28,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"sigs.k8s.io/yaml"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
@@ -41,7 +44,6 @@ import (
|
|||||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||||
"k8s.io/kubernetes/pkg/master"
|
"k8s.io/kubernetes/pkg/master"
|
||||||
"k8s.io/kubernetes/test/integration/framework"
|
"k8s.io/kubernetes/test/integration/framework"
|
||||||
"sigs.k8s.io/yaml"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func setup(t testing.TB, groupVersions ...schema.GroupVersion) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
func setup(t testing.TB, groupVersions ...schema.GroupVersion) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
||||||
@@ -119,13 +121,13 @@ func TestApplyAlsoCreates(t *testing.T) {
|
|||||||
Name(tc.name).
|
Name(tc.name).
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body([]byte(tc.body)).
|
Body([]byte(tc.body)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = client.CoreV1().RESTClient().Get().Namespace("default").Resource(tc.resource).Name(tc.name).Do().Get()
|
_, err = client.CoreV1().RESTClient().Get().Namespace("default").Resource(tc.resource).Name(tc.name).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to retrieve object: %v", err)
|
t.Fatalf("Failed to retrieve object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -137,7 +139,7 @@ func TestApplyAlsoCreates(t *testing.T) {
|
|||||||
Name(tc.name).
|
Name(tc.name).
|
||||||
Param("fieldManager", "apply_test_2").
|
Param("fieldManager", "apply_test_2").
|
||||||
Body([]byte(tc.body)).
|
Body([]byte(tc.body)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to re-apply object using Apply patch: %v", err)
|
t.Fatalf("Failed to re-apply object using Apply patch: %v", err)
|
||||||
@@ -186,7 +188,7 @@ func TestNoOpUpdateSameResourceVersion(t *testing.T) {
|
|||||||
Resource(podResource).
|
Resource(podResource).
|
||||||
Name(podName).
|
Name(podName).
|
||||||
Body(podBytes).
|
Body(podBytes).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object: %v", err)
|
t.Fatalf("Failed to create object: %v", err)
|
||||||
@@ -195,7 +197,7 @@ func TestNoOpUpdateSameResourceVersion(t *testing.T) {
|
|||||||
// Sleep for one second to make sure that the times of each update operation is different.
|
// Sleep for one second to make sure that the times of each update operation is different.
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
createdObject, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource(podResource).Name(podName).Do().Get()
|
createdObject, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource(podResource).Name(podName).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to retrieve created object: %v", err)
|
t.Fatalf("Failed to retrieve created object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -216,13 +218,13 @@ func TestNoOpUpdateSameResourceVersion(t *testing.T) {
|
|||||||
Resource(podResource).
|
Resource(podResource).
|
||||||
Name(podName).
|
Name(podName).
|
||||||
Body(createdBytes).
|
Body(createdBytes).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to apply no-op update: %v", err)
|
t.Fatalf("Failed to apply no-op update: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedObject, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource(podResource).Name(podName).Do().Get()
|
updatedObject, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource(podResource).Name(podName).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to retrieve updated object: %v", err)
|
t.Fatalf("Failed to retrieve updated object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -274,7 +276,7 @@ func TestCreateOnApplyFailsWithUID(t *testing.T) {
|
|||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}`)).
|
}`)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if !apierrors.IsConflict(err) {
|
if !apierrors.IsConflict(err) {
|
||||||
t.Fatalf("Expected conflict error but got: %v", err)
|
t.Fatalf("Expected conflict error but got: %v", err)
|
||||||
@@ -323,7 +325,7 @@ func TestApplyUpdateApplyConflictForced(t *testing.T) {
|
|||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(obj).Do().Get()
|
Body(obj).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
}
|
}
|
||||||
@@ -333,7 +335,7 @@ func TestApplyUpdateApplyConflictForced(t *testing.T) {
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Body([]byte(`{"spec":{"replicas": 5}}`)).Do().Get()
|
Body([]byte(`{"spec":{"replicas": 5}}`)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to patch object: %v", err)
|
t.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -344,7 +346,7 @@ func TestApplyUpdateApplyConflictForced(t *testing.T) {
|
|||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body([]byte(obj)).Do().Get()
|
Body([]byte(obj)).Do(context.TODO()).Get()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expecting to get conflicts when applying object")
|
t.Fatalf("Expecting to get conflicts when applying object")
|
||||||
}
|
}
|
||||||
@@ -363,7 +365,7 @@ func TestApplyUpdateApplyConflictForced(t *testing.T) {
|
|||||||
Name("deployment").
|
Name("deployment").
|
||||||
Param("force", "true").
|
Param("force", "true").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body([]byte(obj)).Do().Get()
|
Body([]byte(obj)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to apply object with force: %v", err)
|
t.Fatalf("Failed to apply object with force: %v", err)
|
||||||
}
|
}
|
||||||
@@ -391,7 +393,7 @@ func TestApplyGroupsManySeparateUpdates(t *testing.T) {
|
|||||||
Resource("validatingwebhookconfigurations").
|
Resource("validatingwebhookconfigurations").
|
||||||
Name("webhook").
|
Name("webhook").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(obj).Do().Get()
|
Body(obj).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
}
|
}
|
||||||
@@ -407,7 +409,7 @@ func TestApplyGroupsManySeparateUpdates(t *testing.T) {
|
|||||||
Resource("validatingwebhookconfigurations").
|
Resource("validatingwebhookconfigurations").
|
||||||
Name("webhook").
|
Name("webhook").
|
||||||
Param("fieldManager", unique).
|
Param("fieldManager", unique).
|
||||||
Body([]byte(`{"metadata":{"labels":{"` + unique + `":"new"}}}`)).Do().Get()
|
Body([]byte(`{"metadata":{"labels":{"` + unique + `":"new"}}}`)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to patch object: %v", err)
|
t.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -464,7 +466,7 @@ func TestApplyManagedFields(t *testing.T) {
|
|||||||
"key": "value"
|
"key": "value"
|
||||||
}
|
}
|
||||||
}`)).
|
}`)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
@@ -475,7 +477,7 @@ func TestApplyManagedFields(t *testing.T) {
|
|||||||
Resource("configmaps").
|
Resource("configmaps").
|
||||||
Name("test-cm").
|
Name("test-cm").
|
||||||
Param("fieldManager", "updater").
|
Param("fieldManager", "updater").
|
||||||
Body([]byte(`{"data":{"new-key": "value"}}`)).Do().Get()
|
Body([]byte(`{"data":{"new-key": "value"}}`)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to patch object: %v", err)
|
t.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -490,12 +492,12 @@ func TestApplyManagedFields(t *testing.T) {
|
|||||||
Resource("configmaps").
|
Resource("configmaps").
|
||||||
Name("test-cm").
|
Name("test-cm").
|
||||||
Param("fieldManager", "updater").
|
Param("fieldManager", "updater").
|
||||||
Body([]byte(`{"data":{"key": "new value"}}`)).Do().Get()
|
Body([]byte(`{"data":{"key": "new value"}}`)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to patch object: %v", err)
|
t.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do().Get()
|
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to retrieve object: %v", err)
|
t.Fatalf("Failed to retrieve object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -588,7 +590,7 @@ func TestApplyRemovesEmptyManagedFields(t *testing.T) {
|
|||||||
Name("test-cm").
|
Name("test-cm").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(obj).
|
Body(obj).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
@@ -599,12 +601,12 @@ func TestApplyRemovesEmptyManagedFields(t *testing.T) {
|
|||||||
Resource("configmaps").
|
Resource("configmaps").
|
||||||
Name("test-cm").
|
Name("test-cm").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(obj).Do().Get()
|
Body(obj).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to patch object: %v", err)
|
t.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do().Get()
|
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to retrieve object: %v", err)
|
t.Fatalf("Failed to retrieve object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -639,7 +641,7 @@ func TestApplyRequiresFieldManager(t *testing.T) {
|
|||||||
Resource("configmaps").
|
Resource("configmaps").
|
||||||
Name("test-cm").
|
Name("test-cm").
|
||||||
Body(obj).
|
Body(obj).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Apply should fail to create without fieldManager")
|
t.Fatalf("Apply should fail to create without fieldManager")
|
||||||
@@ -651,7 +653,7 @@ func TestApplyRequiresFieldManager(t *testing.T) {
|
|||||||
Name("test-cm").
|
Name("test-cm").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(obj).
|
Body(obj).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Apply failed to create with fieldManager: %v", err)
|
t.Fatalf("Apply failed to create with fieldManager: %v", err)
|
||||||
@@ -705,7 +707,7 @@ func TestApplyRemoveContainerPort(t *testing.T) {
|
|||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(obj).Do().Get()
|
Body(obj).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
}
|
}
|
||||||
@@ -746,7 +748,7 @@ func TestApplyRemoveContainerPort(t *testing.T) {
|
|||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(obj).Do().Get()
|
Body(obj).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to remove container port using Apply patch: %v", err)
|
t.Fatalf("Failed to remove container port using Apply patch: %v", err)
|
||||||
}
|
}
|
||||||
@@ -805,7 +807,7 @@ func TestApplyFailsWithVersionMismatch(t *testing.T) {
|
|||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body(obj).Do().Get()
|
Body(obj).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
}
|
}
|
||||||
@@ -845,7 +847,7 @@ func TestApplyFailsWithVersionMismatch(t *testing.T) {
|
|||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Body([]byte(obj)).Do().Get()
|
Body([]byte(obj)).Do(context.TODO()).Get()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expecting to get version mismatch when applying object")
|
t.Fatalf("Expecting to get version mismatch when applying object")
|
||||||
}
|
}
|
||||||
@@ -925,7 +927,7 @@ func TestApplyConvertsManagedFieldsVersion(t *testing.T) {
|
|||||||
AbsPath("/apis/apps/v1").
|
AbsPath("/apis/apps/v1").
|
||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Body(obj).Do().Get()
|
Body(obj).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object: %v", err)
|
t.Fatalf("Failed to create object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -954,7 +956,7 @@ func TestApplyConvertsManagedFieldsVersion(t *testing.T) {
|
|||||||
Resource("deployments").
|
Resource("deployments").
|
||||||
Name("deployment").
|
Name("deployment").
|
||||||
Param("fieldManager", "sidecar_controller").
|
Param("fieldManager", "sidecar_controller").
|
||||||
Body([]byte(obj)).Do().Get()
|
Body([]byte(obj)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to apply object: %v", err)
|
t.Fatalf("Failed to apply object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1028,7 +1030,7 @@ func TestClearManagedFieldsWithMergePatch(t *testing.T) {
|
|||||||
"key": "value"
|
"key": "value"
|
||||||
}
|
}
|
||||||
}`)).
|
}`)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
@@ -1038,12 +1040,12 @@ func TestClearManagedFieldsWithMergePatch(t *testing.T) {
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("configmaps").
|
Resource("configmaps").
|
||||||
Name("test-cm").
|
Name("test-cm").
|
||||||
Body([]byte(`{"metadata":{"managedFields": [{}]}}`)).Do().Get()
|
Body([]byte(`{"metadata":{"managedFields": [{}]}}`)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to patch object: %v", err)
|
t.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do().Get()
|
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to retrieve object: %v", err)
|
t.Fatalf("Failed to retrieve object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1084,7 +1086,7 @@ func TestClearManagedFieldsWithStrategicMergePatch(t *testing.T) {
|
|||||||
"key": "value"
|
"key": "value"
|
||||||
}
|
}
|
||||||
}`)).
|
}`)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
@@ -1094,12 +1096,12 @@ func TestClearManagedFieldsWithStrategicMergePatch(t *testing.T) {
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("configmaps").
|
Resource("configmaps").
|
||||||
Name("test-cm").
|
Name("test-cm").
|
||||||
Body([]byte(`{"metadata":{"managedFields": [{}]}}`)).Do().Get()
|
Body([]byte(`{"metadata":{"managedFields": [{}]}}`)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to patch object: %v", err)
|
t.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do().Get()
|
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to retrieve object: %v", err)
|
t.Fatalf("Failed to retrieve object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1144,7 +1146,7 @@ func TestClearManagedFieldsWithJSONPatch(t *testing.T) {
|
|||||||
"key": "value"
|
"key": "value"
|
||||||
}
|
}
|
||||||
}`)).
|
}`)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
@@ -1154,12 +1156,12 @@ func TestClearManagedFieldsWithJSONPatch(t *testing.T) {
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("configmaps").
|
Resource("configmaps").
|
||||||
Name("test-cm").
|
Name("test-cm").
|
||||||
Body([]byte(`[{"op": "replace", "path": "/metadata/managedFields", "value": [{}]}]`)).Do().Get()
|
Body([]byte(`[{"op": "replace", "path": "/metadata/managedFields", "value": [{}]}]`)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to patch object: %v", err)
|
t.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do().Get()
|
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to retrieve object: %v", err)
|
t.Fatalf("Failed to retrieve object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1200,7 +1202,7 @@ func TestClearManagedFieldsWithUpdate(t *testing.T) {
|
|||||||
"key": "value"
|
"key": "value"
|
||||||
}
|
}
|
||||||
}`)).
|
}`)).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
t.Fatalf("Failed to create object using Apply patch: %v", err)
|
||||||
@@ -1224,12 +1226,12 @@ func TestClearManagedFieldsWithUpdate(t *testing.T) {
|
|||||||
"data": {
|
"data": {
|
||||||
"key": "value"
|
"key": "value"
|
||||||
}
|
}
|
||||||
}`)).Do().Get()
|
}`)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to patch object: %v", err)
|
t.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do().Get()
|
object, err := client.CoreV1().RESTClient().Get().Namespace("default").Resource("configmaps").Name("test-cm").Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to retrieve object: %v", err)
|
t.Fatalf("Failed to retrieve object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1416,7 +1418,7 @@ func getPodBytesWhenEnabled(b *testing.B, pod v1.Pod, format string) []byte {
|
|||||||
Param("fieldManager", "apply_test").
|
Param("fieldManager", "apply_test").
|
||||||
Resource("pods").
|
Resource("pods").
|
||||||
SetHeader("Accept", format).
|
SetHeader("Accept", format).
|
||||||
Body(encodePod(pod)).DoRaw()
|
Body(encodePod(pod)).DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to create object: %#v", err)
|
b.Fatalf("Failed to create object: %#v", err)
|
||||||
}
|
}
|
||||||
@@ -1439,7 +1441,7 @@ func BenchmarkNoServerSideApplyButSameSize(b *testing.B) {
|
|||||||
Resource("pods").
|
Resource("pods").
|
||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf").
|
||||||
Body(encodePod(pod)).DoRaw()
|
Body(encodePod(pod)).DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to create object: %v", err)
|
b.Fatalf("Failed to create object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1485,7 +1487,7 @@ func benchAll(b *testing.B, client kubernetes.Interface, pod v1.Pod) {
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("pods").
|
Resource("pods").
|
||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
Body(encodePod(pod)).Do().Get()
|
Body(encodePod(pod)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to create object: %v", err)
|
b.Fatalf("Failed to create object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1516,7 +1518,7 @@ func benchPostPod(client kubernetes.Interface, pod v1.Pod, parallel int) func(*t
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("pods").
|
Resource("pods").
|
||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
Body(encodePod(pod)).Do().Get()
|
Body(encodePod(pod)).Do(context.TODO()).Get()
|
||||||
c <- err
|
c <- err
|
||||||
}(pod)
|
}(pod)
|
||||||
}
|
}
|
||||||
@@ -1540,7 +1542,7 @@ func createNamespace(client kubernetes.Interface, name string) error {
|
|||||||
_, err = client.CoreV1().RESTClient().Get().
|
_, err = client.CoreV1().RESTClient().Get().
|
||||||
Resource("namespaces").
|
Resource("namespaces").
|
||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
Body(namespaceBytes).Do().Get()
|
Body(namespaceBytes).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to create namespace: %v", err)
|
return fmt.Errorf("Failed to create namespace: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1561,7 +1563,7 @@ func benchListPod(client kubernetes.Interface, pod v1.Pod, num int) func(*testin
|
|||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Resource("pods").
|
Resource("pods").
|
||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
Body(encodePod(pod)).Do().Get()
|
Body(encodePod(pod)).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to create object: %v", err)
|
b.Fatalf("Failed to create object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1574,7 +1576,7 @@ func benchListPod(client kubernetes.Interface, pod v1.Pod, num int) func(*testin
|
|||||||
Namespace(namespace).
|
Namespace(namespace).
|
||||||
Resource("pods").
|
Resource("pods").
|
||||||
SetHeader("Accept", "application/vnd.kubernetes.protobuf").
|
SetHeader("Accept", "application/vnd.kubernetes.protobuf").
|
||||||
Do().Get()
|
Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to patch object: %v", err)
|
b.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1591,7 +1593,7 @@ func benchRepeatedUpdate(client kubernetes.Interface, podName string) func(*test
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Resource("pods").
|
Resource("pods").
|
||||||
Name(podName).
|
Name(podName).
|
||||||
Body([]byte(fmt.Sprintf(`[{"op": "replace", "path": "/spec/containers/0/image", "value": "image%d"}]`, i))).Do().Get()
|
Body([]byte(fmt.Sprintf(`[{"op": "replace", "path": "/spec/containers/0/image", "value": "image%d"}]`, i))).Do(context.TODO()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("Failed to patch object: %v", err)
|
b.Fatalf("Failed to patch object: %v", err)
|
||||||
}
|
}
|
||||||
|
@@ -17,11 +17,12 @@ limitations under the License.
|
|||||||
package apiserver
|
package apiserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
@@ -56,7 +57,7 @@ func TestMaxJSONPatchOperations(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = c.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = c.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(hugePatch).Do().Error()
|
Body(hugePatch).Do(context.TODO()).Error()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("unexpected no error")
|
t.Fatalf("unexpected no error")
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apiserver
|
package apiserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -41,7 +42,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
c := clientSet.CoreV1().RESTClient()
|
c := clientSet.CoreV1().RESTClient()
|
||||||
t.Run("Create should limit the request body size", func(t *testing.T) {
|
t.Run("Create should limit the request body size", func(t *testing.T) {
|
||||||
err := c.Post().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/pods")).
|
err := c.Post().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/pods")).
|
||||||
Body(hugeData).Do().Error()
|
Body(hugeData).Do(context.TODO()).Error()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("unexpected no error")
|
t.Fatalf("unexpected no error")
|
||||||
}
|
}
|
||||||
@@ -64,7 +65,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("Update should limit the request body size", func(t *testing.T) {
|
t.Run("Update should limit the request body size", func(t *testing.T) {
|
||||||
err = c.Put().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = c.Put().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(hugeData).Do().Error()
|
Body(hugeData).Do(context.TODO()).Error()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("unexpected no error")
|
t.Fatalf("unexpected no error")
|
||||||
}
|
}
|
||||||
@@ -75,7 +76,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
})
|
})
|
||||||
t.Run("Patch should limit the request body size", func(t *testing.T) {
|
t.Run("Patch should limit the request body size", func(t *testing.T) {
|
||||||
err = c.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = c.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(hugeData).Do().Error()
|
Body(hugeData).Do(context.TODO()).Error()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("unexpected no error")
|
t.Fatalf("unexpected no error")
|
||||||
}
|
}
|
||||||
@@ -87,7 +88,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
t.Run("JSONPatchType should handle a patch just under the max limit", func(t *testing.T) {
|
t.Run("JSONPatchType should handle a patch just under the max limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`[{"op":"add","path":"/foo","value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}]`)
|
patchBody := []byte(`[{"op":"add","path":"/foo","value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}]`)
|
||||||
err = rest.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = rest.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if err != nil && !apierrors.IsBadRequest(err) {
|
if err != nil && !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected success or bad request err, got %v", err)
|
t.Errorf("expected success or bad request err, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -95,7 +96,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
t.Run("JSONPatchType should handle a valid patch just under the max limit", func(t *testing.T) {
|
t.Run("JSONPatchType should handle a valid patch just under the max limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`[{"op":"add","path":"/foo","value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}]`)
|
patchBody := []byte(`[{"op":"add","path":"/foo","value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}]`)
|
||||||
err = rest.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = rest.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -103,7 +104,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
t.Run("MergePatchType should handle a patch just under the max limit", func(t *testing.T) {
|
t.Run("MergePatchType should handle a patch just under the max limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
||||||
err = rest.Patch(types.MergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = rest.Patch(types.MergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if err != nil && !apierrors.IsBadRequest(err) {
|
if err != nil && !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected success or bad request err, got %v", err)
|
t.Errorf("expected success or bad request err, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -111,7 +112,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
t.Run("MergePatchType should handle a valid patch just under the max limit", func(t *testing.T) {
|
t.Run("MergePatchType should handle a valid patch just under the max limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`{"value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}`)
|
patchBody := []byte(`{"value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}`)
|
||||||
err = rest.Patch(types.MergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = rest.Patch(types.MergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -119,7 +120,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
t.Run("StrategicMergePatchType should handle a patch just under the max limit", func(t *testing.T) {
|
t.Run("StrategicMergePatchType should handle a patch just under the max limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
||||||
err = rest.Patch(types.StrategicMergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = rest.Patch(types.StrategicMergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if err != nil && !apierrors.IsBadRequest(err) {
|
if err != nil && !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected success or bad request err, got %v", err)
|
t.Errorf("expected success or bad request err, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -127,7 +128,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
t.Run("StrategicMergePatchType should handle a valid patch just under the max limit", func(t *testing.T) {
|
t.Run("StrategicMergePatchType should handle a valid patch just under the max limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`{"value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}`)
|
patchBody := []byte(`{"value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}`)
|
||||||
err = rest.Patch(types.StrategicMergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = rest.Patch(types.StrategicMergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -135,7 +136,7 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
t.Run("ApplyPatchType should handle a patch just under the max limit", func(t *testing.T) {
|
t.Run("ApplyPatchType should handle a patch just under the max limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
|
||||||
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if err != nil && !apierrors.IsBadRequest(err) {
|
if err != nil && !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected success or bad request err, got %#v", err)
|
t.Errorf("expected success or bad request err, got %#v", err)
|
||||||
}
|
}
|
||||||
@@ -143,14 +144,14 @@ func TestMaxResourceSize(t *testing.T) {
|
|||||||
t.Run("ApplyPatchType should handle a valid patch just under the max limit", func(t *testing.T) {
|
t.Run("ApplyPatchType should handle a valid patch just under the max limit", func(t *testing.T) {
|
||||||
patchBody := []byte(`{"apiVersion":"v1","kind":"Secret"` + strings.Repeat(" ", 3*1024*1024-100) + `}`)
|
patchBody := []byte(`{"apiVersion":"v1","kind":"Secret"` + strings.Repeat(" ", 3*1024*1024-100) + `}`)
|
||||||
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(patchBody).Do().Error()
|
Body(patchBody).Do(context.TODO()).Error()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("Delete should limit the request body size", func(t *testing.T) {
|
t.Run("Delete should limit the request body size", func(t *testing.T) {
|
||||||
err = c.Delete().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
err = c.Delete().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
|
||||||
Body(hugeData).Do().Error()
|
Body(hugeData).Do(context.TODO()).Error()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("unexpected no error")
|
t.Fatalf("unexpected no error")
|
||||||
}
|
}
|
||||||
@@ -174,7 +175,7 @@ values: ` + strings.Repeat("[", 3*1024*1024))
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/api/v1/namespaces/default/configmaps").
|
AbsPath("/api/v1/namespaces/default/configmaps").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsRequestEntityTooLargeError(err) {
|
if !apierrors.IsRequestEntityTooLargeError(err) {
|
||||||
t.Errorf("expected too large error, got %v", err)
|
t.Errorf("expected too large error, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -194,7 +195,7 @@ values: ` + strings.Repeat("[", 3*1024*1024/2-500) + strings.Repeat("]", 3*1024*
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/api/v1/namespaces/default/configmaps").
|
AbsPath("/api/v1/namespaces/default/configmaps").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected bad request, got %v", err)
|
t.Errorf("expected bad request, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -214,7 +215,7 @@ values: ` + strings.Repeat("[", 3*1024*1024-1000))
|
|||||||
SetHeader("Content-Type", "application/yaml").
|
SetHeader("Content-Type", "application/yaml").
|
||||||
AbsPath("/api/v1/namespaces/default/configmaps").
|
AbsPath("/api/v1/namespaces/default/configmaps").
|
||||||
Body(yamlBody).
|
Body(yamlBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected bad request, got %v", err)
|
t.Errorf("expected bad request, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -235,7 +236,7 @@ values: ` + strings.Repeat("[", 3*1024*1024-1000))
|
|||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
AbsPath("/api/v1/namespaces/default/configmaps").
|
AbsPath("/api/v1/namespaces/default/configmaps").
|
||||||
Body(jsonBody).
|
Body(jsonBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsRequestEntityTooLargeError(err) {
|
if !apierrors.IsRequestEntityTooLargeError(err) {
|
||||||
t.Errorf("expected too large error, got %v", err)
|
t.Errorf("expected too large error, got %v", err)
|
||||||
}
|
}
|
||||||
@@ -256,7 +257,7 @@ values: ` + strings.Repeat("[", 3*1024*1024-1000))
|
|||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
AbsPath("/api/v1/namespaces/default/configmaps").
|
AbsPath("/api/v1/namespaces/default/configmaps").
|
||||||
Body(jsonBody).
|
Body(jsonBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
// TODO(liggitt): expect bad request on deep nesting, rather than success on dropped unknown field data
|
// TODO(liggitt): expect bad request on deep nesting, rather than success on dropped unknown field data
|
||||||
if err != nil && !apierrors.IsBadRequest(err) {
|
if err != nil && !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected bad request, got %v", err)
|
t.Errorf("expected bad request, got %v", err)
|
||||||
@@ -278,7 +279,7 @@ values: ` + strings.Repeat("[", 3*1024*1024-1000))
|
|||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
AbsPath("/api/v1/namespaces/default/configmaps").
|
AbsPath("/api/v1/namespaces/default/configmaps").
|
||||||
Body(jsonBody).
|
Body(jsonBody).
|
||||||
DoRaw()
|
DoRaw(context.TODO())
|
||||||
if !apierrors.IsBadRequest(err) {
|
if !apierrors.IsBadRequest(err) {
|
||||||
t.Errorf("expected bad request, got %v", err)
|
t.Errorf("expected bad request, got %v", err)
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apiserver
|
package apiserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@@ -24,7 +25,7 @@ import (
|
|||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -83,7 +84,7 @@ func TestPatchConflicts(t *testing.T) {
|
|||||||
Resource("secrets").
|
Resource("secrets").
|
||||||
Name("test").
|
Name("test").
|
||||||
Body([]byte(fmt.Sprintf(`{"metadata":{"labels":{"%s":"%s"}, "ownerReferences":[{"$patch":"delete","uid":"%s"}]}}`, labelName, value, UIDs[i]))).
|
Body([]byte(fmt.Sprintf(`{"metadata":{"labels":{"%s":"%s"}, "ownerReferences":[{"$patch":"delete","uid":"%s"}]}}`, labelName, value, UIDs[i]))).
|
||||||
Do().
|
Do(context.TODO()).
|
||||||
Get()
|
Get()
|
||||||
|
|
||||||
if apierrors.IsConflict(err) {
|
if apierrors.IsConflict(err) {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package podlogs
|
package podlogs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
@@ -137,7 +138,7 @@ func TestInsecurePodLogs(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
insecureResult := clientSet.CoreV1().Pods("ns").GetLogs(pod.Name, &corev1.PodLogOptions{InsecureSkipTLSVerifyBackend: true}).Do()
|
insecureResult := clientSet.CoreV1().Pods("ns").GetLogs(pod.Name, &corev1.PodLogOptions{InsecureSkipTLSVerifyBackend: true}).Do(context.TODO())
|
||||||
if err := insecureResult.Error(); err != nil {
|
if err := insecureResult.Error(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -147,7 +148,7 @@ func TestInsecurePodLogs(t *testing.T) {
|
|||||||
t.Fatal(insecureStatusCode)
|
t.Fatal(insecureStatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
secureResult := clientSet.CoreV1().Pods("ns").GetLogs(pod.Name, &corev1.PodLogOptions{}).Do()
|
secureResult := clientSet.CoreV1().Pods("ns").GetLogs(pod.Name, &corev1.PodLogOptions{}).Do(context.TODO())
|
||||||
if err := secureResult.Error(); err == nil || !strings.Contains(err.Error(), "x509: certificate signed by unknown authority") {
|
if err := secureResult.Error(); err == nil || !strings.Contains(err.Error(), "x509: certificate signed by unknown authority") {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apiserver
|
package apiserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -238,7 +239,7 @@ func TestServerSidePrint(t *testing.T) {
|
|||||||
if mapping.Scope.Name() == meta.RESTScopeNameNamespace {
|
if mapping.Scope.Name() == meta.RESTScopeNameNamespace {
|
||||||
req = req.Namespace(ns.Name)
|
req = req.Namespace(ns.Name)
|
||||||
}
|
}
|
||||||
body, err := req.Resource(mapping.Resource.Resource).SetHeader("Accept", tableParam).Do().Raw()
|
body, err := req.Resource(mapping.Resource.Resource).SetHeader("Accept", tableParam).Do(context.TODO()).Raw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error getting %s: %v", gvk, err)
|
t.Errorf("unexpected error getting %s: %v", gvk, err)
|
||||||
continue
|
continue
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -84,7 +85,7 @@ func TestNodeAuthorizer(t *testing.T) {
|
|||||||
|
|
||||||
// Wait for a healthy server
|
// Wait for a healthy server
|
||||||
for {
|
for {
|
||||||
result := superuserClient.CoreV1().RESTClient().Get().AbsPath("/healthz").Do()
|
result := superuserClient.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(context.TODO())
|
||||||
_, err := result.Raw()
|
_, err := result.Raw()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
|
@@ -684,7 +684,7 @@ func TestBootstrapping(t *testing.T) {
|
|||||||
|
|
||||||
t.Errorf("missing cluster-admin: %v", clusterRoles)
|
t.Errorf("missing cluster-admin: %v", clusterRoles)
|
||||||
|
|
||||||
healthBytes, err := clientset.Discovery().RESTClient().Get().AbsPath("/healthz/poststarthook/rbac/bootstrap-roles").DoRaw()
|
healthBytes, err := clientset.Discovery().RESTClient().Get().AbsPath("/healthz/poststarthook/rbac/bootstrap-roles").DoRaw(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -263,7 +264,7 @@ func TestPatch(t *testing.T) {
|
|||||||
Namespace("default").
|
Namespace("default").
|
||||||
Name(name).
|
Name(name).
|
||||||
Body(body).
|
Body(body).
|
||||||
Do()
|
Do(context.TODO())
|
||||||
if result.Error() != nil {
|
if result.Error() != nil {
|
||||||
return result.Error()
|
return result.Error()
|
||||||
}
|
}
|
||||||
@@ -341,7 +342,7 @@ func TestPatchWithCreateOnUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
patchEndpoint := func(json []byte) (runtime.Object, error) {
|
patchEndpoint := func(json []byte) (runtime.Object, error) {
|
||||||
return c.CoreV1().RESTClient().Patch(types.MergePatchType).Resource("endpoints").Namespace("default").Name("patchendpoint").Body(json).Do().Get()
|
return c.CoreV1().RESTClient().Patch(types.MergePatchType).Resource("endpoints").Namespace("default").Name("patchendpoint").Body(json).Do(context.TODO()).Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure patch doesn't get to CreateOnUpdate
|
// Make sure patch doesn't get to CreateOnUpdate
|
||||||
@@ -496,7 +497,7 @@ func TestSingleWatch(t *testing.T) {
|
|||||||
Watch: true,
|
Watch: true,
|
||||||
FieldSelector: fields.OneTermEqualSelector("metadata.name", "event-9").String(),
|
FieldSelector: fields.OneTermEqualSelector("metadata.name", "event-9").String(),
|
||||||
}, metav1.ParameterCodec).
|
}, metav1.ParameterCodec).
|
||||||
Watch()
|
Watch(context.TODO())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed watch: %v", err)
|
t.Fatalf("Failed watch: %v", err)
|
||||||
@@ -757,7 +758,7 @@ func runSelfLinkTestOnNamespace(t *testing.T, c clientset.Interface, namespace s
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed creating selflinktest pod: %v", err)
|
t.Fatalf("Failed creating selflinktest pod: %v", err)
|
||||||
}
|
}
|
||||||
if err = c.CoreV1().RESTClient().Get().RequestURI(pod.SelfLink).Do().Into(pod); err != nil {
|
if err = c.CoreV1().RESTClient().Get().RequestURI(pod.SelfLink).Do(context.TODO()).Into(pod); err != nil {
|
||||||
t.Errorf("Failed listing pod with supplied self link '%v': %v", pod.SelfLink, err)
|
t.Errorf("Failed listing pod with supplied self link '%v': %v", pod.SelfLink, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,7 +767,7 @@ func runSelfLinkTestOnNamespace(t *testing.T, c clientset.Interface, namespace s
|
|||||||
t.Errorf("Failed listing pods: %v", err)
|
t.Errorf("Failed listing pods: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = c.CoreV1().RESTClient().Get().RequestURI(podList.SelfLink).Do().Into(podList); err != nil {
|
if err = c.CoreV1().RESTClient().Get().RequestURI(podList.SelfLink).Do(context.TODO()).Into(podList); err != nil {
|
||||||
t.Errorf("Failed listing pods with supplied self link '%v': %v", podList.SelfLink, err)
|
t.Errorf("Failed listing pods with supplied self link '%v': %v", podList.SelfLink, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,7 +778,7 @@ func runSelfLinkTestOnNamespace(t *testing.T, c clientset.Interface, namespace s
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
found = true
|
found = true
|
||||||
err = c.CoreV1().RESTClient().Get().RequestURI(item.SelfLink).Do().Into(pod)
|
err = c.CoreV1().RESTClient().Get().RequestURI(item.SelfLink).Do(context.TODO()).Into(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed listing pod with supplied self link '%v': %v", item.SelfLink, err)
|
t.Errorf("Failed listing pod with supplied self link '%v': %v", item.SelfLink, err)
|
||||||
}
|
}
|
||||||
|
@@ -146,7 +146,7 @@ func StartRealMasterOrDie(t *testing.T, configFuncs ...func(*options.ServerRunOp
|
|||||||
attempt := 0
|
attempt := 0
|
||||||
if err := wait.PollImmediate(time.Second, time.Minute, func() (done bool, err error) {
|
if err := wait.PollImmediate(time.Second, time.Minute, func() (done bool, err error) {
|
||||||
// wait for the server to be healthy
|
// wait for the server to be healthy
|
||||||
result := kubeClient.RESTClient().Get().AbsPath("/healthz").Do()
|
result := kubeClient.RESTClient().Get().AbsPath("/healthz").Do(context.TODO())
|
||||||
content, _ := result.Raw()
|
content, _ := result.Raw()
|
||||||
lastHealth = string(content)
|
lastHealth = string(content)
|
||||||
if errResult := result.Error(); errResult != nil {
|
if errResult := result.Error(); errResult != nil {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package apiserver
|
package apiserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -228,7 +229,7 @@ func waitForWardleRunning(t *testing.T, wardleToKASKubeConfig *rest.Config, ward
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
healthStatus := 0
|
healthStatus := 0
|
||||||
result := wardleClient.Discovery().RESTClient().Get().AbsPath("/healthz").Do().StatusCode(&healthStatus)
|
result := wardleClient.Discovery().RESTClient().Get().AbsPath("/healthz").Do(context.TODO()).StatusCode(&healthStatus)
|
||||||
lastHealthContent, lastHealthErr = result.Raw()
|
lastHealthContent, lastHealthErr = result.Raw()
|
||||||
if healthStatus != http.StatusOK {
|
if healthStatus != http.StatusOK {
|
||||||
return false, nil
|
return false, nil
|
||||||
@@ -345,7 +346,7 @@ func createKubeConfig(clientCfg *rest.Config) *clientcmdapi.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readResponse(client rest.Interface, location string) ([]byte, error) {
|
func readResponse(client rest.Interface, location string) ([]byte, error) {
|
||||||
return client.Get().AbsPath(location).DoRaw()
|
return client.Get().AbsPath(location).DoRaw(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAPIGroupList(t *testing.T, client rest.Interface) {
|
func testAPIGroupList(t *testing.T, client rest.Interface) {
|
||||||
|
@@ -28,6 +28,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-openapi/spec"
|
"github.com/go-openapi/spec"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
authauthenticator "k8s.io/apiserver/pkg/authentication/authenticator"
|
authauthenticator "k8s.io/apiserver/pkg/authentication/authenticator"
|
||||||
@@ -216,7 +217,7 @@ func startMasterOrDie(masterConfig *master.Config, incomingServer *httptest.Serv
|
|||||||
}
|
}
|
||||||
var lastHealthContent []byte
|
var lastHealthContent []byte
|
||||||
err = wait.PollImmediate(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
err = wait.PollImmediate(100*time.Millisecond, 30*time.Second, func() (bool, error) {
|
||||||
result := privilegedClient.Get().AbsPath("/healthz").Do()
|
result := privilegedClient.Get().AbsPath("/healthz").Do(context.TODO())
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
if status == 200 {
|
if status == 200 {
|
||||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package framework
|
package framework
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -150,7 +151,7 @@ func StartTestServer(t *testing.T, stopCh <-chan struct{}, setup TestServerSetup
|
|||||||
}
|
}
|
||||||
|
|
||||||
healthStatus := 0
|
healthStatus := 0
|
||||||
kubeClient.Discovery().RESTClient().Get().AbsPath("/healthz").Do().StatusCode(&healthStatus)
|
kubeClient.Discovery().RESTClient().Get().AbsPath("/healthz").Do(context.TODO()).StatusCode(&healthStatus)
|
||||||
if healthStatus != http.StatusOK {
|
if healthStatus != http.StatusOK {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user