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

Unknown namespace for the cache error while Getting cluster scoped for MultiNamespacedCache #1378

Closed
vinod-patil opened this issue Feb 9, 2021 · 6 comments · Fixed by #1418
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.

Comments

@vinod-patil
Copy link

vinod-patil commented Feb 9, 2021

While using MultiNamespacedCache with manager, if we try to get a cluster scoped resource as
cluster scoped resource doesn't have any namespace (empty namespace), it's returning unknown namespace error

func (c *multiNamespaceCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error {
	cache, ok := c.namespaceToCache[key.Namespace]
	if !ok {
		return fmt.Errorf("unable to get: %v because of unknown namespace for the cache", key)
	}
	return cache.Get(ctx, key, obj)
}
@alvaroaleman
Copy link
Member

/kind bug
/help

@k8s-ci-robot
Copy link
Contributor

@alvaroaleman:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/kind bug
/help

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 kind/bug Categorizes issue or PR as related to a bug. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Feb 16, 2021
@varshaprasad96
Copy link
Member

@alvaroaleman, would this be the right approach to solve the issue with cluster scoped objects:

  1. In namespaceToCache mapping, we add an entry for a mapping between no namespace and global cache (say an empty string as the key). When there is no namespace provided in the object key, we call the global cache to get the cluster scoped object.
  2. In case of listing the objects in multinamespace cache - if listOptions does provide anything, we call the global cache, without any specified namespace to list the objects. Currently, by default if namespace is not provided we are looking for objects across all namespaces and listing them.

Maybe we can have a separate const defined for multiNamespaceCache to identify a "no namespace" condition.

cc: @estroz

@estroz
Copy link
Contributor

estroz commented Feb 25, 2021

One problem that will likely result in a breaking change comes from point (2). As @varshaprasad96 alluded to, listOpts.Namespace == corev1.NamespaceAll means "only look up objects within the known namespace set", even though looking up objects across all namespaces/cluster scoped objects is still allowed via a multiNamespaceCache. That will probably have to change.

@madhurtrilio
Copy link

Having same issue. Any tentative timelines on when this will be fixed?

@alvaroaleman
Copy link
Member

@madhurtrilio #1418 will fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
6 participants