-
Notifications
You must be signed in to change notification settings - Fork 40k
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
generic etcd should surface ctx/obj namespace mismatches #5684
Comments
Doesn't a KeyFunc handle this already with meta.namespacekeyfunc Sent from my iPhone
|
It doesn't take the namespace from the objectmeta, it just takes strings and the context (https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/registry/generic/etcd/etcd.go#L117). So essentially it grabs the namespace from the ctx, the name from the object (via ObjectNameFunc) and constructs the path to the resource using the prefix specified in the constructor (eg: /registry/pods). In my second example, it would construct something like I need it to barf saying the ctx.namespace != obj.Namespace upfront. This happens automatically later in the call graph but that code will never really execute because something else will give up. Unless I misunderstood what you meant by meta.namespacekeyfunc, do you mean define one? |
Sorry. Was referring to here: https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/registry/generic/etcd/etcd.go#L119 Sent from my iPhone
|
Ah, yes that's the ns on the context, i'd like to compare that against the ns on the objectmeta of the update payload. |
Seems like we could do something in validation.go in the object meta update possibly. Sent from my iPhone
|
Yeah,
I would expect a |
Currently its hard to surface a mismatch context in an update via generic etcd. If I do something like:
it will fail in the
get
with whatever go-etcd error, because the path /invalid/objname doesn't exist; and if i do:it will fail with a resource version mismatch (so
NewConflict
), because the get will return the object in/valid_different/objname
, but its resource version is different.Ideally both these cases should fail with a
NewBadRequest
. This would happen if the validation flow reachesBeforeUpdate
, but it fails due to the mentioned checks earlier in the callstack. To catch both cases we probably need to refactor the namespace checking out ofBeforeCreate
andBeforeUpdate
into a common location and call it from generic/etcd.update.The text was updated successfully, but these errors were encountered: