Skip to content

Commit

Permalink
Bump k8s modules to 0.18.0 (kubernetes#4917)
Browse files Browse the repository at this point in the history
* Bump k8s modules to v0.18.0-beta.0

As of now, v0.18.0-beta.0 is latest.
https://pkg.go.dev/mod/k8s.io/api?tab=versions

* Add `context` parameter for HTTP requests with client-go

* Bump k8s modules to v0.18.0-beta.1

Test failure due to bug in client-go was fixed.

* Bump k8s modules to v0.18.0-beta.2

Add context.TODO() and options into some functions.

* Bump k8s modules to v0.18.0-rc.1

* Bump k8s modules to v0.18.0
  • Loading branch information
shu-mutou authored Apr 3, 2020
1 parent ad0724e commit 5246b8c
Show file tree
Hide file tree
Showing 81 changed files with 405 additions and 273 deletions.
2 changes: 1 addition & 1 deletion aio/scripts/conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ HEAPSTER_VERSION="v1.5.4"
HEAPSTER_PORT=8082
KIND_VERSION="v0.5.1"
KIND_BIN=${CACHE_DIR}/kind-${KIND_VERSION}
CODEGEN_VERSION="v0.17.3"
CODEGEN_VERSION="v0.18.0"
CODEGEN_BIN=${GOPATH}/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}/generate-groups.sh

# Setup logger.
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ go 1.13

require (
github.com/docker/distribution v2.7.1+incompatible
github.com/emicklei/go-restful v2.11.2+incompatible
github.com/emicklei/go-restful v2.12.0+incompatible
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/igm/sockjs-go v2.0.1+incompatible // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/prometheus/client_golang v1.4.1
github.com/prometheus/client_golang v1.5.1
github.com/spf13/pflag v1.0.5
golang.org/x/net v0.0.0-20200202094626-16171245cfb2
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
golang.org/x/text v0.3.2
gopkg.in/igm/sockjs-go.v2 v2.0.1
gopkg.in/square/go-jose.v2 v2.4.1
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.17.3
k8s.io/apiextensions-apiserver v0.17.3
k8s.io/apimachinery v0.17.3
k8s.io/client-go v0.17.3
k8s.io/api v0.18.0
k8s.io/apiextensions-apiserver v0.18.0
k8s.io/apimachinery v0.18.0
k8s.io/client-go v0.18.0
k8s.io/heapster v1.5.4
)
146 changes: 84 additions & 62 deletions go.sum

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/app/backend/client/csrf/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package csrf

