Skip to content

Commit

Permalink
Bump to crossplane v1.16 and enable MR metrics #232 (#285)
Browse files Browse the repository at this point in the history
* Bump to crossplane v1.16 and enable MR metrics

* Update go version and build submodule

* Bump golangci-lint version

* Fix unsafe conversion caught by updated linter

* Bump govulncheck version

* update go version in CI
  • Loading branch information
nolancon authored Oct 3, 2024
1 parent c8908c7 commit e2be5ab
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions:

env:
# Common versions
GO_VERSION: '1.21'
GO_VERSION: '1.23'
DOCKER_BUILDX_VERSION: 'v0.9.1'

# Common users. We can't run a step 'if secrets.XXX != ""' but we can run a
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:

env:
# Common versions
GO_VERSION: '1.21'
GO_VERSION: '1.23'
DOCKER_BUILDX_VERSION: 'v0.9.1'

# Common users. We can't run a step 'if secrets.XXX != ""' but we can run a
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-candidate-publish-and-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions:

env:
# Common versions
GO_VERSION: '1.21'
GO_VERSION: '1.23'
DOCKER_BUILDX_VERSION: 'v0.9.1'

# Common users. We can't run a step 'if secrets.XXX != ""' but we can run a
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LATEST_KUBE_VERSION ?= 1.29
LATEST_KIND_NODE ?= 1.29.2
REPO ?= provider-ceph

CROSSPLANE_VERSION ?= 1.15.0
CROSSPLANE_VERSION ?= 1.16.0
LOCALSTACK_VERSION ?= 2.2
CERT_MANAGER_VERSION ?= 1.14.0

Expand Down Expand Up @@ -44,7 +44,7 @@ GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/provider
GO_LDFLAGS += -X $(GO_PROJECT)/internal/version.Version=$(VERSION)
GO_SUBDIRS += cmd internal apis
GO111MODULE = on
GOLANGCILINT_VERSION ?= 1.56.2
GOLANGCILINT_VERSION ?= 1.61.0
-include build/makelib/golang.mk

# ====================================================================================
Expand Down Expand Up @@ -377,7 +377,7 @@ $(NILAWAY):
@mv $(TOOLS_HOST_DIR)/nilaway $(NILAWAY)
@$(OK) installing nilaway $(NILAWAY_VERSION)

GOVULNCHECK_VERSION ?= v1.0.4
GOVULNCHECK_VERSION ?= v1.1.3
GOVULNCHECK := $(TOOLS_HOST_DIR)/govulncheck-$(GOVULNCHECK_VERSION)

.PHONY: vulncheck
Expand Down
2 changes: 1 addition & 1 deletion build
43 changes: 30 additions & 13 deletions cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
kcache "sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics"
"sigs.k8s.io/controller-runtime/pkg/webhook"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
Expand All @@ -50,7 +51,9 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/logging"
"github.com/crossplane/crossplane-runtime/pkg/meta"
"github.com/crossplane/crossplane-runtime/pkg/ratelimiter"
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
"github.com/crossplane/crossplane-runtime/pkg/resource"
"github.com/crossplane/crossplane-runtime/pkg/statemetrics"

