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 upgrade plan support json/yaml output #108447

Merged
merged 3 commits into from May 17, 2022

Conversation

pacoxu
Copy link
Member

@pacoxu pacoxu commented Mar 2, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

Based on #83941.

Which issue(s) this PR fixes:

xref kubernetes/kubeadm#494

Special notes for your reviewer:

1. text print will not be changed.

2. json example: upgrade from v1.23.3 to v1.23.4

{
    "kind": "UpgradePlan",
    "apiVersion": "output.kubeadm.k8s.io/v1alpha2",
    "components": [
        {
            "name": "kube-apiserver",
            "currentVersion": "v1.23.3",
            "newVersion": "v1.23.4"
        },
        {
            "name": "kube-controller-manager",
            "currentVersion": "v1.23.3",
            "newVersion": "v1.23.4"
        },
        {
            "name": "kube-scheduler",
            "currentVersion": "v1.23.3",
            "newVersion": "v1.23.4"
        },
        {
            "name": "kube-proxy",
            "currentVersion": "v1.23.3",
            "newVersion": "v1.23.4"
        },
        {
            "name": "CoreDNS",
            "currentVersion": "v1.8.6",
            "newVersion": "v1.8.6"
        },
        {
            "name": "etcd",
            "currentVersion": "3.5.1-0",
            "newVersion": "3.5.1-0"
        }
    ],
    "configVersions": null
}

3. yaml example

apiVersion: output.kubeadm.k8s.io/v1alpha2
components:
- currentVersion: v1.23.3
  name: kube-apiserver
  newVersion: v1.23.4
- currentVersion: v1.23.3
  name: kube-controller-manager
  newVersion: v1.23.4
- currentVersion: v1.23.3
  name: kube-scheduler
  newVersion: v1.23.4
- currentVersion: v1.23.3
  name: kube-proxy
  newVersion: v1.23.4
- currentVersion: v1.8.6
  name: CoreDNS
  newVersion: v1.8.6
- currentVersion: 3.5.1-0
  name: etcd
  newVersion: 3.5.1-0
configVersions: null
kind: UpgradePlan

Does this PR introduce a user-facing change?

kubeadm: support experimental JSON/YAML output for "kubeadm upgrade plan" with the "--output" flag

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


@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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. 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 Mar 2, 2022
@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 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 Mar 2, 2022
@pacoxu pacoxu force-pushed the kubeadm-json-upgrade-plan branch from 64da4c1 to e117531 Compare March 3, 2022 09:28
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 3, 2022
@pacoxu pacoxu marked this pull request as ready for review March 3, 2022 10:35
@pacoxu pacoxu force-pushed the kubeadm-json-upgrade-plan branch from e117531 to 0476877 Compare March 3, 2022 10:35
@pacoxu pacoxu changed the title [WIP]Kubeadm upgrade plan support json/yaml output Kubeadm upgrade plan support json/yaml output Mar 3, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 3, 2022
@pacoxu
Copy link
Member Author

pacoxu commented Mar 3, 2022

/priority important-longterm
/triage accepted

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 3, 2022
}

printLineSeparator(w)
printLineSeparator(writer, printer)
printer.Close(writer)
Copy link
Member

@neolit123 neolit123 Mar 21, 2022

Choose a reason for hiding this comment

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

related to the comments about Close(), printing on close is a bit strange and this is confusing me.

would it make sense to print the object explicitly with PrintObj.
the p.Buffer = []outputapiv1alpha2.ComponentUpgradePlan{} for the JSON/YAML printer makes more sense to be in a Flush()

do we have other usage of a Close() that actually makes sense related to a "close" operation?
e.g. closing open file handles.

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.

here is another review pass here.

  • there are some minor typos in comments
  • the Close() is better but i think there is a problem in Flush()
  • there are some strange new lines here and there, we should make these consistent if we can
  • if a text is printed without arguments it should use {F}println() and not {F}printf()

also as mentioned before, i'd really appreciate at least another reviewer for this...
see if you like to ping someone for review.

fmt.Println("")
printer.Printf("[upgrade/config] In order to upgrade, a ConfigMap called %q in the %s namespace must exist.\n", constants.KubeadmConfigConfigMap, metav1.NamespaceSystem)
printer.Printf("[upgrade/config] Without this information, 'kubeadm upgrade' won't know how to configure your upgraded cluster.\n")
printer.Printf("\n")
Copy link
Member

Choose a reason for hiding this comment

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

we can add the Println() method to the interface and use it in all cases when we are printing a line without arguments. (similarly we have the Fprintf())

we have instances of this in common.go and more places.

cmd/kubeadm/app/cmd/upgrade/plan.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/cmd/upgrade/plan.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/cmd/upgrade/plan.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/cmd/upgrade/plan.go Show resolved Hide resolved
cmd/kubeadm/app/cmd/upgrade/plan.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/cmd/upgrade/plan.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/cmd/upgrade/plan.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/cmd/upgrade/plan.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/phases/upgrade/compute.go Outdated Show resolved Hide resolved
Co-authored-by: Lubomir I. Ivanov <neolit123@gmail.com>
@pacoxu
Copy link
Member Author

pacoxu commented Mar 25, 2022

also i think this should have at least another reviewer!

@RA489 @SataQiu
Do you have time to take a look?

@pacoxu
Copy link
Member Author

pacoxu commented Mar 25, 2022

/cc @Klaven @fabriziopandini
cc to reviewers of #83941

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 all the updates @pacoxu !

a bit disappointing that nobody else wants to review this...
it looks fine to me, but i can do another quick pass and maybe we can merge it in early 1.25.

/approve
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 30, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: neolit123, pacoxu

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 30, 2022
@neolit123
Copy link
Member

/hold cancel
let's merge this next week if there are no blocking comments.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 12, 2022
@neolit123
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2022
@k8s-ci-robot k8s-ci-robot merged commit 9169f16 into kubernetes:master May 17, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. 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. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants