Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubeadm: Replace the yaml in the log/comments with a generic term. #130345

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

HirazawaUi
Copy link
Contributor

@HirazawaUi HirazawaUi commented Feb 21, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

  1. Currently, kubeadm supports both yaml and json configuration file types, but in our log output, we only explicitly mention the yaml format.
  2. We haven't printed warning logs for unknown GVKs in all the documentMapToXXX functions. To ensure consistent behavior across the documentMapToXXX functions and to provide sufficient warnings to users, we should print warning logs.

Which issue(s) this PR fixes:

Fixes kubernetes/kubeadm#3163 kubernetes/kubeadm#3162

Special notes for your reviewer:

To make the functions appear more consistent, I also renamed the SplitYAMLDocuments function to SplitYAMLOrJSONDocuments. If this is an unnecessary change, I can roll it back.

Does this PR introduce a user-facing change?

kubeadm: Use generic terminology in logs instead of direct mentions of yaml/json.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 21, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 21, 2025
@carlory
Copy link
Member

carlory commented Feb 24, 2025

/release-note-none
/lgtm

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 24, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 24, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 4de94b209ce33e899d62167ce8ea44456d8afa39

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the pr @HirazawaUi

})
docmap, err := kubeadmutil.SplitYAMLOrJSONDocuments(b)
if err != nil {
t.Fatalf("Unexpected error of SplitYAMLOrJSONDocuments: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SplitConfigDocuments

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is initconfiguration_test.go not calling docmap, err := kubeadmutil.SplitYAMLOrJSONDocuments(b) as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the BytesToInitConfiguration function already includes SplitYAMLDocuments() and documentMapToInitConfiguration().
ref:

// BytesToInitConfiguration converts a byte slice to an internal, defaulted and validated InitConfiguration object.
// The map may contain many different YAML documents. These YAML documents are parsed one-by-one
// and well-known ComponentConfig GroupVersionKinds are stored inside of the internal InitConfiguration struct.
// The resulting InitConfiguration is then dynamically defaulted and validated prior to return.
func BytesToInitConfiguration(b []byte, skipCRIDetect bool) (*kubeadmapi.InitConfiguration, error) {
gvkmap, err := kubeadmutil.SplitYAMLDocuments(b)
if err != nil {
return nil, err
}
return documentMapToInitConfiguration(gvkmap, false, false, false, skipCRIDetect)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably add BytesToXConfiguration for all kinds of config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

Comment on lines +432 to +420
for _, format := range formats {
t.Run(fmt.Sprintf("%s_%s", tt.name, format.name), func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you are adding multi format testing for init and upgrade config, should you also add it to reset and join config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@neolit123
Copy link
Member

Does this PR introduce a user-facing change?

needs a simple release note explaining the user facing aspect of the change.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Feb 24, 2025
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 24, 2025
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 24, 2025
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: HirazawaUi
Once this PR has been reviewed and has the lgtm label, please ask for approval from carlory. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

}

if _, present := deprecatedAPIVersions[gvString]; present && !allowDeprecated {
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)
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
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)

return BytesToJoinConfiguration(b, opts)
}

// BytesToJoinConfiguration converts a byte slice to an internal, defaulted and validated ResetConfiguration object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JoinConfiguration


// BytesToJoinConfiguration converts a byte slice to an internal, defaulted and validated ResetConfiguration object.
// The map may contain many different YAML/JSON documents. These documents are parsed one-by-one
// and well-known ComponentConfig GroupVersionKinds are stored inside of the internal ResetConfiguration struct.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are no component configs in reset config

}

if obj == nil {
t.Error("Unexpected nil return value")
got, _ := LoadJoinConfigurationFromFile(tt.cfgPath, options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use bytestojoinconfiguration instead of writing a file and reading it
we should make this consistent across xconfiguration_tests.go.


// BytesToResetConfiguration converts a byte slice to an internal, defaulted and validated ResetConfiguration object.
// The map may contain many different YAML/JSON documents. These documents are parsed one-by-one
// and well-known ComponentConfig GroupVersionKinds are stored inside of the internal ResetConfiguration struct.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are no component configs in reset config

}

if obj == nil {
t.Error("Unexpected nil return value")
got, _ := LoadResetConfigurationFromFile(tt.cfgPath, options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again we should use bytestoresetconfiguration here instead of writing and loading

the load* functions can have another simple test, maybe

Comment on lines +101 to +104
// BytesToUpgradeConfiguration converts a byte slice to an internal, defaulted and validated InitConfiguration object.
// The map may contain many different YAML/JSON documents. These documents are parsed one-by-one
// and well-known ComponentConfig GroupVersionKinds are stored inside of the internal UpgradeConfiguration struct.
// The resulting UpgradeConfiguration is then dynamically defaulted and validated prior to return.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar copy paste errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify configuration file handling behavior during loading
4 participants