kubelet: warn instead of error for unsupported options on Windows

Make validateKubeletOSConfiguration() show warnings instead of
returning errors on Windows for the fields "CgroupsPerQOS" and
"EnforceNodeAllocatable".
This commit is contained in:
Lubomir I. Ivanov 2024-02-05 20:26:48 +02:00 committed by Lubomir I. Ivanov
parent 026ce57c94
commit 3301efa6a0

View File

@ -20,24 +20,22 @@ limitations under the License.
package validation
import (
"fmt"
"k8s.io/klog/v2"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
)
// validateKubeletOSConfiguration validates os specific kubelet configuration and returns an error if it is invalid.
func validateKubeletOSConfiguration(kc *kubeletconfig.KubeletConfiguration) error {
message := "invalid configuration: %v (%v) %v is not supported on Windows"
allErrors := []error{}
message := "ignored configuration option: %v (%v) %v is not supported on Windows"
if kc.CgroupsPerQOS {
allErrors = append(allErrors, fmt.Errorf(message, "CgroupsPerQOS", "--cgroups-per-qos", kc.CgroupsPerQOS))
klog.Warningf(message, "CgroupsPerQOS", "--cgroups-per-qos", kc.CgroupsPerQOS)
}
if len(kc.EnforceNodeAllocatable) > 0 {
allErrors = append(allErrors, fmt.Errorf(message, "EnforceNodeAllocatable", "--enforce-node-allocatable", kc.EnforceNodeAllocatable))
klog.Warningf(message, "EnforceNodeAllocatable", "--enforce-node-allocatable", kc.EnforceNodeAllocatable)
}
return utilerrors.NewAggregate(allErrors)
return nil
}