volumezone: scheduler queueing hints: pv (#125001)
* volumezone: scheduler queueing hints * add_comment
This commit is contained in:
@@ -675,6 +675,105 @@ func TestIsSchedulableAfterStorageClassAdded(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsSchedulableAfterPersistentVolumeChange(t *testing.T) {
|
||||
testcases := map[string]struct {
|
||||
pod *v1.Pod
|
||||
oldObj, newObj interface{}
|
||||
expectedHint framework.QueueingHint
|
||||
expectedErr bool
|
||||
}{
|
||||
"error-wrong-new-object": {
|
||||
pod: createPodWithVolume("pod_1", "PVC_1"),
|
||||
newObj: "not-a-pv",
|
||||
expectedHint: framework.Queue,
|
||||
expectedErr: true,
|
||||
},
|
||||
"error-wrong-old-object": {
|
||||
pod: createPodWithVolume("pod_1", "PVC_1"),
|
||||
oldObj: "not-a-pv",
|
||||
newObj: st.MakePersistentVolume().Name("Vol_1").Obj(),
|
||||
expectedHint: framework.Queue,
|
||||
expectedErr: true,
|
||||
},
|
||||
"new-pv-was-added": {
|
||||
pod: createPodWithVolume("pod_1", "PVC_1"),
|
||||
newObj: &v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "Vol_1",
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-b"},
|
||||
},
|
||||
},
|
||||
expectedHint: framework.Queue,
|
||||
},
|
||||
"pv-was-updated-and-changed-topology": {
|
||||
pod: createPodWithVolume("pod_1", "PVC_1"),
|
||||
oldObj: &v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "Vol_1",
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-a"},
|
||||
},
|
||||
},
|
||||
newObj: &v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "Vol_1",
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-b"},
|
||||
},
|
||||
},
|
||||
expectedHint: framework.Queue,
|
||||
},
|
||||
"pv-was-updated-and-added-topology-label": {
|
||||
pod: createPodWithVolume("pod_1", "PVC_1"),
|
||||
oldObj: &v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "Vol_1",
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-a"},
|
||||
},
|
||||
},
|
||||
newObj: &v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "Vol_1",
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-a",
|
||||
v1.LabelTopologyZone: "zone"},
|
||||
},
|
||||
},
|
||||
expectedHint: framework.Queue,
|
||||
},
|
||||
"pv-was-updated-but-no-topology-is-changed": {
|
||||
pod: createPodWithVolume("pod_1", "PVC_1"),
|
||||
oldObj: &v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "Vol_1",
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-a",
|
||||
v1.LabelTopologyZone: "zone"},
|
||||
},
|
||||
},
|
||||
newObj: &v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "Vol_1",
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-a",
|
||||
v1.LabelTopologyZone: "zone"},
|
||||
},
|
||||
},
|
||||
expectedHint: framework.QueueSkip,
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testcases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
logger, _ := ktesting.NewTestContext(t)
|
||||
p := &VolumeZone{}
|
||||
|
||||
got, err := p.isSchedulableAfterPersistentVolumeChange(logger, tc.pod, tc.oldObj, tc.newObj)
|
||||
if err != nil && !tc.expectedErr {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if got != tc.expectedHint {
|
||||
t.Errorf("isSchedulableAfterPersistentVolumeChange() = %v, want %v", got, tc.expectedHint)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkVolumeZone(b *testing.B) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
|
||||
Reference in New Issue
Block a user