manager_stub.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 devicemanager
  14. import (
  15. v1 "k8s.io/api/core/v1"
  16. podresourcesapi "k8s.io/kubernetes/pkg/kubelet/apis/podresources/v1alpha1"
  17. "k8s.io/kubernetes/pkg/kubelet/cm/topologymanager"
  18. "k8s.io/kubernetes/pkg/kubelet/config"
  19. "k8s.io/kubernetes/pkg/kubelet/lifecycle"
  20. "k8s.io/kubernetes/pkg/kubelet/pluginmanager/cache"
  21. schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
  22. )
  23. // ManagerStub provides a simple stub implementation for the Device Manager.
  24. type ManagerStub struct{}
  25. // NewManagerStub creates a ManagerStub.
  26. func NewManagerStub() (*ManagerStub, error) {
  27. return &ManagerStub{}, nil
  28. }
  29. // Start simply returns nil.
  30. func (h *ManagerStub) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error {
  31. return nil
  32. }
  33. // Stop simply returns nil.
  34. func (h *ManagerStub) Stop() error {
  35. return nil
  36. }
  37. // Allocate simply returns nil.
  38. func (h *ManagerStub) Allocate(node *schedulernodeinfo.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error {
  39. return nil
  40. }
  41. // GetDeviceRunContainerOptions simply returns nil.
  42. func (h *ManagerStub) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) (*DeviceRunContainerOptions, error) {
  43. return nil, nil
  44. }
  45. // GetCapacity simply returns nil capacity and empty removed resource list.
  46. func (h *ManagerStub) GetCapacity() (v1.ResourceList, v1.ResourceList, []string) {
  47. return nil, nil, []string{}
  48. }
  49. // GetWatcherHandler returns plugin watcher interface
  50. func (h *ManagerStub) GetWatcherHandler() cache.PluginHandler {
  51. return nil
  52. }
  53. // GetTopologyHints returns an empty TopologyHint map
  54. func (h *ManagerStub) GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint {
  55. return map[string][]topologymanager.TopologyHint{}
  56. }
  57. // GetDevices returns nil
  58. func (h *ManagerStub) GetDevices(_, _ string) []*podresourcesapi.ContainerDevices {
  59. return nil
  60. }
  61. // ShouldResetExtendedResourceCapacity returns false
  62. func (h *ManagerStub) ShouldResetExtendedResourceCapacity() bool {
  63. return false
  64. }
  65. // UpdateAllocatedDevices returns nothing
  66. func (h *ManagerStub) UpdateAllocatedDevices() {
  67. return
  68. }