Merge pull request #85047 from yutedz/dev-mgr-err-handling

Handle error return from allocatePodResources
This commit is contained in:
Kubernetes Prow Robot 2019-11-12 11:51:27 -08:00 committed by GitHub
commit ed10b5b17f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -231,7 +231,9 @@ func (m *ManagerImpl) Start(activePods ActivePodsFunc, sourcesReady config.Sourc
}
socketPath := filepath.Join(m.socketdir, m.socketname)
os.MkdirAll(m.socketdir, 0750)
if err = os.MkdirAll(m.socketdir, 0750); err != nil {
return err
}
if selinux.SELinuxEnabled() {
if err := selinux.SetFileLabel(m.socketdir, config.KubeletPluginsDirSELinuxLabel); err != nil {
klog.Warningf("Unprivileged containerized plugins might not work. Could not set selinux context on %s: %v", m.socketdir, err)
@ -552,7 +554,9 @@ func (m *ManagerImpl) writeCheckpoint() error {
m.mutex.Unlock()
err := m.checkpointManager.CreateCheckpoint(kubeletDeviceManagerCheckpoint, data)
if err != nil {
return fmt.Errorf("failed to write checkpoint file %q: %v", kubeletDeviceManagerCheckpoint, err)
err2 := fmt.Errorf("failed to write checkpoint file %q: %v", kubeletDeviceManagerCheckpoint, err)
klog.Warning(err2)
return err2
}
return nil
}
@ -853,7 +857,9 @@ func (m *ManagerImpl) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Co
}
if needsReAllocate {
klog.V(2).Infof("needs re-allocate device plugin resources for pod %s", podUID)
m.allocatePodResources(pod)
if err := m.allocatePodResources(pod); err != nil {
return nil, err
}
}
m.mutex.Lock()
defer m.mutex.Unlock()

View File

@ -744,7 +744,9 @@ func TestPodContainerDeviceAllocation(t *testing.T) {
testCase.description, testCase.expErr, err)
}
runContainerOpts, err := testManager.GetDeviceRunContainerOptions(pod, &pod.Spec.Containers[0])
as.Nil(err)
if testCase.expErr == nil {
as.Nil(err)
}
if testCase.expectedContainerOptsLen == nil {
as.Nil(runContainerOpts)
} else {