Merge pull request #106858 from cmssczy/add_RegisterWithTaints_validation_test

add kubelet config validation test for RegisterWithTaints
This commit is contained in:
Kubernetes Prow Robot 2022-02-23 12:51:58 -08:00 committed by GitHub
commit 08c31088c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -133,7 +133,7 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
allErrors = append(allErrors, fmt.Errorf("invalid taint: %v", nodeTaint))
}
if nodeTaint.TimeAdded != nil {
allErrors = append(allErrors, fmt.Errorf("taint TimeAdded is not nil"))
allErrors = append(allErrors, fmt.Errorf("invalid configuration: taint.TimeAdded is not nil"))
}
}

View File

@ -21,6 +21,7 @@ import (
"testing"
"time"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
componentbaseconfig "k8s.io/component-base/config"
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
@ -483,6 +484,15 @@ func TestValidateKubeletConfiguration(t *testing.T) {
},
errMsg: "invalid configuration: memoryThrottlingFactor 1.1 must be greater than 0 and less than or equal to 1.0",
},
{
name: "invalid Taint.TimeAdded",
configure: func(conf *kubeletconfig.KubeletConfiguration) *kubeletconfig.KubeletConfiguration {
now := metav1.Now()
conf.RegisterWithTaints = []v1.Taint{{TimeAdded: &now}}
return conf
},
errMsg: "invalid configuration: taint.TimeAdded is not nil",
},
}
for _, tc := range cases {