mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #116089 from cvvz/fix-116028
fix: should not set default storageclass if annotation "volume.beta.kubernetes.io/storage-class" is set
This commit is contained in:
commit
5157158d3d
@ -937,7 +937,7 @@ func (ctrl *PersistentVolumeController) updateVolumePhaseWithEvent(volume *v1.Pe
|
||||
// Ignores claims that already have a storage class.
|
||||
// TODO: if resync is ever changed to a larger period, we might need to change how we set the default class on existing unbound claims
|
||||
func (ctrl *PersistentVolumeController) assignDefaultStorageClass(claim *v1.PersistentVolumeClaim) (bool, error) {
|
||||
if claim.Spec.StorageClassName != nil {
|
||||
if storagehelpers.GetPersistentVolumeClaimClass(claim) != "" {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
@ -862,6 +862,24 @@ func TestRetroactiveStorageClassAssignment(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
storageClasses: []*storagev1.StorageClass{
|
||||
makeDefaultStorageClass(classGold, &modeImmediate),
|
||||
makeStorageClass(classCopper, &modeImmediate),
|
||||
},
|
||||
tests: []controllerTest{
|
||||
{
|
||||
name: "15-7 - pvc storage class is not changed if claim is not bound but already set annotation \"volume.beta.kubernetes.io/storage-class\"",
|
||||
initialVolumes: novolumes,
|
||||
expectedVolumes: novolumes,
|
||||
initialClaims: newClaimArray("claim15-7", "uid15-7", "1Gi", "", v1.ClaimPending, nil, v1.BetaStorageClassAnnotation),
|
||||
expectedClaims: newClaimArray("claim15-7", "uid15-7", "1Gi", "", v1.ClaimPending, nil, v1.BetaStorageClassAnnotation),
|
||||
expectedEvents: noevents,
|
||||
errors: noerrors,
|
||||
test: testSyncClaim,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
runSyncTests(t, test.tests, test.storageClasses, nil)
|
||||
|
Loading…
Reference in New Issue
Block a user