Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies (big jump of controller-runtime) and Golang to 1.18 #212

Merged
merged 2 commits into from Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test.yaml
Expand Up @@ -23,7 +23,7 @@ jobs:
file: Dockerfile.controller
push: true
build-args: |
GO_BUILDER_IMG=golang:1.17
GO_BUILDER_IMG=golang:1.18
tags: |
ghcr.io/grafana/operator:${{ github.sha }}
kind:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yaml
Expand Up @@ -45,7 +45,7 @@ jobs:
push: true
file: Dockerfile.controller
build-args: |
GO_BUILDER_IMG=golang:1.17
GO_BUILDER_IMG=golang:1.18
tags: ghcr.io/grafana/operator:latest,ghcr.io/grafana/operator:controller-${{env.IMAGETAG}}
- name: "Build:dockerimage"
uses: docker/build-push-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yaml
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.16.x]
go-version: [1.18.x]
k8s_version: [1.19.2]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -12,7 +12,7 @@ endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

# Image to use for building Go
GO_BUILDER_IMG ?= "golang:1.17"
GO_BUILDER_IMG ?= "golang:1.18"
# Image URL to use all building/pushing image targets
IMG ?= ghcr.io/grafana/operator:latest
# Default dockerfile to build
Expand Down
746 changes: 684 additions & 62 deletions config/crd/bases/k6.io_k6s.yaml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions config/rbac/leader_election_role.yaml
Expand Up @@ -17,6 +17,15 @@ rules:
- update
- patch
- delete
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- get
- list
- update
- apiGroups:
- ""
resources:
Expand Down
32 changes: 17 additions & 15 deletions controllers/k6_controller.go
Expand Up @@ -17,8 +17,8 @@ package controllers
import (
"context"
"fmt"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/handler"
Expand Down Expand Up @@ -50,7 +50,8 @@ type K6Reconciler struct {
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;patch;delete
func (r *K6Reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;create;update
func (r *K6Reconciler) Reconcile(_ context.Context, req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
log := r.Log.WithValues("namespace", req.Namespace, "name", req.Name)

Expand Down Expand Up @@ -101,26 +102,27 @@ func (r *K6Reconciler) SetupWithManager(mgr ctrl.Manager) error {
For(&v1alpha1.K6{}).
Owns(&batchv1.Job{}).
Watches(&source.Kind{Type: &v1.Pod{}},
&handler.EnqueueRequestsFromMapFunc{ToRequests: handler.ToRequestsFunc(
func(object handler.MapObject) []reconcile.Request {
pod := object.Object.(*v1.Pod)
handler.EnqueueRequestsFromMapFunc(
func(object client.Object) []reconcile.Request {
pod := object.(*v1.Pod)
k6CrName, ok := pod.GetLabels()[k6CrLabelName]
if !ok {
return nil
}
return []reconcile.Request{
{NamespacedName: types.NamespacedName{
Name: k6CrName,
Namespace: object.Meta.GetNamespace(),
Namespace: object.GetNamespace(),
}}}
})},
builder.WithPredicates(predicate.NewPredicateFuncs(func(meta metav1.Object, object runtime.Object) bool {
pod := object.(*v1.Pod)
_, ok := pod.GetLabels()[k6CrLabelName]
if !ok {
return false
}
return true
}))).
}),
builder.WithPredicates(predicate.NewPredicateFuncs(
func(object client.Object) bool {
pod := object.(*v1.Pod)
_, ok := pod.GetLabels()[k6CrLabelName]
if !ok {
return false
}
return true
}))).
Complete(r)
}
7 changes: 2 additions & 5 deletions controllers/suite_test.go
Expand Up @@ -24,7 +24,6 @@ import (
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

Expand All @@ -42,13 +41,11 @@ var testEnv *envtest.Environment
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
RunSpecs(t, "Controller Suite")
}

var _ = BeforeSuite(func(done Done) {
logf.SetLogger(zap.LoggerTo(GinkgoWriter, true))
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter)))

By("bootstrapping test environment")
testEnv = &envtest.Environment{
Expand Down
129 changes: 65 additions & 64 deletions go.mod
@@ -1,89 +1,90 @@
module github.com/grafana/k6-operator

go 1.17
go 1.18

require (
github.com/go-logr/logr v0.1.0
github.com/go-logr/logr v1.2.4
github.com/go-test/deep v1.0.7
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
go.k6.io/k6 v0.35.0
k8s.io/api v0.18.6
k8s.io/apimachinery v0.18.6
k8s.io/client-go v0.18.6
sigs.k8s.io/controller-runtime v0.6.2
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.24.1
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.0
go.k6.io/k6 v0.43.1
gopkg.in/guregu/null.v3 v3.3.0
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.3
k8s.io/client-go v0.26.1
sigs.k8s.io/controller-runtime v0.14.6
)

require (
cloud.google.com/go v0.46.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect
github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06 // indirect
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/zapr v0.1.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/go-cmp v0.5.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.9 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/kubernetes/helm v2.9.0+incompatible // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/nxadm/tail v1.4.4 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mstoykov/atlas v0.0.0-20220808085829-90340e9998bd // indirect
github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.4.1 // indirect
github.com/prometheus/procfs v0.0.11 // indirect
github.com/prometheus/client_golang v1.14.1-0.20221122130035-8b6e68085b10 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e // indirect
golang.org/x/net v0.0.0-20211101194204-95aca89e93de // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 // indirect
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
golang.org/x/text v0.3.7-0.20210503195748-5c7c50ebbd4f // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gomodules.xyz/jsonpatch/v2 v2.0.1 // indirect
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12 // indirect
gopkg.in/guregu/null.v3 v3.3.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
k8s.io/apiextensions-apiserver v0.18.6 // indirect
k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.0.0 // indirect
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 // indirect
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 // indirect
sigs.k8s.io/structured-merge-diff/v3 v3.0.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/grafana/k6-operator => ./