mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
node: devicemgr: Remove devicePluginEnabled
field from container mgr
With graduation of device plugins to GA in 1.26, the feature gate is enabled by default so `devicePluginEnabled` field no longer needs to be passed at the time of Container Manager creation. In addition to that, we remove the `ManagerStub` as it is no longer needed. Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
This commit is contained in:
parent
752fa093e0
commit
8b29eded52
@ -704,8 +704,6 @@ func run(ctx context.Context, s *options.KubeletServer, kubeDeps *kubelet.Depend
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
devicePluginEnabled := utilfeature.DefaultFeatureGate.Enabled(features.DevicePlugins)
|
|
||||||
|
|
||||||
var cpuManagerPolicyOptions map[string]string
|
var cpuManagerPolicyOptions map[string]string
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.CPUManager) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.CPUManager) {
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.CPUManagerPolicyOptions) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.CPUManagerPolicyOptions) {
|
||||||
@ -751,7 +749,6 @@ func run(ctx context.Context, s *options.KubeletServer, kubeDeps *kubelet.Depend
|
|||||||
ExperimentalTopologyManagerScope: s.TopologyManagerScope,
|
ExperimentalTopologyManagerScope: s.TopologyManagerScope,
|
||||||
},
|
},
|
||||||
s.FailSwapOn,
|
s.FailSwapOn,
|
||||||
devicePluginEnabled,
|
|
||||||
kubeDeps.Recorder)
|
kubeDeps.Recorder)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -194,7 +194,7 @@ func validateSystemRequirements(mountUtil mount.Interface) (features, error) {
|
|||||||
// TODO(vmarmol): Add limits to the system containers.
|
// TODO(vmarmol): Add limits to the system containers.
|
||||||
// Takes the absolute name of the specified containers.
|
// Takes the absolute name of the specified containers.
|
||||||
// Empty container name disables use of the specified container.
|
// Empty container name disables use of the specified container.
|
||||||
func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.Interface, nodeConfig NodeConfig, failSwapOn bool, devicePluginEnabled bool, recorder record.EventRecorder) (ContainerManager, error) {
|
func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.Interface, nodeConfig NodeConfig, failSwapOn bool, recorder record.EventRecorder) (ContainerManager, error) {
|
||||||
subsystems, err := GetCgroupSubsystems()
|
subsystems, err := GetCgroupSubsystems()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get mounted cgroup subsystems: %v", err)
|
return nil, fmt.Errorf("failed to get mounted cgroup subsystems: %v", err)
|
||||||
@ -298,16 +298,12 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
|
|||||||
cm.topologyManager = topologymanager.NewFakeManager()
|
cm.topologyManager = topologymanager.NewFakeManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.InfoS("Creating device plugin manager", "devicePluginEnabled", devicePluginEnabled)
|
klog.InfoS("Creating device plugin manager")
|
||||||
if devicePluginEnabled {
|
cm.deviceManager, err = devicemanager.NewManagerImpl(machineInfo.Topology, cm.topologyManager)
|
||||||
cm.deviceManager, err = devicemanager.NewManagerImpl(machineInfo.Topology, cm.topologyManager)
|
|
||||||
cm.topologyManager.AddHintProvider(cm.deviceManager)
|
|
||||||
} else {
|
|
||||||
cm.deviceManager, err = devicemanager.NewManagerStub()
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
cm.topologyManager.AddHintProvider(cm.deviceManager)
|
||||||
|
|
||||||
// Initialize CPU manager
|
// Initialize CPU manager
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.CPUManager) {
|
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.CPUManager) {
|
||||||
|
@ -42,6 +42,6 @@ func (unsupportedContainerManager) Start(_ *v1.Node, _ ActivePodsFunc, _ config.
|
|||||||
return fmt.Errorf("Container Manager is unsupported in this build")
|
return fmt.Errorf("Container Manager is unsupported in this build")
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContainerManager(_ mount.Interface, _ cadvisor.Interface, _ NodeConfig, failSwapOn bool, devicePluginEnabled bool, recorder record.EventRecorder) (ContainerManager, error) {
|
func NewContainerManager(_ mount.Interface, _ cadvisor.Interface, _ NodeConfig, failSwapOn bool, recorder record.EventRecorder) (ContainerManager, error) {
|
||||||
return &unsupportedContainerManager{}, nil
|
return &unsupportedContainerManager{}, nil
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func (cm *containerManagerImpl) Start(node *v1.Node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewContainerManager creates windows container manager.
|
// NewContainerManager creates windows container manager.
|
||||||
func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.Interface, nodeConfig NodeConfig, failSwapOn bool, devicePluginEnabled bool, recorder record.EventRecorder) (ContainerManager, error) {
|
func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.Interface, nodeConfig NodeConfig, failSwapOn bool, recorder record.EventRecorder) (ContainerManager, error) {
|
||||||
// It is safe to invoke `MachineInfo` on cAdvisor before logically initializing cAdvisor here because
|
// It is safe to invoke `MachineInfo` on cAdvisor before logically initializing cAdvisor here because
|
||||||
// machine info is computed and cached once as part of cAdvisor object creation.
|
// machine info is computed and cached once as part of cAdvisor object creation.
|
||||||
// But `RootFsInfo` and `ImagesFsInfo` are not available at this moment so they will be called later during manager starts
|
// But `RootFsInfo` and `ImagesFsInfo` are not available at this moment so they will be called later during manager starts
|
||||||
@ -111,16 +111,12 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
|
|||||||
|
|
||||||
cm.topologyManager = topologymanager.NewFakeManager()
|
cm.topologyManager = topologymanager.NewFakeManager()
|
||||||
|
|
||||||
klog.InfoS("Creating device plugin manager", "devicePluginEnabled", devicePluginEnabled)
|
klog.InfoS("Creating device plugin manager")
|
||||||
if devicePluginEnabled {
|
cm.deviceManager, err = devicemanager.NewManagerImpl(nil, cm.topologyManager)
|
||||||
cm.deviceManager, err = devicemanager.NewManagerImpl(nil, cm.topologyManager)
|
|
||||||
cm.topologyManager.AddHintProvider(cm.deviceManager)
|
|
||||||
} else {
|
|
||||||
cm.deviceManager, err = devicemanager.NewManagerStub()
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
cm.topologyManager.AddHintProvider(cm.deviceManager)
|
||||||
|
|
||||||
return cm, nil
|
return cm, nil
|
||||||
}
|
}
|
||||||
|
@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package devicemanager
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager"
|
|
||||||
"k8s.io/kubernetes/pkg/kubelet/config"
|
|
||||||
"k8s.io/kubernetes/pkg/kubelet/lifecycle"
|
|
||||||
"k8s.io/kubernetes/pkg/kubelet/pluginmanager/cache"
|
|
||||||
schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ManagerStub provides a simple stub implementation for the Device Manager.
|
|
||||||
type ManagerStub struct{}
|
|
||||||
|
|
||||||
// NewManagerStub creates a ManagerStub.
|
|
||||||
func NewManagerStub() (*ManagerStub, error) {
|
|
||||||
return &ManagerStub{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start simply returns nil.
|
|
||||||
func (h *ManagerStub) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop simply returns nil.
|
|
||||||
func (h *ManagerStub) Stop() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate simply returns nil.
|
|
||||||
func (h *ManagerStub) Allocate(pod *v1.Pod, container *v1.Container) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdatePluginResources simply returns nil.
|
|
||||||
func (h *ManagerStub) UpdatePluginResources(node *schedulerframework.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetDeviceRunContainerOptions simply returns nil.
|
|
||||||
func (h *ManagerStub) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) (*DeviceRunContainerOptions, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCapacity simply returns nil capacity and empty removed resource list.
|
|
||||||
func (h *ManagerStub) GetCapacity() (v1.ResourceList, v1.ResourceList, []string) {
|
|
||||||
return nil, nil, []string{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetWatcherHandler returns plugin watcher interface
|
|
||||||
func (h *ManagerStub) GetWatcherHandler() cache.PluginHandler {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTopologyHints returns an empty TopologyHint map
|
|
||||||
func (h *ManagerStub) GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint {
|
|
||||||
return map[string][]topologymanager.TopologyHint{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPodTopologyHints returns an empty TopologyHint map
|
|
||||||
func (h *ManagerStub) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint {
|
|
||||||
return map[string][]topologymanager.TopologyHint{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetDevices returns nil
|
|
||||||
func (h *ManagerStub) GetDevices(_, _ string) ResourceDeviceInstances {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAllocatableDevices returns nothing
|
|
||||||
func (h *ManagerStub) GetAllocatableDevices() ResourceDeviceInstances {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ShouldResetExtendedResourceCapacity returns false
|
|
||||||
func (h *ManagerStub) ShouldResetExtendedResourceCapacity() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateAllocatedDevices returns nothing
|
|
||||||
func (h *ManagerStub) UpdateAllocatedDevices() {
|
|
||||||
return
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user