...

Source file src/k8s.io/kubernetes/pkg/kubelet/cm/topologymanager/policy_best_effort.go

Documentation: k8s.io/kubernetes/pkg/kubelet/cm/topologymanager

     1  /*
     2  Copyright 2019 The Kubernetes 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 topologymanager
    18  
    19  type bestEffortPolicy struct {
    20  	// numaInfo represents list of NUMA Nodes available on the underlying machine and distances between them
    21  	numaInfo *NUMAInfo
    22  	opts     PolicyOptions
    23  }
    24  
    25  var _ Policy = &bestEffortPolicy{}
    26  
    27  // PolicyBestEffort policy name.
    28  const PolicyBestEffort string = "best-effort"
    29  
    30  // NewBestEffortPolicy returns best-effort policy.
    31  func NewBestEffortPolicy(numaInfo *NUMAInfo, opts PolicyOptions) Policy {
    32  	return &bestEffortPolicy{numaInfo: numaInfo, opts: opts}
    33  }
    34  
    35  func (p *bestEffortPolicy) Name() string {
    36  	return PolicyBestEffort
    37  }
    38  
    39  func (p *bestEffortPolicy) canAdmitPodResult(hint *TopologyHint) bool {
    40  	return true
    41  }
    42  
    43  func (p *bestEffortPolicy) Merge(providersHints []map[string][]TopologyHint) (TopologyHint, bool) {
    44  	filteredHints := filterProvidersHints(providersHints)
    45  	merger := NewHintMerger(p.numaInfo, filteredHints, p.Name(), p.opts)
    46  	bestHint := merger.Merge()
    47  	admit := p.canAdmitPodResult(&bestHint)
    48  	return bestHint, admit
    49  }
    50  

View as plain text