"github.com/linode/provider-ceph/apis"
providercephv1alpha1 "github.com/linode/provider-ceph/apis/provider-ceph/v1alpha1"
Expand Down Expand Up @@ -79,19 +82,20 @@ func main() {
leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool()
leaderRenew = app.Flag("leader-renew", "Set leader election renewal.").Short('r').Default("10s").OverrideDefaultFromEnvar("LEADER_ELECTION_RENEW").Duration()

syncInterval = app.Flag("sync", "How often all resources will be double-checked for drift from the desired state.").Short('s').Default("1h").Duration()
syncTimeout = app.Flag("sync-timeout", "Cache sync timeout.").Default("10s").Duration()
pollInterval = app.Flag("poll", "How often individual resources will be checked for drift from the desired state").Short('p').Default("30m").Duration()
bucketExistsCache = app.Flag("bucket-exists-cache", "How long the provider caches bucket exists result").Short('c').Default("5s").Duration()
reconcileConcurrency = app.Flag("reconcile-concurrency", "Set number of reconciliation loops.").Default("100").Int()
maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may checked for drift from the desired state.").Default("1000").Int()
reconcileTimeout = app.Flag("reconcile-timeout", "Object reconciliation timeout").Short('t').Default("3s").Duration()
s3Timeout = app.Flag("s3-timeout", "S3 API operations timeout").Default("10s").Duration()
creationGracePeriod = app.Flag("creation-grace-period", "Duration to wait for the external API to report that a newly created external resource exists.").Default("10s").Duration()
tracesEnabled = app.Flag("otel-enable-tracing", "").Default("false").Bool()
tracesExportTimeout = app.Flag("otel-traces-export-timeout", "Timeout when exporting traces").Default("2s").Duration()
tracesExportInterval = app.Flag("otel-traces-export-interval", "Interval at which traces are exported").Default("5s").Duration()
tracesExportAddress = app.Flag("otel-traces-export-address", "Address of otel collector").Default("opentelemetry-collector.opentelemetry:4317").String()
syncInterval = app.Flag("sync", "How often all resources will be double-checked for drift from the desired state.").Short('s').Default("1h").Duration()
syncTimeout = app.Flag("sync-timeout", "Cache sync timeout.").Default("10s").Duration()
pollInterval = app.Flag("poll", "How often individual resources will be checked for drift from the desired state").Short('p').Default("30m").Duration()
pollStateMetricInterval = app.Flag("poll-state-metric", "State metric recording interval").Default("5s").Duration()
bucketExistsCache = app.Flag("bucket-exists-cache", "How long the provider caches bucket exists result").Short('c').Default("5s").Duration()
reconcileConcurrency = app.Flag("reconcile-concurrency", "Set number of reconciliation loops.").Default("100").Int()
maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may checked for drift from the desired state.").Default("1000").Int()
reconcileTimeout = app.Flag("reconcile-timeout", "Object reconciliation timeout").Short('t').Default("3s").Duration()
s3Timeout = app.Flag("s3-timeout", "S3 API operations timeout").Default("10s").Duration()
creationGracePeriod = app.Flag("creation-grace-period", "Duration to wait for the external API to report that a newly created external resource exists.").Default("10s").Duration()
tracesEnabled = app.Flag("otel-enable-tracing", "").Default("false").Bool()
tracesExportTimeout = app.Flag("otel-traces-export-timeout", "Timeout when exporting traces").Default("2s").Duration()
tracesExportInterval = app.Flag("otel-traces-export-interval", "Interval at which traces are exported").Default("5s").Duration()
tracesExportAddress = app.Flag("otel-traces-export-address", "Address of otel collector").Default("opentelemetry-collector.opentelemetry:4317").String()

kubeClientRate = app.Flag("kube-client-rate", "The global maximum rate per second at how many requests the client can do.").Default("1000").Int()

Expand Down Expand Up @@ -223,6 +227,18 @@ func main() {
httpClient.Transport = otelhttp.NewTransport(httpClient.Transport)
httpClient.Timeout = *syncTimeout

mm := managed.NewMRMetricRecorder()
sm := statemetrics.NewMRStateMetrics()

metrics.Registry.MustRegister(mm)
metrics.Registry.MustRegister(sm)

mo := controller.MetricOptions{
PollStateMetricInterval: *pollStateMetricInterval,
MRMetrics: mm,
MRStateMetrics: sm,
}

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
LeaderElection: *leaderElection,
LeaderElectionID: "crossplane-leader-election-provider-ceph-ibyaiby",
Expand Down Expand Up @@ -257,6 +273,7 @@ func main() {
PollInterval: *pollInterval,
GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate),
Features: &feature.Flags{},
MetricOptions: &mo,
}

if *enableExternalSecretStores {
Expand Down
27 changes: 15 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/linode/provider-ceph

go 1.21
go 1.23

toolchain go1.21.12
toolchain go1.23.1

require (
github.com/alecthomas/kingpin/v2 v2.3.2
Expand All @@ -13,7 +13,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.51.1
github.com/aws/aws-sdk-go-v2/service/sts v1.28.1
github.com/aws/smithy-go v1.20.1
github.com/crossplane/crossplane-runtime v1.15.1
github.com/crossplane/crossplane-runtime v1.16.0
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79
github.com/google/go-cmp v0.6.0
github.com/pkg/errors v0.9.1
Expand All @@ -24,7 +24,7 @@ require (
go.opentelemetry.io/otel/sdk v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
go.uber.org/zap v1.26.0
golang.org/x/sync v0.6.0
golang.org/x/sync v0.8.0
google.golang.org/grpc v1.61.1
k8s.io/api v0.29.1
k8s.io/apimachinery v0.29.1
Expand Down Expand Up @@ -52,6 +52,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.20.1 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dave/jennifer v1.7.0 // indirect
Expand Down Expand Up @@ -87,6 +88,8 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo/v2 v2.19.0 // indirect
github.com/onsi/gomega v1.34.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
Expand All @@ -100,20 +103,20 @@ require (
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.org/x/tools v0.25.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit e2be5ab

Please sign in to comment.