github.com/kubewharf/katalyst-core@v0.5.3/pkg/scheduler/plugins/nodeovercommitment/plugin.go (about)

     1  /*
     2  Copyright 2022 The Katalyst Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package nodeovercommitment
    18  
    19  import (
    20  	"k8s.io/apimachinery/pkg/runtime"
    21  	"k8s.io/klog/v2"
    22  	"k8s.io/kubernetes/pkg/scheduler/framework"
    23  
    24  	"github.com/kubewharf/katalyst-core/pkg/scheduler/plugins/nodeovercommitment/cache"
    25  )
    26  
    27  var _ framework.FilterPlugin = &NodeOvercommitment{}
    28  
    29  const (
    30  	// Name is the name of the plugin used in the plugin registry and configurations.
    31  	Name = "NodeOvercommitment"
    32  
    33  	preFilterStateKey = "PreFilter" + Name
    34  )
    35  
    36  var (
    37  	_ framework.PreFilterPlugin = &NodeOvercommitment{}
    38  	_ framework.FilterPlugin    = &NodeOvercommitment{}
    39  	_ framework.ReservePlugin   = &NodeOvercommitment{}
    40  )
    41  
    42  type NodeOvercommitment struct{}
    43  
    44  func (n *NodeOvercommitment) Name() string {
    45  	return Name
    46  }
    47  
    48  func New(args runtime.Object, h framework.Handle) (framework.Plugin, error) {
    49  	klog.Info("Creating new NodeOvercommitment plugin")
    50  
    51  	cache.RegisterPodHandler()
    52  	cache.RegisterCNRHandler()
    53  	return &NodeOvercommitment{}, nil
    54  }