diff --git a/pkg/kubelet/cm/devicemanager/manager.go b/pkg/kubelet/cm/devicemanager/manager.go index 3969ce836c..4b64a506ba 100644 --- a/pkg/kubelet/cm/devicemanager/manager.go +++ b/pkg/kubelet/cm/devicemanager/manager.go @@ -378,9 +378,7 @@ func (m *ManagerImpl) addEndpointProbeMode(resourceName string, socketPath strin func (m *ManagerImpl) registerEndpoint(resourceName string, options *pluginapi.DevicePluginOptions, e *endpointImpl) { m.mutex.Lock() defer m.mutex.Unlock() - if options != nil { - m.pluginOpts[resourceName] = options - } + m.pluginOpts[resourceName] = options m.endpoints[resourceName] = e glog.V(2).Infof("Registered endpoint %v", e) } @@ -721,11 +719,8 @@ func (m *ManagerImpl) callPreStartContainerIfNeeded(podUID, contName, resource s opts, ok := m.pluginOpts[resource] if !ok { m.mutex.Unlock() - glog.V(4).Infof("Plugin options not found in cache for resource: %s. Skip PreStartContainer", resource) - return nil - } - - if !opts.PreStartRequired { + return fmt.Errorf("Plugin options not found in cache for resource: %s", resource) + } else if opts == nil || !opts.PreStartRequired { m.mutex.Unlock() glog.V(4).Infof("Plugin options indicate to skip PreStartContainer for resource, %v", resource) return nil diff --git a/pkg/kubelet/cm/devicemanager/manager_test.go b/pkg/kubelet/cm/devicemanager/manager_test.go index e4b2584490..b6ddb46506 100644 --- a/pkg/kubelet/cm/devicemanager/manager_test.go +++ b/pkg/kubelet/cm/devicemanager/manager_test.go @@ -670,6 +670,8 @@ func TestPodContainerDeviceAllocation(t *testing.T) { defer os.RemoveAll(tmpDir) nodeInfo := getTestNodeInfo(v1.ResourceList{}) pluginOpts := make(map[string]*pluginapi.DevicePluginOptions) + pluginOpts[res1.resourceName] = nil + pluginOpts[res2.resourceName] = nil testManager, err := getTestManager(tmpDir, podsStub.getActivePods, testResources, pluginOpts) as.Nil(err) @@ -766,6 +768,8 @@ func TestInitContainerDeviceAllocation(t *testing.T) { as.Nil(err) defer os.RemoveAll(tmpDir) pluginOpts := make(map[string]*pluginapi.DevicePluginOptions) + pluginOpts[res1.resourceName] = nil + pluginOpts[res2.resourceName] = nil testManager, err := getTestManager(tmpDir, podsStub.getActivePods, testResources, pluginOpts) as.Nil(err)