-
Notifications
You must be signed in to change notification settings - Fork 40.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates to container manager and internal container lifecycle to accommodate TopologyManager #74357
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ import ( | |
"k8s.io/kubernetes/pkg/kubelet/cadvisor" | ||
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager" | ||
"k8s.io/kubernetes/pkg/kubelet/cm/devicemanager" | ||
"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager" | ||
cmutil "k8s.io/kubernetes/pkg/kubelet/cm/util" | ||
"k8s.io/kubernetes/pkg/kubelet/config" | ||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" | ||
|
@@ -139,6 +140,8 @@ type containerManagerImpl struct { | |
deviceManager devicemanager.Manager | ||
// Interface for CPU affinity management. | ||
cpuManager cpumanager.Manager | ||
// Interface for Topology resource co-ordination | ||
topologyManager topologymanager.Manager | ||
} | ||
|
||
type features struct { | ||
|
@@ -284,6 +287,20 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I | |
qosContainerManager: qosContainerManager, | ||
} | ||
|
||
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.TopologyManager) { | ||
cm.topologyManager, err = topologymanager.NewManager( | ||
nodeConfig.ExperimentalTopologyManagerPolicy, | ||
) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
klog.Infof("[topologymanager] Initilizing Topology Manager with %s policy", nodeConfig.ExperimentalTopologyManagerPolicy) | ||
lmdaly marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "Initializing" |
||
} else { | ||
cm.topologyManager = topologymanager.NewFakeManager() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the other OSes, we return a nil There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I can see, the other OSes don't have TopologyManager(or device/cpu manager) as part of the containerManagerImpl so there is no reference, so we don't return anything? I was following the convention used by DeviceManager which returns a ManagerStub below. There is also a reference to the Fake CPU Manager in the other OSes when returning the internalContainerLifecycleImpl. If I return nil, the code errors as cm.TopologyManager functions are called below. So I could wrap those calls in a check for the feature gate but looks like the fake/stub managers are used outside of test code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually think the only call you would need to wrap is this one (which probably makes sense to wrap anyway):
Looking through the code, I don't see anywhere else that https://github.com/kubernetes/kubernetes/pull/74357/files#diff-81cef540f416b0451c18470420adc42dR40 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It still feels more natural to me to remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can clean it up in a follow on. there are a number of things that can be cleaned up. i'm making a list :) |
||
} | ||
|
||
klog.Infof("Creating device plugin manager: %t", devicePluginEnabled) | ||
if devicePluginEnabled { | ||
cm.deviceManager, err = devicemanager.NewManagerImpl() | ||
|
@@ -332,7 +349,7 @@ func (cm *containerManagerImpl) NewPodContainerManager() PodContainerManager { | |
} | ||
|
||
func (cm *containerManagerImpl) InternalContainerLifecycle() InternalContainerLifecycle { | ||
return &internalContainerLifecycleImpl{cm.cpuManager} | ||
return &internalContainerLifecycleImpl{cm.cpuManager, cm.topologyManager} | ||
} | ||
|
||
// Create a cgroup container manager. | ||
|
@@ -644,6 +661,10 @@ func (cm *containerManagerImpl) UpdatePluginResources(node *schedulernodeinfo.No | |
return cm.deviceManager.Allocate(node, attrs) | ||
} | ||
|
||
func (cm *containerManagerImpl) GetTopologyPodAdmitHandler() topologymanager.Manager { | ||
return cm.topologyManager | ||
} | ||
|
||
func (cm *containerManagerImpl) SystemCgroupsLimit() v1.ResourceList { | ||
cpuLimit := int64(0) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect we will plan to move this out of experimental in the future, is it better if we just call this
TopologyManagerPolicy
to avoid a future rename?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1