fake_cpu_manager.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Copyright 2017 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 cpumanager
  14. import (
  15. "k8s.io/api/core/v1"
  16. "k8s.io/klog"
  17. "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state"
  18. "k8s.io/kubernetes/pkg/kubelet/status"
  19. )
  20. type fakeManager struct {
  21. state state.State
  22. }
  23. func (m *fakeManager) Start(activePods ActivePodsFunc, podStatusProvider status.PodStatusProvider, containerRuntime runtimeService) {
  24. klog.Info("[fake cpumanager] Start()")
  25. }
  26. func (m *fakeManager) Policy() Policy {
  27. klog.Info("[fake cpumanager] Policy()")
  28. return NewNonePolicy()
  29. }
  30. func (m *fakeManager) AddContainer(pod *v1.Pod, container *v1.Container, containerID string) error {
  31. klog.Infof("[fake cpumanager] AddContainer (pod: %s, container: %s, container id: %s)", pod.Name, container.Name, containerID)
  32. return nil
  33. }
  34. func (m *fakeManager) RemoveContainer(containerID string) error {
  35. klog.Infof("[fake cpumanager] RemoveContainer (container id: %s)", containerID)
  36. return nil
  37. }
  38. func (m *fakeManager) State() state.Reader {
  39. return m.state
  40. }
  41. // NewFakeManager creates empty/fake cpu manager
  42. func NewFakeManager() Manager {
  43. return &fakeManager{
  44. state: state.NewMemoryState(),
  45. }
  46. }