Skip to content

Commit 6a59c98

Browse files
committed
distinguish between YAML and JSON file formats during log output
1 parent 49bbe19 commit 6a59c98

File tree

6 files changed

+19
-25
lines changed

6 files changed

+19
-25
lines changed

cmd/kubeadm/app/util/config/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func FetchInitConfigurationFromCluster(client clientset.Interface, printer outpu
6060
}
6161
_, _ = printer.Printf("[%s] Reading configuration from the %q ConfigMap in namespace %q...\n",
6262
logPrefix, constants.KubeadmConfigConfigMap, metav1.NamespaceSystem)
63-
_, _ = printer.Printf("[%s] Use 'kubeadm init phase upload-config --config your-config.yaml' to re-upload it.\n", logPrefix)
63+
_, _ = printer.Printf("[%s] Use 'kubeadm init phase upload-config --config your-config-file' to re-upload it.\n", logPrefix)
6464

6565
// Fetch the actual config from cluster
6666
cfg, err := getInitConfigurationFromCluster(constants.KubernetesDir, client, newControlPlane, skipComponentConfigs)
@@ -214,7 +214,7 @@ func GetNodeRegistration(kubeconfigFile string, client clientset.Interface, node
214214

215215
// getNodeNameFromKubeletConfig gets the node name from a kubelet config file
216216
// TODO: in future we want to switch to a more canonical way for doing this e.g. by having this
217-
// information in the local kubelet config.yaml
217+
// information in the local kubelet config configuration file.
218218
func getNodeNameFromKubeletConfig(fileName string) (string, error) {
219219
// loads the kubelet.conf file
220220
config, err := clientcmd.LoadFromFile(fileName)

cmd/kubeadm/app/util/config/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ func validateSupportedVersion(gvk schema.GroupVersionKind, allowDeprecated, allo
9494
gvString := gvk.GroupVersion().String()
9595

9696
if useKubeadmVersion := oldKnownAPIVersions[gvString]; useKubeadmVersion != "" {
97-
return errors.Errorf("your configuration file uses an old API spec: %q (kind: %q). Please use kubeadm %s instead and run 'kubeadm config migrate --old-config old.yaml --new-config new.yaml', which will write the new, similar spec using a newer API version.", gvString, gvk.Kind, useKubeadmVersion)
97+
return errors.Errorf("your configuration file uses an old API spec: %q (kind: %q). Please use kubeadm %s instead and run 'kubeadm config migrate --old-config old-config-file --new-config new-config-file', which will write the new, similar spec using a newer API version.", gvString, gvk.Kind, useKubeadmVersion)
9898
}
9999

100100
if _, present := deprecatedAPIVersions[gvString]; present && !allowDeprecated {
101-
klog.Warningf("your configuration file uses a deprecated API spec: %q (kind: %q). Please use 'kubeadm config migrate --old-config old.yaml --new-config new.yaml', which will write the new, similar spec using a newer API version.", gvString, gvk.Kind)
101+
klog.Warningf("your configuration file uses a deprecated API spec: %q (kind: %q). Please use 'kubeadm config migrate --old-config old-config-file --new-config new-config-file', which will write the new, similar spec using a newer API version.", gvString, gvk.Kind)
102102
}
103103

104104
if _, present := experimentalAPIVersions[gvString]; present && !allowExperimental {

cmd/kubeadm/app/util/config/initconfiguration.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func LoadOrDefaultInitConfiguration(cfgPath string, versionedInitCfg *kubeadmapi
291291
}
292292

293293
// BytesToInitConfiguration converts a byte slice to an internal, defaulted and validated InitConfiguration object.
294-
// The map may contain many different YAML documents. These YAML documents are parsed one-by-one
294+
// The map may contain many different YAML/JSON documents. These YAML/JSON documents are parsed one-by-one
295295
// and well-known ComponentConfig GroupVersionKinds are stored inside of the internal InitConfiguration struct.
296296
// The resulting InitConfiguration is then dynamically defaulted and validated prior to return.
297297
func BytesToInitConfiguration(b []byte, skipCRIDetect bool) (*kubeadmapi.InitConfiguration, error) {
@@ -303,7 +303,7 @@ func BytesToInitConfiguration(b []byte, skipCRIDetect bool) (*kubeadmapi.InitCon
303303
return documentMapToInitConfiguration(gvkmap, false, false, false, skipCRIDetect)
304304
}
305305

306-
// documentMapToInitConfiguration converts a map of GVKs and YAML documents to defaulted and validated configuration object.
306+
// documentMapToInitConfiguration converts a map of GVKs and YAML/JSON documents to defaulted and validated configuration object.
307307
func documentMapToInitConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecated, allowExperimental, strictErrors, skipCRIDetect bool) (*kubeadmapi.InitConfiguration, error) {
308308
var initcfg *kubeadmapi.InitConfiguration
309309
var clustercfg *kubeadmapi.ClusterConfiguration
@@ -326,7 +326,7 @@ func documentMapToInitConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat
326326
return nil, err
327327
}
328328

329-
// verify the validity of the YAML
329+
// verify the validity of the JSON/YAML
330330
if err := strict.VerifyUnmarshalStrict([]*runtime.Scheme{kubeadmscheme.Scheme, componentconfigs.Scheme}, gvk, fileContent); err != nil {
331331
if !strictErrors {
332332
klog.Warning(err.Error())
@@ -358,13 +358,13 @@ func documentMapToInitConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat
358358

359359
// If the group is neither a kubeadm core type or of a supported component config group, we dump a warning about it being ignored
360360
if !componentconfigs.Scheme.IsGroupRegistered(gvk.Group) {
361-
klog.Warningf("[config] WARNING: Ignored YAML document with GroupVersionKind %v\n", gvk)
361+
klog.Warningf("[config] WARNING: Ignored configuration document with GroupVersionKind %v\n", gvk)
362362
}
363363
}
364364

365-
// Enforce that InitConfiguration and/or ClusterConfiguration has to exist among the YAML documents
365+
// Enforce that InitConfiguration and/or ClusterConfiguration has to exist among the configuration documents
366366
if initcfg == nil && clustercfg == nil {
367-
return nil, errors.New("no InitConfiguration or ClusterConfiguration kind was found in the YAML file")
367+
return nil, errors.New("no InitConfiguration or ClusterConfiguration kind was found in the configuration file")
368368
}
369369

370370
// If InitConfiguration wasn't given, default it by creating an external struct instance, default it and convert into the internal type
@@ -408,7 +408,7 @@ func documentMapToInitConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat
408408
}
409409

410410
// MarshalInitConfigurationToBytes marshals the internal InitConfiguration object to bytes. It writes the embedded
411-
// ClusterConfiguration object with ComponentConfigs out as separate YAML documents
411+
// ClusterConfiguration object with ComponentConfigs out as separate YAML/JSON documents
412412
func MarshalInitConfigurationToBytes(cfg *kubeadmapi.InitConfiguration, gv schema.GroupVersion) ([]byte, error) {
413413
initbytes, err := kubeadmutil.MarshalToYamlForCodecs(cfg, gv, kubeadmscheme.Codecs)
414414
if err != nil {

cmd/kubeadm/app/util/config/joinconfiguration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func LoadJoinConfigurationFromFile(cfgPath string, opts LoadOrDefaultConfigurati
9595
return documentMapToJoinConfiguration(gvkmap, false, false, false, opts.SkipCRIDetect)
9696
}
9797

98-
// documentMapToJoinConfiguration takes a map between GVKs and YAML documents (as returned by SplitYAMLDocuments),
98+
// documentMapToJoinConfiguration takes a map between GVKs and YAML/JSON documents (as returned by SplitYAMLDocuments),
9999
// finds a JoinConfiguration, decodes it, dynamically defaults it and then validates it prior to return.
100100
func documentMapToJoinConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecated, allowExperimental, strictErrors, skipCRIDetect bool) (*kubeadmapi.JoinConfiguration, error) {
101101
joinBytes := []byte{}
@@ -110,7 +110,7 @@ func documentMapToJoinConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat
110110
return nil, err
111111
}
112112

113-
// verify the validity of the YAML
113+
// verify the validity of the YAML/JSON
114114
if err := strict.VerifyUnmarshalStrict([]*runtime.Scheme{kubeadmscheme.Scheme}, gvk, bytes); err != nil {
115115
if !strictErrors {
116116
klog.Warning(err.Error())

cmd/kubeadm/app/util/config/resetconfiguration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func LoadResetConfigurationFromFile(cfgPath string, opts LoadOrDefaultConfigurat
9999
return documentMapToResetConfiguration(gvkmap, false, opts.AllowExperimental, false, opts.SkipCRIDetect)
100100
}
101101

102-
// documentMapToResetConfiguration takes a map between GVKs and YAML documents (as returned by SplitYAMLDocuments),
102+
// documentMapToResetConfiguration takes a map between GVKs and YAML/JSON documents (as returned by SplitYAMLDocuments),
103103
// finds a ResetConfiguration, decodes it, dynamically defaults it and then validates it prior to return.
104104
func documentMapToResetConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecated, allowExperimental bool, strictErrors bool, skipCRIDetect bool) (*kubeadmapi.ResetConfiguration, error) {
105105
resetBytes := []byte{}
@@ -114,7 +114,7 @@ func documentMapToResetConfiguration(gvkmap kubeadmapi.DocumentMap, allowDepreca
114114
return nil, err
115115
}
116116

117-
// verify the validity of the YAML
117+
// verify the validity of the YAML/JSON
118118
if err := strict.VerifyUnmarshalStrict([]*runtime.Scheme{kubeadmscheme.Scheme}, gvk, bytes); err != nil {
119119
if !strictErrors {
120120
klog.Warning(err.Error())

cmd/kubeadm/app/util/config/upgradeconfiguration.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,19 @@ import (
2828
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
2929
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta4"
3030
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
31-
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
3231
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
3332
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
3433
"k8s.io/kubernetes/cmd/kubeadm/app/util/config/strict"
3534
)
3635

37-
// documentMapToUpgradeConfiguration takes a map between GVKs and YAML documents (as returned by SplitYAMLDocuments),
36+
// documentMapToUpgradeConfiguration takes a map between GVKs and YAML/JSON documents (as returned by SplitYAMLDocuments),
3837
// finds a UpgradeConfiguration, decodes it, dynamically defaults it and then validates it prior to return.
3938
func documentMapToUpgradeConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecated bool) (*kubeadmapi.UpgradeConfiguration, error) {
4039
upgradeBytes := []byte{}
4140

4241
for gvk, bytes := range gvkmap {
43-
if kubeadmutil.GroupVersionKindsHasInitConfiguration(gvk) || kubeadmutil.GroupVersionKindsHasClusterConfiguration(gvk) || componentconfigs.Scheme.IsGroupRegistered(gvk.Group) {
44-
klog.Warningf("[config] WARNING: YAML document with GroupVersionKind %v is deprecated for upgrade, please use config file with kind of UpgradeConfiguration instead \n", gvk)
45-
continue
46-
}
47-
4842
if gvk.Kind != constants.UpgradeConfigurationKind {
49-
klog.Warningf("[config] WARNING: Ignored YAML document with GroupVersionKind %v\n", gvk)
43+
klog.Warningf("[config] WARNING: Ignored configuration document with GroupVersionKind %v\n", gvk)
5044
continue
5145
}
5246

@@ -55,7 +49,7 @@ func documentMapToUpgradeConfiguration(gvkmap kubeadmapi.DocumentMap, allowDepre
5549
return nil, err
5650
}
5751

58-
// verify the validity of the YAML
52+
// verify the validity of the YAML/JSON
5953
if err := strict.VerifyUnmarshalStrict([]*runtime.Scheme{kubeadmscheme.Scheme}, gvk, bytes); err != nil {
6054
klog.Warning(err.Error())
6155
}
@@ -99,7 +93,7 @@ func LoadUpgradeConfigurationFromFile(cfgPath string, _ LoadOrDefaultConfigurati
9993
return nil, errors.Wrapf(err, "unable to load config from file %q", cfgPath)
10094
}
10195

102-
// Split the YAML documents in the file into a DocumentMap
96+
// Split the YAML/JSON documents in the file into a DocumentMap
10397
docmap, err := kubeadmutil.SplitYAMLDocuments(configBytes)
10498
if err != nil {
10599
return nil, err

0 commit comments

Comments
 (0)