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

Fix kubectl-convert import known versions #97754

Merged
merged 1 commit into from Jan 12, 2021

Conversation

wzshiming
Copy link
Member

@wzshiming wzshiming commented Jan 6, 2021

What type of PR is this?
/kind bug
/sig cli

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #97729

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

kubectl-convert: Fix a regression in 1.20 with `no kind "Ingress" is registered for version` error

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


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. sig/cli Categorizes an issue or PR as relevant to SIG CLI. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 6, 2021
@k8s-ci-robot
Copy link
Contributor

@wzshiming: 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jan 6, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @wzshiming. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/kubectl labels Jan 6, 2021
@knight42
Copy link
Member

knight42 commented Jan 7, 2021

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 7, 2021
@liggitt
Copy link
Member

liggitt commented Jan 7, 2021

Thanks for the PR. We need a unit test to ensure the API types defined and known to client-go continue to be registered here.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 7, 2021
@wzshiming
Copy link
Member Author

/assign @janetkuo

@@ -90,6 +90,16 @@ func TestConvertObject(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.

this test is fine for ingress specifically but will not catch other missing types.

add a test like this in this file:

func TestKnownVersions(t *testing.T) {
	legacytypes := legacyscheme.Scheme.AllKnownTypes()
	alreadyErroredGroups := map[string]bool{}
	var gvks []schema.GroupVersionKind
	for gvk := range scheme.Scheme.AllKnownTypes() {
		gvks = append(gvks, gvk)
	}
	sort.Slice(gvks, func(i, j int) bool {
		if isWatchEvent1, isWatchEvent2 := gvks[i].Kind == "WatchEvent", gvks[j].Kind == "WatchEvent"; isWatchEvent1 != isWatchEvent2 {
			return isWatchEvent2
		}
		if isList1, isList2 := strings.HasSuffix(gvks[i].Kind, "List"), strings.HasSuffix(gvks[j].Kind, "List"); isList1 != isList2 {
			return isList2
		}
		if isOptions1, isOptions2 := strings.HasSuffix(gvks[i].Kind, "Options"), strings.HasSuffix(gvks[j].Kind, "Options"); isOptions1 != isOptions2 {
			return isOptions2
		}
		if isInternal1, isInternal2 := gvks[i].Group == runtime.APIVersionInternal, gvks[j].Group == runtime.APIVersionInternal; isInternal1 != isInternal2 {
			return isInternal2
		}
		return gvks[i].String() < gvks[j].String()
	})
	for _, gvk := range gvks {
		if alreadyErroredGroups[gvk.Group] {
			continue
		}
		if _, legacyregistered := legacytypes[gvk]; !legacyregistered {
			t.Errorf("%v is not registered in legacyscheme. Add group %q (all internal and external versions) to convert/import_known_versions.go", gvk, gvk.Group)
			alreadyErroredGroups[gvk.Group] = true
		}
	}
}

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 12, 2021
@wzshiming
Copy link
Member Author

/retest

@liggitt
Copy link
Member

liggitt commented Jan 12, 2021

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 12, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, wzshiming

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 Jan 12, 2021
@liggitt
Copy link
Member

liggitt commented Jan 12, 2021

thanks, once this merges, can you backport it to 1.20 using hack/cherry_pick_pull.sh?

@pacoxu
Copy link
Member

pacoxu commented Jan 12, 2021

/test pull-kubernetes-bazel-build
/test pull-kubernetes-e2e-gce-ubuntu-containerd

@k8s-ci-robot k8s-ci-robot merged commit db183c7 into kubernetes:master Jan 12, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Jan 12, 2021
k8s-ci-robot added a commit that referenced this pull request Jan 22, 2021
…754-upstream-release-1.20

Automated cherry pick of #97754: kubectl-convert import known versions
@wzshiming wzshiming deleted the fix-kubectl-convert branch January 23, 2021 06:25
@liggitt liggitt added the kind/regression Categorizes issue or PR as related to a regression from a prior release. label Apr 27, 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/kubectl area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubectl-convert cannot convert Ingress objects
6 participants