Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1244 from mesosphere/kubernetes-1.18.5
Browse files Browse the repository at this point in the history
Kubernetes 1.18.5 dependency upgrade (plus other upgrades)
  • Loading branch information
k8s-ci-robot authored Jul 6, 2020
2 parents bf67d02 + 8055ba6 commit dd7ec09
Show file tree
Hide file tree
Showing 267 changed files with 4,614 additions and 25,387 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: go
# The version used here should match the BUILD_IMAGE variable in the
# Makefile.
go:
- "1.13.7"
- "1.14.4"

# Enable building in Travis using forked repos.
go_import_path: sigs.k8s.io/kubefed
Expand Down
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ endif
BUILDMNT = /go/src/$(GOTARGET)
# The version here should match the version of go configured in
# .travis.yml
BUILD_IMAGE ?= golang:1.13.7
BUILD_IMAGE ?= golang:1.14.4

HYPERFED_TARGET = bin/hyperfed
CONTROLLER_TARGET = bin/controller-manager
Expand All @@ -56,14 +56,15 @@ LDFLAG_OPTIONS = -ldflags "-X sigs.k8s.io/kubefed/pkg/version.version=$(GIT_VERS
-X sigs.k8s.io/kubefed/pkg/version.gitTreeState=$(GIT_TREESTATE) \
-X sigs.k8s.io/kubefed/pkg/version.buildDate=$(BUILDDATE)"

export GOPATH ?= $(shell go env GOPATH)
GO_BUILDCMD = CGO_ENABLED=0 go build $(VERBOSE_FLAG) $(LDFLAG_OPTIONS)

TESTARGS ?= $(VERBOSE_FLAG) -timeout 60s
TEST_PKGS ?= $(GOTARGET)/cmd/... $(GOTARGET)/pkg/...
TEST_CMD = go test $(TESTARGS)
TEST = $(TEST_CMD) $(TEST_PKGS)

DOCKER_BUILD ?= $(DOCKER) run --rm -v $(DIR):$(BUILDMNT) -w $(BUILDMNT) $(BUILD_IMAGE) /bin/sh -c
DOCKER_BUILD ?= $(DOCKER) run -it --rm -v $(DIR):$(BUILDMNT) -w $(BUILDMNT) $(BUILD_IMAGE) /bin/sh -c

# TODO (irfanurrehman): can add local compile, and auto-generate targets also if needed
.PHONY: all container push clean hyperfed controller kubefedctl test local-test vet fmt build bindir generate webhook e2e
Expand Down Expand Up @@ -128,9 +129,6 @@ e2e: $(E2E_BINARY_TARGET)

# Generate code
generate-code: controller-gen
ifndef GOPATH
$(error GOPATH not defined, please define GOPATH. Run "go help gopath" to learn more about GOPATH)
endif
controller-gen object:headerFile=./hack/boilerplate.go.txt paths="./..."

generate: generate-code kubefedctl
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ require (
github.com/evanphx/json-patch v4.5.0+incompatible
github.com/ghodss/yaml v1.0.0
github.com/json-iterator/go v1.1.9
github.com/onsi/ginkgo v1.12.0
github.com/onsi/gomega v1.9.0
github.com/onsi/ginkgo v1.13.0
github.com/onsi/gomega v1.10.1
github.com/openshift/generic-admission-server v1.14.0
github.com/pborman/uuid v1.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.0.0
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.4.0
k8s.io/api v0.17.3
k8s.io/apiextensions-apiserver v0.17.3
k8s.io/apimachinery v0.17.3
k8s.io/apiserver v0.17.3
k8s.io/client-go v0.17.3
k8s.io/component-base v0.17.3
k8s.io/api v0.18.5
k8s.io/apiextensions-apiserver v0.18.5
k8s.io/apimachinery v0.18.5
k8s.io/apiserver v0.18.5
k8s.io/client-go v0.18.5
k8s.io/component-base v0.18.5
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
k8s.io/kubectl v0.17.3
sigs.k8s.io/controller-runtime v0.5.0
sigs.k8s.io/yaml v1.1.0
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6
k8s.io/kubectl v0.18.5
sigs.k8s.io/controller-runtime v0.6.0
sigs.k8s.io/yaml v1.2.0
)
199 changes: 128 additions & 71 deletions go.sum

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pkg/controller/kubefedcluster/clusterclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package kubefedcluster

import (
"context"
"strings"
"time"

Expand Down Expand Up @@ -70,7 +71,7 @@ func NewClusterClientSet(c *fedv1b1.KubeFedCluster, client generic.Client, fedNa
if err != nil {
return nil, err
}
clusterConfig.Timeout = timeout
clusterConfig.Timeout = timeout //nolint:staticcheck
var clusterClientSet = ClusterClient{clusterName: c.Name}
if clusterConfig != nil {
clusterClientSet.kubeClient = kubeclientset.NewForConfigOrDie((restclient.AddUserAgent(clusterConfig, UserAgentName)))
Expand Down Expand Up @@ -125,7 +126,7 @@ func (self *ClusterClient) GetClusterHealthStatus() (*fedv1b1.KubeFedClusterStat
LastProbeTime: currentTime,
LastTransitionTime: &currentTime,
}
body, err := self.kubeClient.DiscoveryClient.RESTClient().Get().AbsPath("/healthz").Do().Raw()
body, err := self.kubeClient.DiscoveryClient.RESTClient().Get().AbsPath("/healthz").Do(context.Background()).Raw()
if err != nil {
runtime.HandleError(errors.Wrapf(err, "Failed to do cluster health check for cluster %q", self.clusterName))
clusterStatus.Conditions = append(clusterStatus.Conditions, newClusterOfflineCondition)
Expand All @@ -145,7 +146,7 @@ func (self *ClusterClient) GetClusterHealthStatus() (*fedv1b1.KubeFedClusterStat

// GetClusterZones gets the kubernetes cluster zones and region by inspecting labels on nodes in the cluster.
func (self *ClusterClient) GetClusterZones() ([]string, string, error) {
nodes, err := self.kubeClient.CoreV1().Nodes().List(metav1.ListOptions{})
nodes, err := self.kubeClient.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{})
if err != nil {
klog.Errorf("Failed to list nodes while getting zone names: %v", err)
return nil, "", err
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/kubefedcluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package kubefedcluster

import (
"context"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -111,7 +110,7 @@ func newClusterController(config *util.ControllerConfig, clusterHealthCheckConfi
kubeClient := kubeclient.NewForConfigOrDie(kubeConfig)
broadcaster := record.NewBroadcaster()
broadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
recorder := broadcaster.NewRecorder(genscheme.Scheme, corev1.EventSource{Component: fmt.Sprintf("kubefedcluster-controller")})
recorder := broadcaster.NewRecorder(genscheme.Scheme, corev1.EventSource{Component: "kubefedcluster-controller"})
cc.eventRecorder = recorder

var err error
Expand Down
15 changes: 14 additions & 1 deletion pkg/controller/kubefedcluster/controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ var _ = BeforeSuite(func(done Done) {
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient).ToNot(BeNil())

_, err = clientset.CoreV1().Namespaces().Create(
context.Background(),
&corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: util.DefaultKubeFedSystemNamespace,
},
},
metav1.CreateOptions{},
)
Expect(err).ToNot(HaveOccurred())

config = &util.ClusterHealthCheckConfig{
Period: 10 * time.Second,
FailureThreshold: 3,
Expand Down Expand Up @@ -121,7 +132,9 @@ var _ = Describe("TestKubefedClusterController", func() {
},
}

_, err := clientset.CoreV1().Secrets(util.DefaultKubeFedSystemNamespace).Create(kubefedClusterSecret)
_, err := clientset.CoreV1().Secrets(util.DefaultKubeFedSystemNamespace).Create(
context.Background(), kubefedClusterSecret, metav1.CreateOptions{},
)
Expect(err).ToNot(HaveOccurred())

kc := &fedv1b1.KubeFedCluster{
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/schedulingpreference/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func StartSchedulingPreferenceController(config *util.ControllerConfig, scheduli
if config.MinimizeLatency {
controller.minimizeLatency()
}
klog.Infof(fmt.Sprintf("Starting replicaschedulingpreferences controller"))
klog.Infof("Starting replicaschedulingpreferences controller")
controller.Run(stopChannel)
return controller.scheduler, nil
}
Expand All @@ -95,7 +95,7 @@ func newSchedulingPreferenceController(config *util.ControllerConfig, scheduling

broadcaster := record.NewBroadcaster()
broadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
recorder := broadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: fmt.Sprintf("replicaschedulingpreference-controller")})
recorder := broadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: "replicaschedulingpreference-controller"})

s := &SchedulingPreferenceController{
clusterAvailableDelay: config.ClusterAvailableDelay,
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/status/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package status

import (
"context"
"fmt"
"reflect"
"sort"
Expand Down Expand Up @@ -302,7 +303,7 @@ func (s *KubeFedStatusController) reconcile(qualifiedName util.QualifiedName) ut
}

if existingStatus == nil {
_, err = s.statusClient.Resources(qualifiedName.Namespace).Create(status, metav1.CreateOptions{})
_, err = s.statusClient.Resources(qualifiedName.Namespace).Create(context.Background(), status, metav1.CreateOptions{})
if err != nil {
runtime.HandleError(errors.Wrapf(err, "Failed to create status object for federated type %s %q", statusKind, key))
return util.StatusNeedsRecheck
Expand All @@ -312,7 +313,7 @@ func (s *KubeFedStatusController) reconcile(qualifiedName util.QualifiedName) ut
status.Object["clusterStatus"] = make([]util.ResourceClusterStatus, 0)
}
existingStatus.Object["clusterStatus"] = status.Object["clusterStatus"]
_, err = s.statusClient.Resources(qualifiedName.Namespace).Update(existingStatus, metav1.UpdateOptions{})
_, err = s.statusClient.Resources(qualifiedName.Namespace).Update(context.Background(), existingStatus, metav1.UpdateOptions{})
if err != nil {
runtime.HandleError(errors.Wrapf(err, "Failed to update status object for federated type %s %q", statusKind, key))
return util.StatusNeedsRecheck
Expand Down
5 changes: 1 addition & 4 deletions pkg/controller/sync/version/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ func (m *VersionManager) Sync(stopChan <-chan struct{}) {
if !ok {
return
}
ok = m.load(versionList, stopChan)
if !ok {
return
}
m.load(versionList, stopChan)
}

// HasSynced indicates whether the manager's in-memory state has been
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/util/genericinformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package util

import (
"context"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -68,14 +69,14 @@ func NewGenericInformerWithEventHandler(config *rest.Config, namespace string, o
ListFunc: func(opts metav1.ListOptions) (pkgruntime.Object, error) {
res := listObj.DeepCopyObject()
isNamespaceScoped := namespace != "" && mapping.Scope.Name() != meta.RESTScopeNameRoot
err := client.Get().NamespaceIfScoped(namespace, isNamespaceScoped).Resource(mapping.Resource.Resource).VersionedParams(&opts, scheme.ParameterCodec).Do().Into(res)
err := client.Get().NamespaceIfScoped(namespace, isNamespaceScoped).Resource(mapping.Resource.Resource).VersionedParams(&opts, scheme.ParameterCodec).Do(context.Background()).Into(res)
return res, err
},
WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) {
// Watch needs to be set to true separately
opts.Watch = true
isNamespaceScoped := namespace != "" && mapping.Scope.Name() != meta.RESTScopeNameRoot
return client.Get().NamespaceIfScoped(namespace, isNamespaceScoped).Resource(mapping.Resource.Resource).VersionedParams(&opts, scheme.ParameterCodec).Watch()
return client.Get().NamespaceIfScoped(namespace, isNamespaceScoped).Resource(mapping.Resource.Resource).VersionedParams(&opts, scheme.ParameterCodec).Watch(context.Background())
},
},
obj,
Expand Down
6 changes: 4 additions & 2 deletions pkg/controller/util/resourceinformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package util

import (
"context"

"github.com/pkg/errors"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -52,11 +54,11 @@ func newResourceInformer(client ResourceClient, namespace string, apiResource *m
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (pkgruntime.Object, error) {
options.LabelSelector = labelSelector
return client.Resources(namespace).List(options)
return client.Resources(namespace).List(context.Background(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
options.LabelSelector = labelSelector
return client.Resources(namespace).Watch(options)
return client.Resources(namespace).Watch(context.Background(), options)
},
},
obj, // use an unstructured type with apiVersion / kind populated for informer logging purposes
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubefedctl/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func customResourcesExist(config *rest.Config, resource *metav1.APIResource) (bo
}

options := metav1.ListOptions{}
objList, err := client.Resources("").List(options)
objList, err := client.Resources("").List(context.Background(), options)
if apierrors.IsNotFound(err) {
return false, nil
} else if err != nil {
Expand All @@ -366,7 +366,7 @@ func deleteFederatedCRD(config *rest.Config, crdName string, write func(string))
return errors.Wrap(err, "Error creating crd client")
}

err = client.CustomResourceDefinitions().Delete(crdName, nil)
err = client.CustomResourceDefinitions().Delete(context.Background(), crdName, metav1.DeleteOptions{})
if apierrors.IsNotFound(err) {
write(fmt.Sprintf("customresourcedefinition %q does not exist\n", crdName))
} else if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubefedctl/enable/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func CreateResources(cmdOut io.Writer, config *rest.Config, resources *typeResou
if err != nil {
return errors.Wrap(err, "Failed to create host clientset")
}
_, err = hostClientset.CoreV1().Namespaces().Get(namespace, metav1.GetOptions{})
_, err = hostClientset.CoreV1().Namespaces().Get(context.Background(), namespace, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return errors.Wrapf(err, "KubeFed system namespace %q does not exist", namespace)
} else if err != nil {
Expand Down Expand Up @@ -268,10 +268,10 @@ func CreateResources(cmdOut io.Writer, config *rest.Config, resources *typeResou
return errors.Wrap(err, "Failed to create crd clientset")
}

existingCRD, err := crdClient.CustomResourceDefinitions().Get(resources.CRD.Name, metav1.GetOptions{})
existingCRD, err := crdClient.CustomResourceDefinitions().Get(context.Background(), resources.CRD.Name, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
if !dryRun {
_, err = crdClient.CustomResourceDefinitions().Create(resources.CRD)
_, err = crdClient.CustomResourceDefinitions().Create(context.Background(), resources.CRD, metav1.CreateOptions{})
if err != nil {
return errors.Wrapf(err, "Error creating CRD %q", resources.CRD.Name)
}
Expand Down Expand Up @@ -315,7 +315,7 @@ func CreateResources(cmdOut io.Writer, config *rest.Config, resources *typeResou

existingCRD.Spec = resources.CRD.Spec
if !dryRun {
_, err = crdClient.CustomResourceDefinitions().Update(existingCRD)
_, err = crdClient.CustomResourceDefinitions().Update(context.Background(), existingCRD, metav1.UpdateOptions{})
if err != nil {
return errors.Wrapf(err, "Error updating CRD %q", resources.CRD.Name)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/kubefedctl/enable/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package enable

import (
"context"
"fmt"

"github.com/pkg/errors"
Expand Down Expand Up @@ -63,7 +64,7 @@ func newCRDSchemaAccessor(config *rest.Config, apiResource metav1.APIResource) (
return nil, errors.Wrap(err, "Failed to create crd clientset")
}
crdName := fmt.Sprintf("%s.%s", apiResource.Name, apiResource.Group)
crd, err := crdClient.CustomResourceDefinitions().Get(crdName, metav1.GetOptions{})
crd, err := crdClient.CustomResourceDefinitions().Get(context.Background(), crdName, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return nil, nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubefedctl/federate/federate.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func getTargetResource(hostConfig *rest.Config, typeConfig typeconfig.Interface,
}

kind := targetAPIResource.Kind
resource, err := targetClient.Resources(qualifiedName.Namespace).Get(qualifiedName.Name, metav1.GetOptions{})
resource, err := targetClient.Resources(qualifiedName.Namespace).Get(context.Background(), qualifiedName.Name, metav1.GetOptions{})
if err != nil {
return nil, errors.Wrapf(err, "Error retrieving target %s %q", kind, qualifiedName)
}
Expand Down Expand Up @@ -486,7 +486,7 @@ func CreateFederatedResource(hostConfig *rest.Config, typeConfig typeconfig.Inte
// It might take a little while for the federated type to appear if the
// same is being enabled while or immediately before federating the resource.
err = wait.PollImmediate(createResourceRetryInterval, createResourceRetryTimeout, func() (bool, error) {
_, err := fedClient.Resources(federatedResource.GetNamespace()).Create(federatedResource, metav1.CreateOptions{})
_, err := fedClient.Resources(federatedResource.GetNamespace()).Create(context.Background(), federatedResource, metav1.CreateOptions{})
if apierrors.IsNotFound(err) {
return false, nil
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/kubefedctl/federate/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package federate

import (
"bufio"
"context"
"io"
"os"

Expand Down Expand Up @@ -191,7 +192,7 @@ func getResourcesInNamespace(config *rest.Config, namespace string, skipAPIResou
return nil, errors.Wrapf(err, "Error creating client for %s", apiResource.Kind)
}

resourceList, err := client.Resources(namespace).List(metav1.ListOptions{})
resourceList, err := client.Resources(namespace).List(context.Background(), metav1.ListOptions{})
if apierrors.IsNotFound(err) || resourceList == nil {
continue
}
Expand Down
Loading

0 comments on commit dd7ec09

Please sign in to comment.