github.com/kubewharf/katalyst-core@v0.5.3/pkg/agent/evictionmanager/plugin/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 plugin is the package that defines the eviction strategy, and
    18  // those strategies must implement EvictPlugin interface, supporting both
    19  // embedded plugin and external registered plugin.
    20  package plugin // import "github.com/kubewharf/katalyst-core/pkg/evictionmanager/plugin"
    21  
    22  import (
    23  	"context"
    24  
    25  	"k8s.io/client-go/tools/events"
    26  
    27  	pluginapi "github.com/kubewharf/katalyst-api/pkg/protocol/evictionplugin/v1alpha1"
    28  	endpointpkg "github.com/kubewharf/katalyst-core/pkg/agent/evictionmanager/endpoint"
    29  	"github.com/kubewharf/katalyst-core/pkg/client"
    30  	"github.com/kubewharf/katalyst-core/pkg/config"
    31  	"github.com/kubewharf/katalyst-core/pkg/metaserver"
    32  	"github.com/kubewharf/katalyst-core/pkg/metrics"
    33  	util "github.com/kubewharf/katalyst-core/pkg/util/process"
    34  )
    35  
    36  const (
    37  	fakePluginName = "fake-eviction-plugin"
    38  )
    39  
    40  // InitFunc is used to initialize a particular innter eviction plugin.
    41  type InitFunc func(genericClient *client.GenericClientSet, recorder events.EventRecorder, metaServer *metaserver.MetaServer,
    42  	emitter metrics.MetricEmitter, conf *config.Configuration) EvictionPlugin
    43  
    44  // EvictionPlugin performs eviction actions based on agent resources.
    45  type EvictionPlugin interface {
    46  	Name() string
    47  	endpointpkg.Endpoint
    48  }
    49  
    50  type DummyEvictionPlugin struct {
    51  	*util.StopControl
    52  }
    53  
    54  func (_ DummyEvictionPlugin) Name() string { return fakePluginName }
    55  func (_ DummyEvictionPlugin) ThresholdMet(_ context.Context) (*pluginapi.ThresholdMetResponse, error) {
    56  	return nil, nil
    57  }
    58  
    59  func (_ DummyEvictionPlugin) GetTopEvictionPods(_ context.Context, _ *pluginapi.GetTopEvictionPodsRequest) (*pluginapi.GetTopEvictionPodsResponse, error) {
    60  	return nil, nil
    61  }
    62  
    63  func (_ DummyEvictionPlugin) GetEvictPods(_ context.Context, _ *pluginapi.GetEvictPodsRequest) (*pluginapi.GetEvictPodsResponse, error) {
    64  	return nil, nil
    65  }
    66  
    67  func (_ DummyEvictionPlugin) Start() {
    68  	return
    69  }
    70  
    71  var _ EvictionPlugin = DummyEvictionPlugin{}