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
Conversation
@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 The 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. |
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 Once the patch is verified, the new status will be reflected by the 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. |
/ok-to-test |
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. |
dfb652f
to
86aabc9
Compare
c8ae638
to
7144b57
Compare
/assign @janetkuo |
@@ -90,6 +90,16 @@ func TestConvertObject(t *testing.T) { | |||
}, | |||
}, | |||
}, | |||
{ |
There was a problem hiding this comment.
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
}
}
}
7144b57
to
b0b7ee4
Compare
/retest |
b0b7ee4
to
af5e468
Compare
af5e468
to
df9a779
Compare
/lgtm |
[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 |
thanks, once this merges, can you backport it to 1.20 using |
/test pull-kubernetes-bazel-build |
…754-upstream-release-1.20 Automated cherry pick of #97754: kubectl-convert import known versions
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?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: