mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Fail container start if its requested device plugin resource doesn't
have cached option state to make sure the device plugin resource is in ready state when we start the container.
This commit is contained in:
parent
d949315649
commit
7b1ae66432
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user