mirror of https://github.com/k3s-io/k3s
add provision failure hook in fake volume plugin
parent
9ba74cb5b5
commit
814dbac3df
|
@ -46,6 +46,10 @@ import (
|
|||
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
|
||||
)
|
||||
|
||||
// A hook specified in storage class to indicate it's provisioning
|
||||
// is expected to fail.
|
||||
const ExpectProvisionFailureKey = "expect-provision-failure"
|
||||
|
||||
// fakeVolumeHost is useful for testing volume plugins.
|
||||
type fakeVolumeHost struct {
|
||||
rootDir string
|
||||
|
@ -787,6 +791,12 @@ type FakeProvisioner struct {
|
|||
}
|
||||
|
||||
func (fc *FakeProvisioner) Provision(selectedNode *v1.Node, allowedTopologies []v1.TopologySelectorTerm) (*v1.PersistentVolume, error) {
|
||||
// Add provision failure hook
|
||||
if fc.Options.Parameters != nil {
|
||||
if _, ok := fc.Options.Parameters[ExpectProvisionFailureKey]; ok {
|
||||
return nil, fmt.Errorf("expected error")
|
||||
}
|
||||
}
|
||||
fullpath := fmt.Sprintf("/tmp/hostpath_pv/%s", uuid.NewUUID())
|
||||
|
||||
pv := &v1.PersistentVolume{
|
||||
|
|
Loading…
Reference in New Issue