mirror of https://github.com/k3s-io/k3s
Merge pull request #67145 from jiayingz/reboot-fix
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fail container start if its requested device plugin resource is unknown. With the change, Kubelet device manager now checks whether it has cached option state for the requested device plugin resource to make sure the resource is in ready state when we start the container. **What this PR does / why we need it**: **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes https://github.com/kubernetes/kubernetes/issues/67107 **Special notes for your reviewer**: **Release note**: ```release-note Fail container start if its requested device plugin resource hasn't registered after Kubelet restart. ```pull/8/head
commit
d017bebf6b
|
@ -377,9 +377,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)
|
||||
}
|
||||
|
@ -720,11 +718,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: %s", 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