fake_topology_manager.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. import (
  15. "k8s.io/api/core/v1"
  16. "k8s.io/klog"
  17. "k8s.io/kubernetes/pkg/kubelet/lifecycle"
  18. )
  19. type fakeManager struct{}
  20. //NewFakeManager returns an instance of FakeManager
  21. func NewFakeManager() Manager {
  22. klog.Infof("[fake topologymanager] NewFakeManager")
  23. return &fakeManager{}
  24. }
  25. func (m *fakeManager) GetAffinity(podUID string, containerName string) TopologyHint {
  26. klog.Infof("[fake topologymanager] GetAffinity podUID: %v container name: %v", podUID, containerName)
  27. return TopologyHint{}
  28. }
  29. func (m *fakeManager) AddHintProvider(h HintProvider) {
  30. klog.Infof("[fake topologymanager] AddHintProvider HintProvider: %v", h)
  31. }
  32. func (m *fakeManager) AddContainer(pod *v1.Pod, containerID string) error {
  33. klog.Infof("[fake topologymanager] AddContainer pod: %v container id: %v", pod, containerID)
  34. return nil
  35. }
  36. func (m *fakeManager) RemoveContainer(containerID string) error {
  37. klog.Infof("[fake topologymanager] RemoveContainer container id: %v", containerID)
  38. return nil
  39. }
  40. func (m *fakeManager) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAdmitResult {
  41. klog.Infof("[fake topologymanager] Topology Admit Handler")
  42. return lifecycle.PodAdmitResult{
  43. Admit: true,
  44. }
  45. }