Skip to content

Commit b6a8cbb

Browse files
authored
Merge pull request #479 from AndrewSirenko/cherry-picks
Release v1.13.2
2 parents 20072c0 + 372e42c commit b6a8cbb

File tree

11 files changed

+302
-15
lines changed

11 files changed

+302
-15
lines changed

CHANGELOG/CHANGELOG-1.13.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# Release notes for 1.13.2
2+
3+
[Documentation](https://kubernetes-csi.github.io)
4+
5+
## Changes by Kind
6+
7+
### Feature
8+
9+
- Serve additional leader election, work queue, process, and Go runtime metrics ([#475](https://github.com/kubernetes-csi/external-resizer/pull/475), [@AndrewSirenko](https://github.com/AndrewSirenko))
10+
11+
### Bug fix
12+
13+
- Fix panic when attempting to modify non-CSI volumes ([#471](https://github.com/kubernetes-csi/external-resizer/pull/471), [@AndrewSirenko](https://github.com/AndrewSirenko))
14+
15+
## Dependencies
16+
17+
### Added
18+
_Nothing has changed._
19+
20+
### Changed
21+
- github.com/kubernetes-csi/csi-lib-utils: [v0.20.0 → v0.21.0](https://github.com/kubernetes-csi/csi-lib-utils/compare/v0.20.0...v0.21.0)
22+
23+
### Removed
24+
_Nothing has changed._
25+
126
# Release notes for 1.13.0
227

328
[Documentation](https://kubernetes-csi.github.io)

cmd/csi-resizer/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ import (
5353
"k8s.io/component-base/logs"
5454
logsapi "k8s.io/component-base/logs/api/v1"
5555
_ "k8s.io/component-base/logs/json/register"
56+
"k8s.io/component-base/metrics/legacyregistry"
57+
_ "k8s.io/component-base/metrics/prometheus/clientgo/leaderelection" // register leader election in the default legacy registry
58+
_ "k8s.io/component-base/metrics/prometheus/workqueue" // register work queues in the default legacy registry
5659
)
5760

5861
var (
@@ -177,6 +180,10 @@ func main() {
177180
csiClient = migratedCsiClient
178181
}
179182

183+
// Add default legacy registry so that metrics manager serves Go runtime and process metrics.
184+
// Also registers the `k8s.io/component-base/` work queue and leader election metrics we anonymously import.
185+
metricsManager.WithAdditionalRegistry(legacyregistry.DefaultGatherer)
186+
180187
csiResizer, err := resizer.NewResizerFromClient(
181188
csiClient,
182189
*timeout,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/container-storage-interface/spec v1.11.0
77
github.com/google/go-cmp v0.6.0
88
github.com/google/gofuzz v1.2.0 // indirect
9-
github.com/kubernetes-csi/csi-lib-utils v0.20.0
9+
github.com/kubernetes-csi/csi-lib-utils v0.21.0
1010
golang.org/x/oauth2 v0.25.0 // indirect
1111
golang.org/x/term v0.28.0 // indirect
1212
google.golang.org/grpc v1.69.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
6060
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
6161
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
6262
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
63-
github.com/kubernetes-csi/csi-lib-utils v0.20.0 h1:JTvHRJugn+cByMnIU4nCnqPqOOUhuPzhlLqRvenwjDA=
64-
github.com/kubernetes-csi/csi-lib-utils v0.20.0/go.mod h1:3b/HFVURW11oxV/gUAKyhhkvFpxXO/zRdvh1wdEfCZY=
63+
github.com/kubernetes-csi/csi-lib-utils v0.21.0 h1:dUN/iIgXLucAxyML2iPyhniIlACQumIeAJmIzsMBddc=
64+
github.com/kubernetes-csi/csi-lib-utils v0.21.0/go.mod h1:ZCVRTYuup+bwX9tOeE5Q3LDw64QvltSwMUQ3M3g2T+Q=
6565
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
6666
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
6767
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=

pkg/modifycontroller/controller.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,16 @@ func (ctrl *modifyController) syncPVC(key string) error {
268268
}
269269

270270
// Only trigger modify volume if the following conditions are met
271-
// 1. Non-empty vac name
272-
// 2. PVC is in Bound state
273-
// 3. PV CSI driver name matches local driver
271+
// 1. PV provisioned by CSI driver AND driver name matches local driver
272+
// 2. Non-empty vac name
273+
// 3. PVC is in Bound state
274+
if pv.Spec.CSI == nil || pv.Spec.CSI.Driver != ctrl.name {
275+
klog.V(7).InfoS("Skipping PV provisioned by different driver", "PV", klog.KObj(pv))
276+
return nil
277+
}
278+
274279
vacName := pvc.Spec.VolumeAttributesClassName
275-
if vacName != nil && *vacName != "" && pvc.Status.Phase == v1.ClaimBound && pv.Spec.CSI.Driver == ctrl.name {
280+
if vacName != nil && *vacName != "" && pvc.Status.Phase == v1.ClaimBound {
276281
_, _, err, _ := ctrl.modify(pvc, pv)
277282
if err != nil {
278283
return err

pkg/modifycontroller/controller_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/kubernetes-csi/external-resizer/pkg/util"
88
"google.golang.org/grpc/codes"
99
"google.golang.org/grpc/status"
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1011
"k8s.io/client-go/tools/cache"
1112
"testing"
1213
"time"
@@ -156,6 +157,25 @@ func TestSyncPVC(t *testing.T) {
156157
pvcWithUncreatedPV := createTestPVC(pvcName, targetVac /*vacName*/, testVac /*curVacName*/, testVac /*targetVacName*/)
157158
pvcWithUncreatedPV.Spec.VolumeName = ""
158159

160+
nonCSIPVC := &v1.PersistentVolumeClaim{
161+
ObjectMeta: metav1.ObjectMeta{Name: pvcName, Namespace: pvcNamespace},
162+
Spec: v1.PersistentVolumeClaimSpec{
163+
VolumeAttributesClassName: &targetVac,
164+
VolumeName: pvName,
165+
},
166+
Status: v1.PersistentVolumeClaimStatus{
167+
Phase: v1.ClaimBound,
168+
},
169+
}
170+
nonCSIPV := &v1.PersistentVolume{
171+
ObjectMeta: metav1.ObjectMeta{
172+
Name: pvName,
173+
},
174+
Spec: v1.PersistentVolumeSpec{
175+
VolumeAttributesClassName: nil,
176+
},
177+
}
178+
159179
tests := []struct {
160180
name string
161181
pvc *v1.PersistentVolumeClaim
@@ -192,6 +212,12 @@ func TestSyncPVC(t *testing.T) {
192212
pv: basePV,
193213
callCSIModify: false,
194214
},
215+
{
216+
name: "Should NOT modify if PV wasn't provisioned by CSI driver",
217+
pvc: nonCSIPVC,
218+
pv: nonCSIPV,
219+
callCSIModify: false,
220+
},
195221
}
196222

197223
for _, test := range tests {

vendor/github.com/kubernetes-csi/csi-lib-utils/metrics/metrics.go

Lines changed: 19 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kubernetes-csi/csi-lib-utils/protosanitizer/protosanitizer.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection/metrics.go

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)