Skip to content

Commit d038b65

Browse files
authored
Merge pull request kubernetes#121303 from humblec/csinodeexpand-ga
Promote CSINodeExpandSecret to GA
2 parents a8b7e19 + 3890546 commit d038b65

File tree

14 files changed

+19
-115
lines changed

14 files changed

+19
-115
lines changed

api/openapi-spec/swagger.json

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

api/openapi-spec/v3/api__v1_openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@
446446
"$ref": "#/components/schemas/io.k8s.api.core.v1.SecretReference"
447447
}
448448
],
449-
"description": "nodeExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeExpandVolume call. This is a beta field which is enabled default by CSINodeExpandSecret feature gate. This field is optional, may be omitted if no secret is required. If the secret object contains more than one secret, all secrets are passed."
449+
"description": "nodeExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeExpandVolume call. This field is optional, may be omitted if no secret is required. If the secret object contains more than one secret, all secrets are passed."
450450
},
451451
"nodePublishSecretRef": {
452452
"allOf": [

api/openapi-spec/v3/apis__storage.k8s.io__v1_openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
"$ref": "#/components/schemas/io.k8s.api.core.v1.SecretReference"
127127
}
128128
],
129-
"description": "nodeExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeExpandVolume call. This is a beta field which is enabled default by CSINodeExpandSecret feature gate. This field is optional, may be omitted if no secret is required. If the secret object contains more than one secret, all secrets are passed."
129+
"description": "nodeExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeExpandVolume call. This field is optional, may be omitted if no secret is required. If the secret object contains more than one secret, all secrets are passed."
130130
},
131131
"nodePublishSecretRef": {
132132
"allOf": [

pkg/api/persistentvolume/util.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ const (
3434
// DropDisabledSpecFields removes disabled fields from the pv spec.
3535
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pv spec.
3636
func DropDisabledSpecFields(pvSpec *api.PersistentVolumeSpec, oldPVSpec *api.PersistentVolumeSpec) {
37-
if !utilfeature.DefaultFeatureGate.Enabled(features.CSINodeExpandSecret) && !hasNodeExpansionSecrets(oldPVSpec) {
38-
if pvSpec.CSI != nil {
39-
pvSpec.CSI.NodeExpandSecretRef = nil
40-
}
41-
}
4237
if !utilfeature.DefaultFeatureGate.Enabled(features.VolumeAttributesClass) {
4338
if oldPVSpec == nil || oldPVSpec.VolumeAttributesClassName == nil {
4439
pvSpec.VolumeAttributesClassName = nil
@@ -54,17 +49,6 @@ func DropDisabledStatusFields(oldStatus, newStatus *api.PersistentVolumeStatus)
5449
}
5550
}
5651

57-
func hasNodeExpansionSecrets(oldPVSpec *api.PersistentVolumeSpec) bool {
58-
if oldPVSpec == nil || oldPVSpec.CSI == nil {
59-
return false
60-
}
61-
62-
if oldPVSpec.CSI.NodeExpandSecretRef != nil {
63-
return true
64-
}
65-
return false
66-
}
67-
6852
func GetWarningsForPersistentVolume(pv *api.PersistentVolume) []string {
6953
if pv == nil {
7054
return nil

pkg/api/persistentvolume/util_test.go

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -32,62 +32,15 @@ import (
3232
)
3333

3434
func TestDropDisabledFields(t *testing.T) {
35-
secretRef := &api.SecretReference{
36-
Name: "expansion-secret",
37-
Namespace: "default",
38-
}
3935
vacName := ptr.To("vac")
4036

4137
tests := map[string]struct {
42-
oldSpec *api.PersistentVolumeSpec
43-
newSpec *api.PersistentVolumeSpec
44-
expectOldSpec *api.PersistentVolumeSpec
45-
expectNewSpec *api.PersistentVolumeSpec
46-
csiExpansionEnabled bool
47-
vacEnabled bool
38+
oldSpec *api.PersistentVolumeSpec
39+
newSpec *api.PersistentVolumeSpec
40+
expectOldSpec *api.PersistentVolumeSpec
41+
expectNewSpec *api.PersistentVolumeSpec
42+
vacEnabled bool
4843
}{
49-
"disabled csi expansion clears secrets": {
50-
csiExpansionEnabled: false,
51-
newSpec: specWithCSISecrets(secretRef),
52-
expectNewSpec: specWithCSISecrets(nil),
53-
oldSpec: nil,
54-
expectOldSpec: nil,
55-
},
56-
"enabled csi expansion preserve secrets": {
57-
csiExpansionEnabled: true,
58-
newSpec: specWithCSISecrets(secretRef),
59-
expectNewSpec: specWithCSISecrets(secretRef),
60-
oldSpec: nil,
61-
expectOldSpec: nil,
62-
},
63-
"enabled csi expansion preserve secrets when both old and new have it": {
64-
csiExpansionEnabled: true,
65-
newSpec: specWithCSISecrets(secretRef),
66-
expectNewSpec: specWithCSISecrets(secretRef),
67-
oldSpec: specWithCSISecrets(secretRef),
68-
expectOldSpec: specWithCSISecrets(secretRef),
69-
},
70-
"disabled csi expansion old pv had secrets": {
71-
csiExpansionEnabled: false,
72-
newSpec: specWithCSISecrets(secretRef),
73-
expectNewSpec: specWithCSISecrets(secretRef),
74-
oldSpec: specWithCSISecrets(secretRef),
75-
expectOldSpec: specWithCSISecrets(secretRef),
76-
},
77-
"enabled csi expansion preserves secrets when old pv did not had secrets": {
78-
csiExpansionEnabled: true,
79-
newSpec: specWithCSISecrets(secretRef),
80-
expectNewSpec: specWithCSISecrets(secretRef),
81-
oldSpec: specWithCSISecrets(nil),
82-
expectOldSpec: specWithCSISecrets(nil),
83-
},
84-
"disabled csi expansion neither new pv nor old pv had secrets": {
85-
csiExpansionEnabled: false,
86-
newSpec: specWithCSISecrets(nil),
87-
expectNewSpec: specWithCSISecrets(nil),
88-
oldSpec: specWithCSISecrets(nil),
89-
expectOldSpec: specWithCSISecrets(nil),
90-
},
9144
"disabled vac clears volume attributes class name": {
9245
vacEnabled: false,
9346
newSpec: specWithVACName(vacName),
@@ -134,7 +87,6 @@ func TestDropDisabledFields(t *testing.T) {
13487

13588
for name, tc := range tests {
13689
t.Run(name, func(t *testing.T) {
137-
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSINodeExpandSecret, tc.csiExpansionEnabled)()
13890
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.VolumeAttributesClass, tc.vacEnabled)()
13991

14092
DropDisabledSpecFields(tc.newSpec, tc.oldSpec)
@@ -148,22 +100,6 @@ func TestDropDisabledFields(t *testing.T) {
148100
}
149101
}
150102

151-
func specWithCSISecrets(secret *api.SecretReference) *api.PersistentVolumeSpec {
152-
pvSpec := &api.PersistentVolumeSpec{
153-
PersistentVolumeSource: api.PersistentVolumeSource{
154-
CSI: &api.CSIPersistentVolumeSource{
155-
Driver: "com.google.gcepd",
156-
VolumeHandle: "foobar",
157-
},
158-
},
159-
}
160-
161-
if secret != nil {
162-
pvSpec.CSI.NodeExpandSecretRef = secret
163-
}
164-
return pvSpec
165-
}
166-
167103
func specWithVACName(vacName *string) *api.PersistentVolumeSpec {
168104
pvSpec := &api.PersistentVolumeSpec{
169105
PersistentVolumeSource: api.PersistentVolumeSource{

pkg/apis/core/types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,10 +1879,8 @@ type CSIPersistentVolumeSource struct {
18791879
// NodeExpandSecretRef is a reference to the secret object containing
18801880
// sensitive information to pass to the CSI driver to complete the CSI
18811881
// NodeExpandVolume call.
1882-
// This is a beta field which is enabled default by CSINodeExpandSecret feature gate.
18831882
// This field is optional, may be omitted if no secret is required. If the
18841883
// secret object contains more than one secret, all secrets are passed.
1885-
// +featureGate=CSINodeExpandSecret
18861884
// +optional
18871885
NodeExpandSecretRef *SecretReference
18881886
}

pkg/features/kube_features.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const (
163163
// kep: https://kep.k8s.io/3171
164164
// alpha: v1.25
165165
// beta: v1.27
166-
//
166+
// GA: v1.29
167167
// Enables SecretRef field in CSI NodeExpandVolume request.
168168
CSINodeExpandSecret featuregate.Feature = "CSINodeExpandSecret"
169169

@@ -1006,7 +1006,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
10061006

10071007
CSIMigrationRBD: {Default: false, PreRelease: featuregate.Deprecated}, // deprecated in 1.28, remove in 1.31
10081008

1009-
CSINodeExpandSecret: {Default: true, PreRelease: featuregate.Beta},
1009+
CSINodeExpandSecret: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.31
10101010

10111011
CSIVolumeHealth: {Default: false, PreRelease: featuregate.Alpha},
10121012

pkg/generated/openapi/zz_generated.openapi.go

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

pkg/registry/core/persistentvolume/strategy.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package persistentvolume
1919
import (
2020
"context"
2121
"fmt"
22+
2223
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324
utilfeature "k8s.io/apiserver/pkg/util/feature"
2425
"k8s.io/kubernetes/pkg/features"
@@ -74,8 +75,6 @@ func (persistentvolumeStrategy) PrepareForCreate(ctx context.Context, obj runtim
7475
now := NowFunc()
7576
pv.Status.LastPhaseTransitionTime = &now
7677
}
77-
78-
pvutil.DropDisabledSpecFields(&pv.Spec, nil)
7978
}
8079

8180
func (persistentvolumeStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
@@ -103,8 +102,6 @@ func (persistentvolumeStrategy) PrepareForUpdate(ctx context.Context, obj, old r
103102
newPv := obj.(*api.PersistentVolume)
104103
oldPv := old.(*api.PersistentVolume)
105104
newPv.Status = oldPv.Status
106-
107-
pvutil.DropDisabledSpecFields(&newPv.Spec, &oldPv.Spec)
108105
}
109106

110107
func (persistentvolumeStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {

pkg/volume/csi/expander.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ import (
2323
"google.golang.org/grpc/codes"
2424
"google.golang.org/grpc/status"
2525
api "k8s.io/api/core/v1"
26-
utilfeature "k8s.io/apiserver/pkg/util/feature"
2726
"k8s.io/klog/v2"
28-
"k8s.io/kubernetes/pkg/features"
2927
"k8s.io/kubernetes/pkg/volume"
3028
"k8s.io/kubernetes/pkg/volume/util"
3129
volumetypes "k8s.io/kubernetes/pkg/volume/util/types"
@@ -83,13 +81,12 @@ func (c *csiPlugin) nodeExpandWithClient(
8381
}
8482
nodeExpandSecrets := map[string]string{}
8583
expandClient := c.host.GetKubeClient()
86-
if utilfeature.DefaultFeatureGate.Enabled(features.CSINodeExpandSecret) {
87-
if csiSource.NodeExpandSecretRef != nil {
88-
nodeExpandSecrets, err = getCredentialsFromSecret(expandClient, csiSource.NodeExpandSecretRef)
89-
if err != nil {
90-
return false, fmt.Errorf("expander.NodeExpand failed to get NodeExpandSecretRef %s/%s: %v",
91-
csiSource.NodeExpandSecretRef.Namespace, csiSource.NodeExpandSecretRef.Name, err)
92-
}
84+
85+
if csiSource.NodeExpandSecretRef != nil {
86+
nodeExpandSecrets, err = getCredentialsFromSecret(expandClient, csiSource.NodeExpandSecretRef)
87+
if err != nil {
88+
return false, fmt.Errorf("expander.NodeExpand failed to get NodeExpandSecretRef %s/%s: %v",
89+
csiSource.NodeExpandSecretRef.Namespace, csiSource.NodeExpandSecretRef.Name, err)
9390
}
9491
}
9592

0 commit comments

Comments
 (0)