Skip to content

Commit

Permalink
Update provisioner lib to v10
Browse files Browse the repository at this point in the history
Update the metrics registration to v10 - there are no global metrics now,
give them to the provisioner by `provisionerOptions`.
  • Loading branch information
jsafrane committed May 13, 2024
1 parent 3b5a778 commit a5f4501
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 206 deletions.
55 changes: 29 additions & 26 deletions cmd/csi-provisioner/csi-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ import (
_ "k8s.io/component-base/metrics/prometheus/workqueue" // register work queues in the default legacy registry
csitrans "k8s.io/csi-translation-lib"
klog "k8s.io/klog/v2"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller"
libmetrics "sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller/metrics"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v10/controller"
libmetrics "sigs.k8s.io/sig-storage-lib-external-provisioner/v10/controller/metrics"

"github.com/kubernetes-csi/csi-lib-utils/leaderelection"
"github.com/kubernetes-csi/csi-lib-utils/metrics"
Expand Down Expand Up @@ -553,34 +553,20 @@ func main() {
csiProvisioner = capacity.NewProvisionWrapper(csiProvisioner, capacityController)
}

provisionController = controller.NewProvisionController(
clientset,
provisionerName,
csiProvisioner,
provisionerOptions...,
)

csiClaimController := ctrl.NewCloningProtectionController(
clientset,
claimLister,
claimInformer,
claimQueue,
controllerCapabilities,
)

// Start HTTP server, regardless whether we are the leader or not.
if addr != "" {
// To collect metrics data from the metric handler itself, we
// let it register itself and then collect from that registry.
// Start HTTP server, regardless whether we are the leader or not.
// Register provisioner metrics manually to be able to add multiplexer in front of it
m := libmetrics.New("controller")
reg := prometheus.NewRegistry()
reg.MustRegister([]prometheus.Collector{
libmetrics.PersistentVolumeClaimProvisionTotal,
libmetrics.PersistentVolumeClaimProvisionFailedTotal,
libmetrics.PersistentVolumeClaimProvisionDurationSeconds,
libmetrics.PersistentVolumeDeleteTotal,
libmetrics.PersistentVolumeDeleteFailedTotal,
libmetrics.PersistentVolumeDeleteDurationSeconds,
m.PersistentVolumeClaimProvisionTotal,
m.PersistentVolumeClaimProvisionFailedTotal,
m.PersistentVolumeClaimProvisionDurationSeconds,
m.PersistentVolumeDeleteTotal,
m.PersistentVolumeDeleteFailedTotal,
m.PersistentVolumeDeleteDurationSeconds,
}...)
provisionerOptions = append(provisionerOptions, controller.MetricsInstance(m))
gatherers = append(gatherers, reg)

// This is similar to k8s.io/component-base/metrics HandlerWithReset
Expand Down Expand Up @@ -611,6 +597,23 @@ func main() {
}()
}

logger := klog.FromContext(ctx)
provisionController = controller.NewProvisionController(
logger,
clientset,
provisionerName,
csiProvisioner,
provisionerOptions...,
)

csiClaimController := ctrl.NewCloningProtectionController(
clientset,
claimLister,
claimInformer,
claimQueue,
controllerCapabilities,
)

run := func(ctx context.Context) {
factory.Start(ctx.Done())
if factoryForNamespace != nil {
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/kubernetes-csi/external-provisioner

go 1.22.0

toolchain go1.22.3
go 1.22.3

require (
github.com/container-storage-interface/spec v1.9.0
Expand All @@ -29,7 +27,7 @@ require (
k8s.io/klog/v2 v2.120.1
sigs.k8s.io/controller-runtime v0.17.3
sigs.k8s.io/gateway-api v1.0.0
sigs.k8s.io/sig-storage-lib-external-provisioner/v9 v9.1.0-rc.0
sigs.k8s.io/sig-storage-lib-external-provisioner/v10 v10.0.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ sigs.k8s.io/gateway-api v1.0.0 h1:iPTStSv41+d9p0xFydll6d7f7MOBGuqXM6p2/zVYMAs=
sigs.k8s.io/gateway-api v1.0.0/go.mod h1:4cUgr0Lnp5FZ0Cdq8FdRwCvpiWws7LVhLHGIudLlf4c=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/sig-storage-lib-external-provisioner/v9 v9.1.0-rc.0 h1:0aLQSafwBXlXTPiA9wJK5wEDsgYUh5uJlKHpBw9dwCk=
sigs.k8s.io/sig-storage-lib-external-provisioner/v9 v9.1.0-rc.0/go.mod h1:MMl64GlAImSAd7mOvJZ8SOkKORuvV/lsjhtgLPDlGjQ=
sigs.k8s.io/sig-storage-lib-external-provisioner/v10 v10.0.0 h1:+OhFU21hL9Gq/sHKHfYxbc7M6RWV3UqTpnk5/wF9cP4=
sigs.k8s.io/sig-storage-lib-external-provisioner/v10 v10.0.0/go.mod h1:mfQ2enu5yAHUhpNWsce9NmkqkRQsk70zQT+7KjZ+JMo=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
Expand Down
2 changes: 1 addition & 1 deletion pkg/capacity/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"

v1 "k8s.io/api/core/v1"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v10/controller"
)

type provisionWrapper struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/clone_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v10/controller"
)

//
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
klog "k8s.io/klog/v2"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v9/util"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v10/controller"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v10/util"

"github.com/kubernetes-csi/csi-lib-utils/connection"
"github.com/kubernetes-csi/csi-lib-utils/metrics"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
utilfeaturetesting "k8s.io/component-base/featuregate/testing"
csitrans "k8s.io/csi-translation-lib"
klog "k8s.io/klog/v2"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v10/controller"

"github.com/kubernetes-csi/csi-lib-utils/connection"
"github.com/kubernetes-csi/csi-lib-utils/metrics"
Expand Down
10 changes: 5 additions & 5 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1485,11 +1485,11 @@ sigs.k8s.io/gateway-api/pkg/client/listers/apis/v1beta1
## explicit; go 1.18
sigs.k8s.io/json
sigs.k8s.io/json/internal/golang/encoding/json
# sigs.k8s.io/sig-storage-lib-external-provisioner/v9 v9.1.0-rc.0
## explicit; go 1.19
sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller
sigs.k8s.io/sig-storage-lib-external-provisioner/v9/controller/metrics
sigs.k8s.io/sig-storage-lib-external-provisioner/v9/util
# sigs.k8s.io/sig-storage-lib-external-provisioner/v10 v10.0.0
## explicit; go 1.22.0
sigs.k8s.io/sig-storage-lib-external-provisioner/v10/controller
sigs.k8s.io/sig-storage-lib-external-provisioner/v10/controller/metrics
sigs.k8s.io/sig-storage-lib-external-provisioner/v10/util
# sigs.k8s.io/structured-merge-diff/v4 v4.4.1
## explicit; go 1.13
sigs.k8s.io/structured-merge-diff/v4/fieldpath
Expand Down
Loading

0 comments on commit a5f4501

Please sign in to comment.