-
Notifications
You must be signed in to change notification settings - Fork 492
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
Scope in object references may be unnecessary #838
Comments
This was also raised by @danwinship in #780 (comment).
|
I think this is mostly about clarity. Nil namespace could potentially imply the same namespace. Because there is a major distinction between namespace-level and cluster-level resources, the additional clarity at the cost of verbosity could be helpful to the end user, who may not always remember the scope of each resource (unless the resource names have the required context (like ClusterRole). I think this is one of those areas where historical design decision should not be used to justify the choice we make in the present. |
I disagree - if the user does not remember the scope of the type, requiring it is the opposite of what we want - that means that there is a blocker to the user using the API. There is already substantial prior art here with kubectl and the api-server. Users are NOT expected to need to know if the resource is cluster/scoped today - they can get resources and even create resources with or without a namespace, not worrying about "scope". By adding the Scope we field we make the user do something the computer already can do. Aside from being annyoing and adding additional cognitize complexity, it also introduces more errors. See https://khalilstemmler.com/articles/typescript-domain-driven-design/make-illegal-states-unrepresentable for some more discussion on this. I cannot see why as user would want to set this field. Its a bit equivalent to requiring a |
John, I see your point. This is asking the user to do more than necessary. I'm still ruminating on what is the right balance here. Would love to hear more thoughts. |
Given that this discussion is about That said, if we do want to allow it, I think having the Kind work the same way as kubectl make sense, as @howardjohn said originally. If the namespace is unspecified, it means a cluster-scoped reference if the Kind is cluster-scoped, and the same namespace if the Kind is namespaced. That's actually a pretty safe default because a cross-namespace reference to a non-cluster-scoped object will require the equivalent of a ReferencePolicy on the parent object anyway. I just don't see that having the Scope specified really adds that much. I think that specifying the Kind is enough. |
I tried to look back through the GEP, and I can't find a clear motivation for a cluster-scoped parent ref. I think I'd originally considered that as a way to target potential cluster-scoped mesh resources. Although that could still be relevant, I'm not sure we have a clear use for it today. The in-progress mesh implementations I'm aware of right now are actually planning on a namespace-scoped resource at this level, so I think we may not actually need to support cluster-scoped parent resources, at least not yet. If anyone has a use case for cluster-scoped route parents, I think that could be a compelling reason to leave the cluster-scoped ref option in place. Otherwise, the simplest way to resolve this may just be to remove scope and require namespace in ParentRef. |
@lavalamp If I'm remembering correctly, the rationale for |
If the scope is known, then yes, remove the field (and add a schema annotation when/if those become a thing). |
Thanks @lavalamp! What would a "schema annotation" look like here? |
The idea is that we'd put an annotation in the schema to state all the items of an object reference that happen to be constant, so tools can also follow the references. It looks like we haven't published this idea yet, though. |
As a follow up from @howardjohn's v1alpha2 feedback in #790:
The text was updated successfully, but these errors were encountered: