Graduate ReadWriteOncePod to GA
This commit is contained in:
@@ -24,9 +24,6 @@ import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/feature"
|
||||
@@ -355,8 +352,6 @@ func TestISCSIDiskConflicts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccessModeConflicts(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ReadWriteOncePod, true)()
|
||||
|
||||
// Required for querying lister for PVCs in the same namespace.
|
||||
podWithOnePVC := st.MakePod().Name("pod-with-one-pvc").Namespace(metav1.NamespaceDefault).PVC("claim-with-rwop-1").Node("node-1").Obj()
|
||||
podWithTwoPVCs := st.MakePod().Name("pod-with-two-pvcs").Namespace(metav1.NamespaceDefault).PVC("claim-with-rwop-1").PVC("claim-with-rwop-2").Node("node-1").Obj()
|
||||
@@ -401,81 +396,64 @@ func TestAccessModeConflicts(t *testing.T) {
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
pod *v1.Pod
|
||||
nodeInfo *framework.NodeInfo
|
||||
existingPods []*v1.Pod
|
||||
existingNodes []*v1.Node
|
||||
existingPVCs []*v1.PersistentVolumeClaim
|
||||
enableReadWriteOncePod bool
|
||||
preFilterWantStatus *framework.Status
|
||||
wantStatus *framework.Status
|
||||
name string
|
||||
pod *v1.Pod
|
||||
nodeInfo *framework.NodeInfo
|
||||
existingPods []*v1.Pod
|
||||
existingNodes []*v1.Node
|
||||
existingPVCs []*v1.PersistentVolumeClaim
|
||||
preFilterWantStatus *framework.Status
|
||||
wantStatus *framework.Status
|
||||
}{
|
||||
{
|
||||
name: "nothing",
|
||||
pod: &v1.Pod{},
|
||||
nodeInfo: framework.NewNodeInfo(),
|
||||
existingPods: []*v1.Pod{},
|
||||
existingNodes: []*v1.Node{},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{},
|
||||
enableReadWriteOncePod: true,
|
||||
preFilterWantStatus: framework.NewStatus(framework.Skip),
|
||||
wantStatus: nil,
|
||||
name: "nothing",
|
||||
pod: &v1.Pod{},
|
||||
nodeInfo: framework.NewNodeInfo(),
|
||||
existingPods: []*v1.Pod{},
|
||||
existingNodes: []*v1.Node{},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{},
|
||||
preFilterWantStatus: framework.NewStatus(framework.Skip),
|
||||
wantStatus: nil,
|
||||
},
|
||||
{
|
||||
name: "nothing, ReadWriteOncePod disabled",
|
||||
pod: &v1.Pod{},
|
||||
nodeInfo: framework.NewNodeInfo(),
|
||||
existingPods: []*v1.Pod{},
|
||||
existingNodes: []*v1.Node{},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{},
|
||||
enableReadWriteOncePod: false,
|
||||
preFilterWantStatus: framework.NewStatus(framework.Skip),
|
||||
wantStatus: nil,
|
||||
name: "failed to get PVC",
|
||||
pod: podWithOnePVC,
|
||||
nodeInfo: framework.NewNodeInfo(),
|
||||
existingPods: []*v1.Pod{},
|
||||
existingNodes: []*v1.Node{},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{},
|
||||
preFilterWantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "persistentvolumeclaim \"claim-with-rwop-1\" not found"),
|
||||
wantStatus: nil,
|
||||
},
|
||||
{
|
||||
name: "failed to get PVC",
|
||||
pod: podWithOnePVC,
|
||||
nodeInfo: framework.NewNodeInfo(),
|
||||
existingPods: []*v1.Pod{},
|
||||
existingNodes: []*v1.Node{},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{},
|
||||
enableReadWriteOncePod: true,
|
||||
preFilterWantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "persistentvolumeclaim \"claim-with-rwop-1\" not found"),
|
||||
wantStatus: nil,
|
||||
name: "no access mode conflict",
|
||||
pod: podWithOnePVC,
|
||||
nodeInfo: framework.NewNodeInfo(podWithReadWriteManyPVC),
|
||||
existingPods: []*v1.Pod{podWithReadWriteManyPVC},
|
||||
existingNodes: []*v1.Node{node},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{readWriteOncePodPVC1, readWriteManyPVC},
|
||||
preFilterWantStatus: framework.NewStatus(framework.Skip),
|
||||
wantStatus: nil,
|
||||
},
|
||||
{
|
||||
name: "no access mode conflict",
|
||||
pod: podWithOnePVC,
|
||||
nodeInfo: framework.NewNodeInfo(podWithReadWriteManyPVC),
|
||||
existingPods: []*v1.Pod{podWithReadWriteManyPVC},
|
||||
existingNodes: []*v1.Node{node},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{readWriteOncePodPVC1, readWriteManyPVC},
|
||||
enableReadWriteOncePod: true,
|
||||
preFilterWantStatus: framework.NewStatus(framework.Skip),
|
||||
wantStatus: nil,
|
||||
name: "access mode conflict, unschedulable",
|
||||
pod: podWithOneConflict,
|
||||
nodeInfo: framework.NewNodeInfo(podWithOnePVC, podWithReadWriteManyPVC),
|
||||
existingPods: []*v1.Pod{podWithOnePVC, podWithReadWriteManyPVC},
|
||||
existingNodes: []*v1.Node{node},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{readWriteOncePodPVC1, readWriteManyPVC},
|
||||
preFilterWantStatus: nil,
|
||||
wantStatus: framework.NewStatus(framework.Unschedulable, ErrReasonReadWriteOncePodConflict),
|
||||
},
|
||||
{
|
||||
name: "access mode conflict, unschedulable",
|
||||
pod: podWithOneConflict,
|
||||
nodeInfo: framework.NewNodeInfo(podWithOnePVC, podWithReadWriteManyPVC),
|
||||
existingPods: []*v1.Pod{podWithOnePVC, podWithReadWriteManyPVC},
|
||||
existingNodes: []*v1.Node{node},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{readWriteOncePodPVC1, readWriteManyPVC},
|
||||
enableReadWriteOncePod: true,
|
||||
preFilterWantStatus: nil,
|
||||
wantStatus: framework.NewStatus(framework.Unschedulable, ErrReasonReadWriteOncePodConflict),
|
||||
},
|
||||
{
|
||||
name: "two conflicts, unschedulable",
|
||||
pod: podWithTwoConflicts,
|
||||
nodeInfo: framework.NewNodeInfo(podWithTwoPVCs, podWithReadWriteManyPVC),
|
||||
existingPods: []*v1.Pod{podWithTwoPVCs, podWithReadWriteManyPVC},
|
||||
existingNodes: []*v1.Node{node},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{readWriteOncePodPVC1, readWriteOncePodPVC2, readWriteManyPVC},
|
||||
enableReadWriteOncePod: true,
|
||||
preFilterWantStatus: nil,
|
||||
wantStatus: framework.NewStatus(framework.Unschedulable, ErrReasonReadWriteOncePodConflict),
|
||||
name: "two conflicts, unschedulable",
|
||||
pod: podWithTwoConflicts,
|
||||
nodeInfo: framework.NewNodeInfo(podWithTwoPVCs, podWithReadWriteManyPVC),
|
||||
existingPods: []*v1.Pod{podWithTwoPVCs, podWithReadWriteManyPVC},
|
||||
existingNodes: []*v1.Node{node},
|
||||
existingPVCs: []*v1.PersistentVolumeClaim{readWriteOncePodPVC1, readWriteOncePodPVC2, readWriteManyPVC},
|
||||
preFilterWantStatus: nil,
|
||||
wantStatus: framework.NewStatus(framework.Unschedulable, ErrReasonReadWriteOncePodConflict),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -483,7 +461,7 @@ func TestAccessModeConflicts(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
p := newPluginWithListers(ctx, t, test.existingPods, test.existingNodes, test.existingPVCs, test.enableReadWriteOncePod)
|
||||
p := newPluginWithListers(ctx, t, test.existingPods, test.existingNodes, test.existingPVCs)
|
||||
cycleState := framework.NewCycleState()
|
||||
_, preFilterGotStatus := p.(framework.PreFilterPlugin).PreFilter(ctx, cycleState, test.pod)
|
||||
if diff := cmp.Diff(test.preFilterWantStatus, preFilterGotStatus); diff != "" {
|
||||
@@ -501,14 +479,12 @@ func TestAccessModeConflicts(t *testing.T) {
|
||||
}
|
||||
|
||||
func newPlugin(ctx context.Context, t *testing.T) framework.Plugin {
|
||||
return newPluginWithListers(ctx, t, nil, nil, nil, true)
|
||||
return newPluginWithListers(ctx, t, nil, nil, nil)
|
||||
}
|
||||
|
||||
func newPluginWithListers(ctx context.Context, t *testing.T, pods []*v1.Pod, nodes []*v1.Node, pvcs []*v1.PersistentVolumeClaim, enableReadWriteOncePod bool) framework.Plugin {
|
||||
func newPluginWithListers(ctx context.Context, t *testing.T, pods []*v1.Pod, nodes []*v1.Node, pvcs []*v1.PersistentVolumeClaim) framework.Plugin {
|
||||
pluginFactory := func(ctx context.Context, plArgs runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
return New(ctx, plArgs, fh, feature.Features{
|
||||
EnableReadWriteOncePod: enableReadWriteOncePod,
|
||||
})
|
||||
return New(ctx, plArgs, fh, feature.Features{})
|
||||
}
|
||||
snapshot := cache.NewSnapshot(pods, nodes)
|
||||
|
||||
|
Reference in New Issue
Block a user