Merge pull request #86931 from roycaihw/crd-openapi-deflake

crd openapi e2e: increase waitForOpenAPISchema timeout
This commit is contained in:
Kubernetes Prow Robot 2020-01-08 19:12:01 -08:00 committed by GitHub
commit 5b4d1bf559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View File

@ -9,6 +9,7 @@ require (
github.com/emicklei/go-restful v2.9.5+incompatible
github.com/go-openapi/spec v0.19.3
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d
github.com/json-iterator/go v1.1.8
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.4.0

View File

@ -20,6 +20,7 @@ go_library(
"//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library",
"//vendor/github.com/emicklei/go-restful:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/json-iterator/go:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/aggregator:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/builder:go_default_library",

View File

@ -18,12 +18,12 @@ package aggregator
import (
"crypto/sha512"
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/go-openapi/spec"
jsoniter "github.com/json-iterator/go"
"k8s.io/apiserver/pkg/authentication/user"
"k8s.io/apiserver/pkg/endpoints/request"
@ -80,7 +80,7 @@ func (s *Downloader) Download(handler http.Handler, etag string) (returnSpec *sp
return nil, "", http.StatusNotFound, nil
case http.StatusOK:
openAPISpec := &spec.Swagger{}
if err := json.Unmarshal(writer.data, openAPISpec); err != nil {
if err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(writer.data, openAPISpec); err != nil {
return nil, "", 0, err
}
newEtag = writer.Header().Get("Etag")

View File

@ -596,12 +596,12 @@ func waitForDefinitionCleanup(c k8sclientset.Interface, name string) error {
}
func waitForOpenAPISchema(c k8sclientset.Interface, pred func(*spec.Swagger) (bool, string)) error {
client := c.CoreV1().RESTClient().(*rest.RESTClient).Client
url := c.CoreV1().RESTClient().Get().AbsPath("openapi", "v2").URL()
client := c.Discovery().RESTClient().(*rest.RESTClient).Client
url := c.Discovery().RESTClient().Get().AbsPath("openapi", "v2").URL()
lastMsg := ""
etag := ""
var etagSpec *spec.Swagger
if err := wait.Poll(500*time.Millisecond, wait.ForeverTestTimeout, mustSucceedMultipleTimes(waitSuccessThreshold, func() (bool, error) {
if err := wait.Poll(500*time.Millisecond, 60*time.Second, mustSucceedMultipleTimes(waitSuccessThreshold, func() (bool, error) {
// download spec with etag support
spec := &spec.Swagger{}
req, err := http.NewRequest("GET", url.String(), nil)