mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Merge pull request #51228 from wongma7/mount-options-sc
Automatic merge from submit-queue Add storageClass.mountOptions and use it in all applicable plugins split off from https://github.com/kubernetes/kubernetes/pull/50919 and still dependent on it. cc @gnufied issue: https://github.com/kubernetes/features/issues/168 ```release-note Add mount options field to StorageClass. The options listed there are automatically added to PVs provisioned using the class. ```
This commit is contained in:
@@ -798,12 +798,13 @@ const operationDelete = "Delete"
|
||||
const operationRecycle = "Recycle"
|
||||
|
||||
var (
|
||||
classGold string = "gold"
|
||||
classSilver string = "silver"
|
||||
classEmpty string = ""
|
||||
classNonExisting string = "non-existing"
|
||||
classExternal string = "external"
|
||||
classUnknownInternal string = "unknown-internal"
|
||||
classGold string = "gold"
|
||||
classSilver string = "silver"
|
||||
classEmpty string = ""
|
||||
classNonExisting string = "non-existing"
|
||||
classExternal string = "external"
|
||||
classUnknownInternal string = "unknown-internal"
|
||||
classUnsupportedMountOptions string = "unsupported-mountoptions"
|
||||
)
|
||||
|
||||
// wrapTestWithPluginCalls returns a testCall that:
|
||||
|
||||
@@ -81,6 +81,18 @@ var storageClasses = []*storage.StorageClass{
|
||||
Parameters: class1Parameters,
|
||||
ReclaimPolicy: &deleteReclaimPolicy,
|
||||
},
|
||||
{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "StorageClass",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "unsupported-mountoptions",
|
||||
},
|
||||
Provisioner: mockPluginName,
|
||||
Parameters: class1Parameters,
|
||||
ReclaimPolicy: &deleteReclaimPolicy,
|
||||
MountOptions: []string{"foo"},
|
||||
},
|
||||
}
|
||||
|
||||
// call to storageClass 1, returning an error
|
||||
@@ -392,6 +404,17 @@ func TestProvisionSync(t *testing.T) {
|
||||
testSyncClaim,
|
||||
),
|
||||
},
|
||||
{
|
||||
// No provisioning + warning event with unsupported storageClass.mountOptions
|
||||
"11-20 - unsupported storageClass.mountOptions",
|
||||
novolumes,
|
||||
novolumes,
|
||||
newClaimArray("claim11-20", "uid11-20", "1Gi", "", v1.ClaimPending, &classUnsupportedMountOptions),
|
||||
newClaimArray("claim11-20", "uid11-20", "1Gi", "", v1.ClaimPending, &classUnsupportedMountOptions, annStorageProvisioner),
|
||||
// Expect event to be prefixed with "Mount options" because saving PV will fail anyway
|
||||
[]string{"Warning ProvisioningFailed Mount options"},
|
||||
noerrors, wrapTestWithProvisionCalls([]provisionCall{}, testSyncClaim),
|
||||
},
|
||||
}
|
||||
runSyncTests(t, tests, storageClasses)
|
||||
}
|
||||
|
||||
@@ -1283,6 +1283,7 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa
|
||||
|
||||
options := vol.VolumeOptions{
|
||||
PersistentVolumeReclaimPolicy: *storageClass.ReclaimPolicy,
|
||||
MountOptions: storageClass.MountOptions,
|
||||
CloudTags: &tags,
|
||||
ClusterName: ctrl.clusterName,
|
||||
PVName: pvName,
|
||||
@@ -1290,6 +1291,15 @@ func (ctrl *PersistentVolumeController) provisionClaimOperation(claimObj interfa
|
||||
Parameters: storageClass.Parameters,
|
||||
}
|
||||
|
||||
// Refuse to provision if the plugin doesn't support mount options, creation
|
||||
// of PV would be rejected by validation anyway
|
||||
if !plugin.SupportsMountOption() && len(options.MountOptions) > 0 {
|
||||
strerr := fmt.Sprintf("Mount options are not supported by the provisioner but StorageClass %q has mount options %v", storageClass.Name, options.MountOptions)
|
||||
glog.V(2).Infof("Mount options are not supported by the provisioner but claim %q's StorageClass %q has mount options %v", claimToClaimKey(claim), storageClass.Name, options.MountOptions)
|
||||
ctrl.eventRecorder.Event(claim, v1.EventTypeWarning, events.ProvisioningFailed, strerr)
|
||||
return
|
||||
}
|
||||
|
||||
// Provision the volume
|
||||
provisioner, err := plugin.NewProvisioner(options)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user