import (
"context"
"log"

v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -34,7 +35,7 @@ func (self *csrfTokenManager) init() {
log.Printf("Initializing csrf token from %s secret", api.CsrfTokenSecretName)
tokenSecret, err := self.client.CoreV1().
Secrets(args.Holder.GetNamespace()).
Get(api.CsrfTokenSecretName, v1.GetOptions{})
Get(context.TODO(), api.CsrfTokenSecretName, v1.GetOptions{})

if err != nil {
panic(err)
Expand All @@ -45,7 +46,7 @@ func (self *csrfTokenManager) init() {
log.Printf("Empty token. Generating and storing in a secret %s", api.CsrfTokenSecretName)
token = api.GenerateCSRFKey()
tokenSecret.StringData = map[string]string{api.CsrfTokenSecretData: token}
_, err := self.client.CoreV1().Secrets(args.Holder.GetNamespace()).Update(tokenSecret)
_, err := self.client.CoreV1().Secrets(args.Holder.GetNamespace()).Update(context.TODO(), tokenSecret, v1.UpdateOptions{})
if err != nil {
panic(err)
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/backend/client/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
package client

import (
"context"
"log"
"strings"

"github.com/emicklei/go-restful"
v1 "k8s.io/api/authorization/v1"
apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -189,7 +191,7 @@ func (self *clientManager) CanI(req *restful.Request, ssar *v1.SelfSubjectAccess
return false
}

response, err := client.AuthorizationV1().SelfSubjectAccessReviews().Create(ssar)
response, err := client.AuthorizationV1().SelfSubjectAccessReviews().Create(context.TODO(), ssar, metaV1.CreateOptions{})
if err != nil {
log.Println(err)
return false
Expand Down
11 changes: 6 additions & 5 deletions src/app/backend/client/verber.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package client

import (
"context"
"fmt"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
Expand Down Expand Up @@ -118,7 +119,7 @@ func (verber *resourceVerber) getCRDGroupAndVersion(kind string) (info crdInfo,
var crdv1 apiextensionsv1.CustomResourceDefinition
var crdv1beta1 apiextensionsv1beta1.CustomResourceDefinition

err = verber.apiExtensionsClient.Get().Resource("customresourcedefinitions").Name(kind).Do().Into(&crdv1)
err = verber.apiExtensionsClient.Get().Resource("customresourcedefinitions").Name(kind).Do(context.TODO()).Into(&crdv1)
if err != nil {
if errors.IsNotFoundError(err) {
return info, errors.NewInvalid(fmt.Sprintf("Unknown resource kind: %s", kind))
Expand All @@ -136,7 +137,7 @@ func (verber *resourceVerber) getCRDGroupAndVersion(kind string) (info crdInfo,
return
}

err = verber.apiExtensionsClient.Get().Resource("customresourcedefinitions").Name(kind).Do().Into(&crdv1beta1)
err = verber.apiExtensionsClient.Get().Resource("customresourcedefinitions").Name(kind).Do(context.TODO()).Into(&crdv1beta1)
if err != nil {
if errors.IsNotFoundError(err) {
return info, errors.NewInvalid(fmt.Sprintf("Unknown resource kind: %s", kind))
Expand Down Expand Up @@ -187,7 +188,7 @@ func (verber *resourceVerber) Delete(kind string, namespaceSet bool, namespace s
req.Namespace(namespace)
}

return req.Do().Error()
return req.Do(context.TODO()).Error()
}

// Put puts new resource version of the given kind in the given namespace with the given name.
Expand All @@ -209,7 +210,7 @@ func (verber *resourceVerber) Put(kind string, namespaceSet bool, namespace stri
req.Namespace(namespace)
}

return req.Do().Error()
return req.Do(context.TODO()).Error()
}

// Get gets the resource of the given kind in the given namespace with the given name.
Expand All @@ -226,6 +227,6 @@ func (verber *resourceVerber) Get(kind string, namespaceSet bool, namespace stri
req.Namespace(namespace)
}

err = req.Do().Into(result)
err = req.Do(context.TODO()).Into(result)
return result, err
}
3 changes: 2 additions & 1 deletion src/app/backend/integration/metric/heapster/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package heapster

import (
"context"
"encoding/json"
"fmt"
"log"
Expand Down Expand Up @@ -222,7 +223,7 @@ func (self heapsterClient) allInOneDownload(selector heapsterSelector, metricNam
// unmarshalType performs heapster GET request to the specifies path and transfers
// the data to the interface provided.
func (self heapsterClient) unmarshalType(path string, v interface{}) error {
rawData, err := self.client.Get("/model/" + path).DoRaw()
rawData, err := self.client.Get("/model/" + path).DoRaw(context.TODO())
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/backend/integration/metric/heapster/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package heapster

import (
"context"
"encoding/json"
"fmt"
"log"
Expand Down Expand Up @@ -90,7 +91,7 @@ func (self FakeHeapster) ID() integrationapi.IntegrationID {
return "fakeHeapster"
}

func (self FakeRequest) DoRaw() ([]byte, error) {
func (self FakeRequest) DoRaw(ctx context.Context) ([]byte, error) {
_NumRequests.increment()
log.Println("Performing req...")
path := self.Path
Expand Down
8 changes: 5 additions & 3 deletions src/app/backend/integration/metric/heapster/restclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package heapster

import (
"context"

"k8s.io/client-go/rest"
)

Expand All @@ -30,7 +32,7 @@ type HeapsterRESTClient interface {
// RequestInterface is an interface that allows to make operations on pure request object.
// Separation is done to allow testing.
type RequestInterface interface {
DoRaw() ([]byte, error)
DoRaw(context.Context) ([]byte, error)
AbsPath(segments ...string) *rest.Request
}

Expand Down Expand Up @@ -59,7 +61,7 @@ func (self inClusterHeapsterClient) HealthCheck() error {
Name("heapster").
SubResource("proxy").
Suffix("/healthz").
DoRaw()
DoRaw(context.TODO())
return err
}

Expand All @@ -77,6 +79,6 @@ func (c remoteHeapsterClient) Get(path string) RequestInterface {
// HealthCheck does a health check of the application.
// Returns nil if connection to application can be established, error object otherwise.
func (self remoteHeapsterClient) HealthCheck() error {
_, err := self.Get("healthz").AbsPath("/").DoRaw()
_, err := self.Get("healthz").AbsPath("/").DoRaw(context.TODO())
return err
}
3 changes: 2 additions & 1 deletion src/app/backend/integration/metric/sidecar/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package sidecar

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -249,7 +250,7 @@ func (self sidecarClient) allInOneDownload(selector sidecarSelector, metricName
// unmarshalType performs sidecar GET request to the specifies path and transfers
// the data to the interface provided.
func (self sidecarClient) unmarshalType(path string, v interface{}) error {
rawData, err := self.client.Get("/api/v1/dashboard/" + path).DoRaw()
rawData, err := self.client.Get("/api/v1/dashboard/" + path).DoRaw(context.TODO())
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/backend/integration/metric/sidecar/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package sidecar

import (
"context"
"encoding/json"
"fmt"
"log"
Expand Down Expand Up @@ -89,7 +90,7 @@ func (self FakeSidecar) ID() integrationapi.IntegrationID {
return "fakeSidecar"
}

func (self FakeRequest) DoRaw() ([]byte, error) {
func (self FakeRequest) DoRaw(ctx context.Context) ([]byte, error) {
_NumRequests.increment()
log.Println("Performing req...")
path := self.Path
Expand Down
8 changes: 5 additions & 3 deletions src/app/backend/integration/metric/sidecar/restclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package sidecar

import (
"context"

"github.com/kubernetes/dashboard/src/app/backend/args"
"k8s.io/client-go/rest"
)
Expand All @@ -31,7 +33,7 @@ type SidecarRESTClient interface {
// RequestInterface is an interface that allows to make operations on pure request object.
// Separation is done to allow testing.
type RequestInterface interface {
DoRaw() ([]byte, error)
DoRaw(context.Context) ([]byte, error)
AbsPath(segments ...string) *rest.Request
}

Expand Down Expand Up @@ -60,7 +62,7 @@ func (self inClusterSidecarClient) HealthCheck() error {
Name("dashboard-metrics-scraper").
SubResource("proxy").
Suffix("/healthz").
DoRaw()
DoRaw(context.TODO())
return err
}

Expand All @@ -78,6 +80,6 @@ func (c remoteSidecarClient) Get(path string) RequestInterface {
// HealthCheck does a health check of the application.
// Returns nil if connection to application can be established, error object otherwise.
func (self remoteSidecarClient) HealthCheck() error {
_, err := self.Get("healthz").AbsPath("/").DoRaw()
_, err := self.Get("healthz").AbsPath("/").DoRaw(context.TODO())
return err
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5246b8c

Please sign in to comment.