mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
Merge pull request #121347 from SataQiu/fix-kubeadm-20231019
kubeadm: fix TestValidateConfig failure on the host with multiple CRI endpoints
This commit is contained in:
commit
a570b05253
@ -61,7 +61,6 @@ apiVersion: %s
|
||||
kind: InitConfiguration
|
||||
nodeRegistration:
|
||||
name: foo
|
||||
criSocket: %s
|
||||
localAPIEndpoint:
|
||||
advertiseAddress: 192.168.2.2
|
||||
bindPort: 6443
|
||||
@ -86,7 +85,7 @@ networking:
|
||||
dnsDomain: cluster.local
|
||||
podSubnet: ""
|
||||
serviceSubnet: 10.96.0.0/12
|
||||
`, kubeadmapiv1.SchemeGroupVersion.String(), constants.UnknownCRISocket)
|
||||
`, kubeadmapiv1.SchemeGroupVersion.String())
|
||||
|
||||
// fakeWaiter is a fake apiclient.Waiter that returns errors it was initialized with
|
||||
type fakeWaiter struct {
|
||||
@ -600,7 +599,7 @@ func getConfig(version, certsDir, etcdDataDir string) (*kubeadmapi.InitConfigura
|
||||
configBytes := []byte(fmt.Sprintf(testConfiguration, certsDir, etcdDataDir, version))
|
||||
|
||||
// Unmarshal the config
|
||||
return configutil.BytesToInitConfiguration(configBytes, false)
|
||||
return configutil.BytesToInitConfiguration(configBytes, true /* skipCRIDetect */)
|
||||
}
|
||||
|
||||
func getTempDir(t *testing.T, name string) (string, func()) {
|
||||
|
@ -332,21 +332,21 @@ func ValidateConfig(config []byte, allowExperimental bool) error {
|
||||
|
||||
// Validate InitConfiguration and ClusterConfiguration if there are any in the config
|
||||
if kubeadmutil.GroupVersionKindsHasInitConfiguration(gvks...) || kubeadmutil.GroupVersionKindsHasClusterConfiguration(gvks...) {
|
||||
if _, err := documentMapToInitConfiguration(gvkmap, true, allowExperimental, true, false); err != nil {
|
||||
if _, err := documentMapToInitConfiguration(gvkmap, true, allowExperimental, true, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Validate JoinConfiguration if there is any
|
||||
if kubeadmutil.GroupVersionKindsHasJoinConfiguration(gvks...) {
|
||||
if _, err := documentMapToJoinConfiguration(gvkmap, true, allowExperimental, true, false); err != nil {
|
||||
if _, err := documentMapToJoinConfiguration(gvkmap, true, allowExperimental, true, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Validate ResetConfiguration if there is any
|
||||
if kubeadmutil.GroupVersionKindsHasResetConfiguration(gvks...) {
|
||||
if _, err := documentMapToResetConfiguration(gvkmap, true, allowExperimental, true, false); err != nil {
|
||||
if _, err := documentMapToResetConfiguration(gvkmap, true, allowExperimental, true, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -510,30 +510,24 @@ func TestValidateConfig(t *testing.T) {
|
||||
cfg: dedent.Dedent(fmt.Sprintf(`
|
||||
apiVersion: %s
|
||||
kind: InitConfiguration
|
||||
nodeRegistration:
|
||||
criSocket: %s
|
||||
name: foo bar # not a valid subdomain
|
||||
`, gv, constants.UnknownCRISocket)),
|
||||
`, gv)),
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "unknown API GVK",
|
||||
cfg: dedent.Dedent(fmt.Sprintf(`
|
||||
cfg: dedent.Dedent(`
|
||||
apiVersion: foo/bar # not a valid GroupVersion
|
||||
kind: zzz # not a valid Kind
|
||||
nodeRegistration:
|
||||
criSocket: %s
|
||||
`, constants.UnknownCRISocket)),
|
||||
`),
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "legacy API GVK",
|
||||
cfg: dedent.Dedent(fmt.Sprintf(`
|
||||
cfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1 # legacy API
|
||||
kind: InitConfiguration
|
||||
nodeRegistration:
|
||||
criSocket: %s
|
||||
`, constants.UnknownCRISocket)),
|
||||
`),
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
@ -542,9 +536,7 @@ func TestValidateConfig(t *testing.T) {
|
||||
apiVersion: %s
|
||||
kind: InitConfiguration
|
||||
foo: bar
|
||||
nodeRegistration:
|
||||
criSocket: %s
|
||||
`, gv, constants.UnknownCRISocket)),
|
||||
`, gv)),
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
@ -552,9 +544,7 @@ func TestValidateConfig(t *testing.T) {
|
||||
cfg: dedent.Dedent(fmt.Sprintf(`
|
||||
apiVersion: %s
|
||||
kind: InitConfiguration
|
||||
nodeRegistration:
|
||||
criSocket: %s
|
||||
`, gv, constants.UnknownCRISocket)),
|
||||
`, gv)),
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user