Skip to content

Commit

Permalink
Merge pull request #207 from duanmengkk/fix_pvc_create_error
Browse files Browse the repository at this point in the history
cherry-pick manually[fix pvc create error]
  • Loading branch information
kosmos-robot authored Nov 8, 2023
2 parents 007f1e6 + fc6ab77 commit 0022ed1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
5 changes: 2 additions & 3 deletions deploy/scheduler/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ spec:
image: ghcr.io/kosmos-io/scheduler:0.0.2
command:
- scheduler
- --leader-elect=true
- --leader-elect-resource-name=kosmos-scheduler
- --leader-elect-resource-namespace=kosmos-system
- --config=/etc/kubernetes/kube-scheduler/scheduler-config.yaml
resources:
requests:
Expand Down Expand Up @@ -67,6 +64,8 @@ data:
kind: KubeSchedulerConfiguration
leaderElection:
leaderElect: true
resourceName: kosmos-scheduler
resourceNamespace: kosmos-system
profiles:
- schedulerName: kosmos-scheduler
plugins:
Expand Down
2 changes: 0 additions & 2 deletions deploy/scheduler/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ rules:
- ''
resources:
- endpoints
resourceNames:
- kube-scheduler
- verbs:
- get
- list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (d *stateData) Clone() framework.StateData {
type VolumeBinding struct {
Binder scheduling.SchedulerVolumeBinder
PVCLister corelisters.PersistentVolumeClaimLister
NodeLister corelisters.NodeLister
frameworkHandler framework.Handle
}

Expand Down Expand Up @@ -232,6 +233,15 @@ func (pl *VolumeBinding) Filter(_ context.Context, cs *framework.CycleState, pod

// Reserve reserves volumes of pod and saves binding status in cycle state.
func (pl *VolumeBinding) Reserve(_ context.Context, cs *framework.CycleState, pod *corev1.Pod, nodeName string) *framework.Status {
node, err := pl.NodeLister.Get(nodeName)
if err == nil {
return framework.NewStatus(framework.Error, "node not found")
}

if helpers.HasKnodeTaint(node) {
return nil
}

state, err := getStateData(cs)
if err != nil {
return framework.AsStatus(err)
Expand All @@ -257,6 +267,15 @@ func (pl *VolumeBinding) Reserve(_ context.Context, cs *framework.CycleState, po
// If binding errors, times out or gets undone, then an error will be returned to
// retry scheduling.
func (pl *VolumeBinding) PreBind(ctx context.Context, cs *framework.CycleState, pod *corev1.Pod, nodeName string) *framework.Status {
node, err := pl.NodeLister.Get(nodeName)
if err == nil {
return framework.NewStatus(framework.Error, "node not found")
}

if helpers.HasKnodeTaint(node) {
return nil
}

s, err := getStateData(cs)
if err != nil {
return framework.AsStatus(err)
Expand All @@ -283,6 +302,15 @@ func (pl *VolumeBinding) PreBind(ctx context.Context, cs *framework.CycleState,
// Unreserve clears assumed PV and PVC cache.
// It's idempotent, and does nothing if no cache found for the given pod.
func (pl *VolumeBinding) Unreserve(_ context.Context, cs *framework.CycleState, _ *corev1.Pod, nodeName string) {
node, err := pl.NodeLister.Get(nodeName)
if err != nil {
return
}

if helpers.HasKnodeTaint(node) {
return
}

s, err := getStateData(cs)
if err != nil {
return
Expand Down Expand Up @@ -317,6 +345,7 @@ func New(plArgs runtime.Object, fh framework.Handle) (framework.Plugin, error) {
return &VolumeBinding{
Binder: binder,
PVCLister: pvcInformer.Lister(),
NodeLister: nodeInformer.Lister(),
frameworkHandler: fh,
}, nil
}

0 comments on commit 0022ed1

Please sign in to comment.