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

Log a warning message when failed to find kind for resource in garbage collector controller #39457

Merged
merged 1 commit into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/controller/garbagecollector/garbagecollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,14 @@ func NewGarbageCollector(metaOnlyClientPool dynamic.ClientPool, clientPool dynam
}
kind, err := gc.restMapper.KindFor(resource)
if err != nil {
if _, ok := err.(*meta.NoResourceMatchError); ok {
// ignore NoResourceMatchErrors for now because TPRs won't be registered
// and hence the RestMapper does not know about them. The deletableResources
// though are using discovery which included TPRs.
// TODO: use dynamic discovery for RestMapper and deletableResources
glog.Warningf("ignore NoResourceMatchError for %v", resource)
continue
}
return nil, err
}
monitor, err := gc.monitorFor(resource, kind)
Expand Down
1 change: 1 addition & 0 deletions pkg/master/thirdparty/thirdparty.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (m *ThirdPartyResourceServer) InstallThirdPartyResource(rsrc *extensions.Th
m.genericAPIServer.HandlerContainer.Add(genericapi.NewGroupWebService(api.Codecs, path, apiGroup))

m.addThirdPartyResourceStorage(path, plural.Resource, thirdparty.Storage[plural.Resource].(*thirdpartyresourcedataetcd.REST), apiGroup)
registered.AddThirdPartyAPIGroupVersions(schema.GroupVersion{Group: group, Version: rsrc.Versions[0].Name})
Copy link
Contributor

Choose a reason for hiding this comment

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

Will the upper check see this registration? This is master, above is controller manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it won't, I add this because there are some calls in the apiserver which did the same check as above, for example: https://github.com/kubernetes/kubernetes/blob/master/pkg/registry/extensions/thirdpartyresourcedata/codec.go#L373.

but yeah, I did two things here, and I am still doing various of validation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is anything broken in the apiserver due to not registering the thirdpartyresources? We are either missing a test or the whole registration is not necessary. In the later case, I would rather remove the whole registration logic for tprs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sttts along with your changes to add verbs for thirdpartyresources, the namespace controller will be aware of them, so let's reconsider the problem at #37278.

When a namespace is going to be deleted, the namespace controller will delete all the deletable resources under that namespace, and in case it is a TPR resources, the delete options will fail to be decoded by a TPR gvk, and @caesarxuchao made a change in this pull request: #37328, if you look at the code, it checks whether the gvk is a TPR group version by calling registered.IsThirdPartyAPIGroupVersion, and that call depends on whether we register it or not.

Copy link
Member

Choose a reason for hiding this comment

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

The stuff in the registered package is intended to be static, write-once on application startup, so I'm a little surprised to see this method...

Copy link
Member

Choose a reason for hiding this comment

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

And answering the question, this line could only possibly affect the copy of registered in the apiserver binary. It has no effect on the copy of registered that the garbage collector would use.

If you add this here, probably there is a corresponding place where it needs to be removed.

Copy link
Member

Choose a reason for hiding this comment

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

hm, it's pretty weird that that function existed but was never called in the server. Perhaps it was intended for clients constructing their own RESTMapper.

Copy link
Member

Choose a reason for hiding this comment

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

Last thought: having this line here without explanation and without a test makes it hard to refactor this code into something understandable. @zhouhaibing089 it would be great if you could add a test :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lavalamp thanks for your thoughts, i will do both: add an explanation and also a test.

return nil
}

Expand Down