Skip to content

Commit

Permalink
Merge pull request kosmos-io#206 from duanmengkk/release-1.21
Browse files Browse the repository at this point in the history
fix: fix pvc updated error
  • Loading branch information
kosmos-robot authored Nov 7, 2023
2 parents e7be0b3 + a8b4a74 commit 4191749
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
type VolumeBinding struct {
Binder scheduling.SchedulerVolumeBinder
PVCLister corelisters.PersistentVolumeClaimLister
NodeLister corelisters.NodeLister
frameworkHandler framework.Handle
}

Expand Down Expand Up @@ -90,6 +91,15 @@ func (pl *VolumeBinding) PreFilterExtensions() framework.PreFilterExtensions {
// 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 @@ -115,6 +125,15 @@ func (pl *VolumeBinding) PreBind(ctx context.Context, cs *framework.CycleState,

// Reserve reserves volumes of pod and saves binding status in cycle state.
func (pl *VolumeBinding) Reserve(_ context.Context, cs *framework.CycleState, p *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 @@ -137,6 +156,15 @@ func (pl *VolumeBinding) Reserve(_ context.Context, cs *framework.CycleState, p
// 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 @@ -227,6 +255,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
}
Expand Down

0 comments on commit 4191749

Please sign in to comment.