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

MapObject.Object contains empty GroupVersionKind #284

Closed
liyinan926 opened this issue Jan 8, 2019 · 6 comments · Fixed by #389
Closed

MapObject.Object contains empty GroupVersionKind #284

liyinan926 opened this issue Jan 8, 2019 · 6 comments · Fixed by #389

Comments

@liyinan926
Copy link
Contributor

liyinan926 commented Jan 8, 2019

I noticed that MapObject.Object instances passed to a handler.ToRequestsFunc function contains empty GroupVersionKind. The code I have looks like the following:

mapFn := handler.ToRequestsFunc(
	func(a handler.MapObject) []reconcile.Request {
		var requests []reconcile.Request
		apps := listApplications(mgr.GetClient(), a.Meta.GetNamespace())
		for _, app := range apps {
			ref := app.Spec.Selector.ObjectRef
			gvk := a.Object.GetObjectKind().GroupVersionKind()
			if gvk.Empty() {
				log.Printf("Empty GVK for object %s/%s", a.Meta.GetNamespace(), a.Meta.GetName())
				return requests
			}
			if ref != nil && ref.Name == a.Meta.GetName() && ref.Kind == gvk.Kind {
				requests = append(requests, reconcile.Request{
					NamespacedName: types.NamespacedName{
						Namespace: app.Namespace,
						Name:      app.Name,
					},
				})
			}
		}
		return requests
	})

The logs show multiple occurrences of Empty GVK for object ....

@liyinan926
Copy link
Contributor Author

liyinan926 commented Jan 8, 2019

Looks like #212 might have solved the issue.
UPDATE: tried version v0.1.8 of controller-runtime, which contains #212 and still have the same problem.

@DirectXMan12
Copy link
Contributor

in general, you probably want to use the scheme to get the GVK of a type, but we're trying to clean up the places where we don't set a GVK. It's pretty common throughout the code not to have a GVK set, because it's not actually needed most places in the client/apimachinery (which use Scheme instead).

@shawn-hurley
Copy link

shawn-hurley commented Jan 15, 2019

@liyinan926 I believe because #212 fixed the Get method, but did not fix the List method.

The fix I believe is in pkg/cache/internal/cache_reader.go and to update the getListItems to set the GVK based on the cache readers gvk if you're interested in working on this? Otherwise, I can take it @DirectXMan12.

@liyinan926
Copy link
Contributor Author

@shawn-hurley I can do it.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 28, 2019
@JoelSpeed
Copy link
Contributor

/remove-lifecycle stale

PR #389 is open to fix this issue

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants