Skip to content

Commit

Permalink
dependencies: bump test-infra
Browse files Browse the repository at this point in the history
Generated with:
```
$ go get k8s.io/test-infra
$ go mod tidy
```

Signed-off-by: Steve Kuznetsov <[email protected]>
  • Loading branch information
stevekuznetsov authored and alvaroaleman committed Dec 14, 2020
1 parent c1f51a3 commit 45c5957
Show file tree
Hide file tree
Showing 12 changed files with 1,067 additions and 162 deletions.
14 changes: 7 additions & 7 deletions cleaner/cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
fakectrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"

"sigs.k8s.io/boskos/common"
Expand Down Expand Up @@ -50,7 +50,7 @@ type fakeBoskos struct {
}

// Create a fake client
func createFakeBoskos(objects ...runtime.Object) (*ranch.Storage, boskosClient, chan releasedResource) {
func createFakeBoskos(objects ...ctrlruntimeclient.Object) (*ranch.Storage, boskosClient, chan releasedResource) {
for _, obj := range objects {
obj.(metav1.Object).SetNamespace(testNS)
}
Expand Down Expand Up @@ -113,12 +113,12 @@ func testDRLC(rType string) common.DynamicResourceLifeCycle {
func TestRecycleResources(t *testing.T) {
for _, tc := range []struct {
name string
resources []runtime.Object
resources []ctrlruntimeclient.Object
expectedStates map[string]string
}{
{
name: "nothingToDo",
resources: []runtime.Object{
resources: []ctrlruntimeclient.Object{
testResource("static_3", "static", common.Free, "", nil),
},
expectedStates: map[string]string{
Expand All @@ -127,7 +127,7 @@ func TestRecycleResources(t *testing.T) {
},
{
name: "noLeasedResources",
resources: []runtime.Object{
resources: []ctrlruntimeclient.Object{
testResource("static_1", "static", "dynamic_1", "", nil),
testResource("static_2", "static", "dynamic_1", "", nil),
testResource("static_3", "static", common.Free, "", nil),
Expand All @@ -151,7 +151,7 @@ func TestRecycleResources(t *testing.T) {
},
{
name: "leasedResources",
resources: []runtime.Object{
resources: []ctrlruntimeclient.Object{
testResource("static_1", "static", "dynamic_1", "", nil),
testResource("static_2", "static", "dynamic_1", "", nil),
testResource("static_3", "static", "dynamic_2", "", nil),
Expand All @@ -175,7 +175,7 @@ func TestRecycleResources(t *testing.T) {
},
{
name: "missingLeasedResource",
resources: []runtime.Object{
resources: []ctrlruntimeclient.Object{
testResource("static_1", "static", "dynamic_1", "", nil),
testResource("static_2", "static", common.Free, "", nil),
testResource("static_3", "static", common.Free, "", nil),
Expand Down
3 changes: 2 additions & 1 deletion cleaner/v2/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ type reconciler struct {
namespace string
}

func (r *reconciler) Reconcile(request reconcile.Request) (reconcile.Result, error) {
func (r *reconciler) Reconcile(_ context.Context, request reconcile.Request) (reconcile.Result, error) {
// TODO(alvaroaleman): figure out how to use the context
log := logrus.WithField("resource-name", request.Name)
err := r.reconcile(log, request)
if err != nil {
Expand Down
10 changes: 4 additions & 6 deletions cleaner/v2/cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
fakectrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
Expand Down Expand Up @@ -53,7 +52,7 @@ func TestReconcile(t *testing.T) {

testCases := []struct {
name string
objects []runtime.Object
objects []ctrlruntimeclient.Object
verify func(ctrlruntimeclient.Client) error
}{
{
Expand Down Expand Up @@ -110,7 +109,7 @@ func TestReconcile(t *testing.T) {

request := reconcile.Request{NamespacedName: types.NamespacedName{Namespace: testNamespace, Name: testResourceName}}

if _, err := r.Reconcile(request); err != nil {
if _, err := r.Reconcile(context.Background(), request); err != nil {
t.Fatalf("reconciliation failed: %v", err)
}
if tc.verify == nil {
Expand All @@ -126,8 +125,7 @@ func TestReconcile(t *testing.T) {

type testObjectModifier func(*crds.ResourceObject, *crds.DRLCObject)

func createTestObjects(modifiers ...testObjectModifier) []runtime.Object {

func createTestObjects(modifiers ...testObjectModifier) []ctrlruntimeclient.Object {
drlcObject := &crds.DRLCObject{
ObjectMeta: metav1.ObjectMeta{
Namespace: testNamespace,
Expand All @@ -153,5 +151,5 @@ func createTestObjects(modifiers ...testObjectModifier) []runtime.Object {
modify(resourceObject, drlcObject)
}

return []runtime.Object{drlcObject, resourceObject}
return []ctrlruntimeclient.Object{drlcObject, resourceObject}
}
12 changes: 7 additions & 5 deletions cmd/boskos/boskos.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"context"
"flag"
"fmt"
"net/http"
Expand All @@ -28,6 +29,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
corev1 "k8s.io/api/core/v1"
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
Expand Down Expand Up @@ -168,7 +170,8 @@ type configSyncReconciler struct {
sync func() error
}

func (r *configSyncReconciler) Reconcile(_ reconcile.Request) (reconcile.Result, error) {
func (r *configSyncReconciler) Reconcile(_ context.Context, _ reconcile.Request) (reconcile.Result, error) {
// TODO(alvaroaleman): figure out how to use the context in the sync
err := r.sync()
if err != nil {
logrus.WithError(err).Error("Config sync failed")
Expand Down Expand Up @@ -205,11 +208,10 @@ func addConfigSyncReconcilerToManager(mgr manager.Manager, configSync func() err
}

func constHandler() handler.EventHandler {
return &handler.EnqueueRequestsFromMapFunc{
ToRequests: handler.ToRequestsFunc(func(handler.MapObject) []reconcile.Request {
return handler.EnqueueRequestsFromMapFunc(
func(object ctrlruntimeclient.Object) []reconcile.Request {
return []reconcile.Request{{}}
}),
}
})
}

// resourceUpdatePredicate prevents the config reconciler from reacting to resource update events
Expand Down
2 changes: 1 addition & 1 deletion cmd/cleaner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func v2Main(client *client.Client) {
logrus.WithError(err).Fatal("failed to add controller to manager.")
}

if err := mgr.Start(interrupts.Context().Done()); err != nil {
if err := mgr.Start(interrupts.Context()); err != nil {
logrus.WithError(err).Fatal("manager failed")
} else {
logrus.Info("manager ended gracefully.")
Expand Down
9 changes: 5 additions & 4 deletions crds/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (o *KubernetesClientOptions) Client() (ctrlruntimeclient.Client, error) {
// Manager returns a Manager. It contains a client whose Reader is cache backed. Namespace can be empty
// in which case the client will use all namespaces.
// It blocks until the cache was synced for all types passed in startCacheFor.
func (o *KubernetesClientOptions) Manager(namespace string, startCacheFor ...runtime.Object) (manager.Manager, error) {
func (o *KubernetesClientOptions) Manager(namespace string, startCacheFor ...ctrlruntimeclient.Object) (manager.Manager, error) {
if o.inMemory {
return manager.New(&rest.Config{}, manager.Options{
LeaderElection: false,
Expand Down Expand Up @@ -115,8 +115,9 @@ func (o *KubernetesClientOptions) Manager(namespace string, startCacheFor ...run
// Allocate an informer so our cache actually waits for these types to
// be synced. Must be done before we start the mgr, else this may block
// indefinitely if there is an issue.
ctx := interrupts.Context()
for _, t := range startCacheFor {
if _, err := mgr.GetCache().GetInformer(t); err != nil {
if _, err := mgr.GetCache().GetInformer(ctx, t); err != nil {
return nil, fmt.Errorf("failed to get informer for type %T: %v", t, err)
}
}
Expand All @@ -126,7 +127,7 @@ func (o *KubernetesClientOptions) Manager(namespace string, startCacheFor ...run
// doesn't allow us to stop the app. Furthermore, the behaviour
// of the reading client is undefined after the manager stops,
// so we should bail ASAP.
if err := mgr.Start(ctx.Done()); err != nil {
if err := mgr.Start(ctx); err != nil {
logrus.WithError(err).Fatal("Mgr failed.")
}
logrus.Info("Mgr finished gracefully.")
Expand All @@ -137,7 +138,7 @@ func (o *KubernetesClientOptions) Manager(namespace string, startCacheFor ...run
defer cancel()

startSyncTime := time.Now()
if synced := mgr.GetCache().WaitForCacheSync(ctx.Done()); !synced {
if synced := mgr.GetCache().WaitForCacheSync(ctx); !synced {
return nil, errors.New("timeout waiting for cache sync")
}
logrus.WithField("sync-duration", time.Since(startSyncTime).String()).Info("Cache synced")
Expand Down
32 changes: 16 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ go 1.14

replace (
// Bazel is seemingly broken with newer versions of this package
cloud.google.com/go => cloud.google.com/go v0.44.3
github.com/Azure/go-autorest => github.com/Azure/go-autorest v12.2.0+incompatible
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.1
// Pin all k8s.io staging repositories to kubernetes v0.17.3 to match kubernetes/test-infra.
k8s.io/api => k8s.io/api v0.17.3
k8s.io/apimachinery => k8s.io/apimachinery v0.17.3
k8s.io/client-go => k8s.io/client-go v0.17.3
k8s.io/code-generator => k8s.io/code-generator v0.17.3
k8s.io/api => k8s.io/api v0.19.3
k8s.io/apimachinery => k8s.io/apimachinery v0.19.3
k8s.io/client-go => k8s.io/client-go v0.19.3
k8s.io/code-generator => k8s.io/code-generator v0.19.3
)

require (
github.com/aws/aws-sdk-go v1.31.12
github.com/fsnotify/fsnotify v1.4.7
github.com/fsnotify/fsnotify v1.4.9
github.com/go-test/deep v1.0.4
github.com/google/go-cmp v0.4.0
github.com/google/go-cmp v0.5.2
github.com/google/uuid v1.1.1
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/go-multierror v1.1.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.5.0
github.com/prometheus/client_golang v1.7.1
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v0.0.6
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.6.2
k8s.io/api v0.17.3
k8s.io/apimachinery v0.17.3
k8s.io/client-go v9.0.0+incompatible
k8s.io/test-infra v0.0.0-20200617221206-ea73eaeab7ff
sigs.k8s.io/controller-runtime v0.5.4
github.com/spf13/viper v1.7.0
k8s.io/api v0.19.3
k8s.io/apimachinery v0.19.3
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/test-infra v0.0.0-20201214190528-57362ae63e51
sigs.k8s.io/controller-runtime v0.7.0-alpha.6.0.20201106193838-8d0107636985
sigs.k8s.io/yaml v1.2.0
)
Loading

0 comments on commit 45c5957

Please sign in to comment.