policy_best_effort.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. Copyright 2019 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package topologymanager
  14. type bestEffortPolicy struct {
  15. //List of NUMA Nodes available on the underlying machine
  16. numaNodes []int
  17. }
  18. var _ Policy = &bestEffortPolicy{}
  19. // PolicyBestEffort policy name.
  20. const PolicyBestEffort string = "best-effort"
  21. // NewBestEffortPolicy returns best-effort policy.
  22. func NewBestEffortPolicy(numaNodes []int) Policy {
  23. return &bestEffortPolicy{numaNodes: numaNodes}
  24. }
  25. func (p *bestEffortPolicy) Name() string {
  26. return PolicyBestEffort
  27. }
  28. func (p *bestEffortPolicy) canAdmitPodResult(hint *TopologyHint) bool {
  29. return true
  30. }
  31. func (p *bestEffortPolicy) Merge(providersHints []map[string][]TopologyHint) (TopologyHint, bool) {
  32. filteredProvidersHints := filterProvidersHints(providersHints)
  33. bestHint := mergeFilteredHints(p.numaNodes, filteredProvidersHints)
  34. admit := p.canAdmitPodResult(&bestHint)
  35. return bestHint, admit
  36. }