-
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
Updating integration tests to test both API versions - v1beta1 and 3 #5587
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/. If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits. Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name. |
|
Thats a cool test that I didnt know existed! |
if err != nil { | ||
glog.Fatalf("Failed listing service with supplied self link '%v': %v", svc.SelfLink, err) | ||
} | ||
|
||
var svcList api.ServiceList | ||
err = c.Get().NamespaceIfScoped(namespace, len(namespace) > 0).Resource("services").Do().Into(&svcList) | ||
svcList, err := services.List(labels.Everything()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the namespacing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like its still there, but services is now ServiceNamespacer that has already been scoped to the namespace in question.
Replied to all comments. PTAL. |
@@ -65,7 +65,6 @@ import ( | |||
|
|||
// Config is a structure used to configure a Master. | |||
type Config struct { | |||
Client *client.Client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind. I see your answer above now.
LGTM. Waiting for tests. |
Shippable passed :) |
Updating integration tests to test both API versions - v1beta1 and 3
@@ -77,7 +77,13 @@ func (c *services) Get(name string) (result *api.Service, err error) { | |||
// Create creates a new service. | |||
func (c *services) Create(svc *api.Service) (result *api.Service, err error) { | |||
result = &api.Service{} | |||
err = c.r.Post().Namespace(c.ns).Resource("services").Body(svc).Do().Into(result) | |||
// v1beta3 does not allow POST without a namespace. | |||
needNamespace := !api.PreV1Beta3(c.r.APIVersion()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? I think this is a bug in higher level code, and doesn't look right here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not here, then we will need such conditions everywhere at higher level code.
If (apiVersion = v1beta3 && ns == "") {
ns = api.NamespaceDefault
}
servicesInterface = client.services(ns)
Is that better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm saying that anyone who has an empty string either got it from client input (in which case the server will catch it) or it will be caught lower in the code base. No one should be passing an empty namespace, ever. I don't think we need to test in the client (I have a pull incoming which normalizes all our clients now that the server is normalized).
----- Original Message -----
@@ -77,7 +77,13 @@ func (c *services) Get(name string) (result
*api.Service, err error) {
// Create creates a new service.
func (c *services) Create(svc *api.Service) (result *api.Service, err
error) {
result = &api.Service{}
- err =
c.r.Post().Namespace(c.ns).Resource("services").Body(svc).Do().Into(result)- // v1beta3 does not allow POST without a namespace.
- needNamespace := !api.PreV1Beta3(c.r.APIVersion())
If not here, then we will need such conditions everywhere at higher level
code.If (apiVersion = v1beta3 && ns == "") { ns = api.NamespaceDefault } servicesInterface = client.services(ns)
Is that better?
Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/5587/files#r26879365
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. What do you mean by "normalizing the server and the client"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RESTStorage objects and the api_installer now properly check a lot of the conditions. If there is client code that is allowing Namespace to be wrong when it passes to the Services code, we should either fix the client code or reject it on the server (the standard api/rest.go code should do that now).
Opened #5738 to clean some of this up.
----- Original Message -----
@@ -77,7 +77,13 @@ func (c *services) Get(name string) (result
*api.Service, err error) {
// Create creates a new service.
func (c *services) Create(svc *api.Service) (result *api.Service, err
error) {
result = &api.Service{}
- err =
c.r.Post().Namespace(c.ns).Resource("services").Body(svc).Do().Into(result)- // v1beta3 does not allow POST without a namespace.
- needNamespace := !api.PreV1Beta3(c.r.APIVersion())
ok. What do you mean by "normalizing the server and the client"?
Reply to this email directly or view it on GitHub:
https://github.com/GoogleCloudPlatform/kubernetes/pull/5587/files#r26881133
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. Thanks for the explanation!
I looked at the PR and it looks good.
Thanks for working on it.
#5475