Skip to content
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

Check for nil cpuManager in container manager #88857

Merged
merged 1 commit into from Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions pkg/kubelet/cm/container_manager_linux.go
Expand Up @@ -706,12 +706,14 @@ func (m *resourceAllocator) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle
}
}

err = m.cpuManager.Allocate(pod, &container)
if err != nil {
return lifecycle.PodAdmitResult{
Message: fmt.Sprintf("Allocate failed due to %v, which is unexpected", err),
Reason: "UnexpectedAdmissionError",
Admit: false,
if m.cpuManager != nil {
err = m.cpuManager.Allocate(pod, &container)
if err != nil {
return lifecycle.PodAdmitResult{
Message: fmt.Sprintf("Allocate failed due to %v, which is unexpected", err),
Reason: "UnexpectedAdmissionError",
Admit: false,
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubelet/cm/internal_container_lifecycle.go
Expand Up @@ -38,7 +38,7 @@ type internalContainerLifecycleImpl struct {
}

func (i *internalContainerLifecycleImpl) PreStartContainer(pod *v1.Pod, container *v1.Container, containerID string) error {
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.CPUManager) {
if i.cpuManager != nil {
err := i.cpuManager.AddContainer(pod, container, containerID)
if err != nil {
return err
Expand All @@ -54,14 +54,14 @@ func (i *internalContainerLifecycleImpl) PreStartContainer(pod *v1.Pod, containe
}

func (i *internalContainerLifecycleImpl) PreStopContainer(containerID string) error {
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.CPUManager) {
if i.cpuManager != nil {
return i.cpuManager.RemoveContainer(containerID)
}
return nil
}

func (i *internalContainerLifecycleImpl) PostStopContainer(containerID string) error {
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.CPUManager) {
if i.cpuManager != nil {
err := i.cpuManager.RemoveContainer(containerID)
if err != nil {
return err
Expand Down