Skip to content

Commit

Permalink
WIP: kubelet: add a way to toggle the devicemanager check
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Romani <fromani@redhat.com>
  • Loading branch information
ffromani committed Jun 7, 2023
1 parent 55f2dbe commit aa7d7f4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/kubelet/cm/devicemanager/manager.go
Expand Up @@ -546,6 +546,11 @@ func (m *ManagerImpl) devicesToAllocate(podUID, contName, resource string, requi
}

klog.V(3).InfoS("Need devices to allocate for pod", "deviceNumber", needed, "resourceName", resource, "podUID", string(podUID), "containerName", contName)
if IsRelaxedCheckEnabled() && needed == 0 {
// No change, no work.
return nil, nil
}

healthyDevices, hasRegistered := m.healthyDevices[resource]

// Check if resource registered with devicemanager
Expand Down
38 changes: 38 additions & 0 deletions pkg/kubelet/cm/devicemanager/strictallocation.go
@@ -0,0 +1,38 @@
/*
Copyright 2023 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package devicemanager

import "os"

var (
devicemanagerRelaxedCheckEnabled bool
devicemanagerRelaxedCheckFilename = "/etc/kubernetes/openshift-devicemanager-relaxed-check"
)

func init() {
readEnablementFile()
}

func readEnablementFile() {
if _, err := os.Stat(devicemanagerRelaxedCheckFilename); err == nil {
devicemanagerRelaxedCheckEnabled = true
}
}

func IsRelaxedCheckEnabled() bool {
return devicemanagerRelaxedCheckEnabled
}

0 comments on commit aa7d7f4

Please sign in to comment.