Skip to content

Commit

Permalink
The volume binding function is applicable to K8S v1.23 and earlier ve…
Browse files Browse the repository at this point in the history
…rsions.

Signed-off-by: wangyang <wangyang289@huawei.com>
  • Loading branch information
wangyang0616 committed Oct 18, 2022
1 parent 82ad229 commit cf1dd30
Show file tree
Hide file tree
Showing 22 changed files with 7,542 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/scheduler/api/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog"
volumescheduling "k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumebinding"
volumescheduling "volcano.sh/volcano/pkg/scheduler/plugins/volumebinding"

batch "volcano.sh/apis/pkg/apis/batch/v1alpha1"
"volcano.sh/apis/pkg/apis/scheduling"
Expand Down
19 changes: 13 additions & 6 deletions pkg/scheduler/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
infov1 "k8s.io/client-go/informers/core/v1"
schedv1 "k8s.io/client-go/informers/scheduling/v1"
storagev1 "k8s.io/client-go/informers/storage/v1"
storagev1beta1 "k8s.io/client-go/informers/storage/v1beta1"
"k8s.io/client-go/kubernetes"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/rest"
Expand All @@ -49,7 +50,7 @@ import (
"k8s.io/client-go/util/workqueue"
"k8s.io/klog"
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
volumescheduling "k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumebinding"
volumescheduling "volcano.sh/volcano/pkg/scheduler/plugins/volumebinding"

batch "volcano.sh/apis/pkg/apis/batch/v1alpha1"
"volcano.sh/apis/pkg/apis/scheduling"
Expand Down Expand Up @@ -112,7 +113,7 @@ type SchedulerCache struct {
quotaInformer infov1.ResourceQuotaInformer
csiNodeInformer storagev1.CSINodeInformer
csiDriverInformer storagev1.CSIDriverInformer
csiStorageCapacityInformer storagev1.CSIStorageCapacityInformer
csiStorageCapacityInformer storagev1beta1.CSIStorageCapacityInformer
cpuInformer cpuinformerv1.NumatopologyInformer

Binder Binder
Expand Down Expand Up @@ -535,10 +536,16 @@ func newSchedulerCache(config *rest.Config, schedulerNames []string, defaultQueu
},
)
sc.csiDriverInformer = informerFactory.Storage().V1().CSIDrivers()
sc.csiStorageCapacityInformer = informerFactory.Storage().V1().CSIStorageCapacities()
capacityCheck := volumescheduling.CapacityCheck{
CSIDriverInformer: sc.csiDriverInformer,
CSIStorageCapacityInformer: sc.csiStorageCapacityInformer,
sc.csiStorageCapacityInformer = informerFactory.Storage().V1beta1().CSIStorageCapacities()

var capacityCheck *volumescheduling.CapacityCheck
if options.ServerOpts.EnableCSIStorage {
capacityCheck = &volumescheduling.CapacityCheck{
CSIDriverInformer: sc.csiDriverInformer,
CSIStorageCapacityInformer: sc.csiStorageCapacityInformer,
}
} else {
capacityCheck = nil
}

sc.VolumeBinder = &defaultVolumeBinder{
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/cache/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
scheduling "k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumebinding"
scheduling "volcano.sh/volcano/pkg/scheduler/plugins/volumebinding"

"volcano.sh/volcano/pkg/scheduler/api"
)
Expand Down Expand Up @@ -94,7 +94,7 @@ type VolumeBinder interface {
BindVolumes(task *api.TaskInfo, podVolumes *scheduling.PodVolumes) error
}

//Binder interface for binding task and hostname
// Binder interface for binding task and hostname
type Binder interface {
Bind(kubeClient *kubernetes.Clientset, tasks []*api.TaskInfo) ([]*api.TaskInfo, error)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/plugins/util/k8s/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/apis/config"
"k8s.io/kubernetes/pkg/scheduler/framework"
"k8s.io/kubernetes/pkg/scheduler/framework/parallelize"
scheduling "k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumebinding"
scheduling "volcano.sh/volcano/pkg/scheduler/plugins/volumebinding"
)

// Framework is a K8S framework who mainly provides some methods
Expand Down
Loading

0 comments on commit cf1dd30

Please sign in to comment.