Skip to content

Fix project request quota - #5454

Merged
openshift-bot merged 2 commits into
openshift:masterfrom
deads2k:fix-project-request-quota
Oct 29, 2015
Merged

openshift-bot merged 2 commits into
openshift:masterfrom
deads2k:fix-project-request-quota

Conversation

@deads2k

@deads2k deads2k commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1275001

[ResourceQuota in version v1beta3 cannot be handled as a ResourceQuota: The apiVersion in the data (v1beta3) does not match the specified apiVersion(v1), LimitRange in version v1beta3 cannot 
be handled as a LimitRange: The apiVersion in the data (v1beta3) does not match the specified apiVersion(v1)]

@deads2k

deads2k commented Oct 28, 2015

Copy link
Copy Markdown
Contributor Author

Before I finish updating unit tests, this is happening because the codec used for serializing the object is not the same as the codec used in the RESTClient for submission. This commit here deads2k@434636a would make it match. I'm hard pressed to think of a reason to know the correct codec for the URL we're POSTing to and not using it.

@ironcladlou You had a similar problem during v1beta3 disablement, does this seem reasonable?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can pass in a runtime.Object to Request.Body(), and it gets encoded using the RESTClient's codec, right? That seems preferable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can pass in a runtime.Object to Request.Body(), and it gets encoded using the RESTClient's codec, right? That seems preferable

For this case in particular, probably, but I'm disinclined to have a second spot where we build the URL unless you feel pretty strongly.

You agree on principle, but want a refactor of the method overall?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't like adding GetCodec() to the RESTClient interface... passing the object into Body lets you leave the responsibility for encoding in the RESTClient's hands

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't like adding GetCodec() to the RESTClient interface... passing the object into Body lets you leave the responsibility for encoding in the RESTClient's hands

I don't like the sig func (m *Helper) Create(namespace string, modify bool, data []byte) either, but changing it to func (m *Helper) Create(namespace string, modify bool, data interface{}) is more that I'd really like to change here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the sig func (m *Helper) Create(namespace string, modify bool, data []byte) either, but changing it to func (m *Helper) Create(namespace string, modify bool, data interface{}) is more that I'd really like to change here

Especially since someone (@smarterclayton) thought about this upstream and decided that passing through straight []byte was the proper way to build the API. They went to some effort to make that happen.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so leave that alone for now and just refactor the internal createResource/replaceResource methods to take an interface{}, which lets you pass through the []byte, or pass the decoded runtime.Object when modify is true. The helper's codec then is only used for decoding in order to set resourceVersion when modify is true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so leave that alone for now and just refactor the internal createResource/replaceResource methods to take an interface{}, which lets you pass through the []byte, or pass the decoded runtime.Object when modify is true. The helper's codec then is only used for decoding in order to set version when modify is true

That leaves me exposing GetCodec to make the rest work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the original pattern from the original implementation. It's never
been important enough to change.

On Wed, Oct 28, 2015 at 10:46 AM, David Eads [email protected]
wrote:

In Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource/helper.go
#5454 (comment):

@@ -117,7 +117,7 @@ func (m *Helper) Create(namespace string, modify bool, data []byte) (runtime.Obj
if err := m.Versioner.SetResourceVersion(obj, ""); err != nil {
return nil, err
}

  •       newData, err := m.Codec.Encode(obj)
    
  •       newData, err := m.RESTClient.GetCodec().Encode(obj)
    

I don't like the sig func (m *Helper) Create(namespace string, modify
bool, data []byte) either, but changing it to func (m *Helper)
Create(namespace string, modify bool, data interface{}) is more that I'd
really like to change here

Especially since someone (@smarterclayton
https://github.com/smarterclayton) thought about this upstream and
decided that passing through straight []byte was the proper way to build
the API. They went to some effort to make that happen.

—
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/5454/files#r43264340.

@deads2k
deads2k force-pushed the fix-project-request-quota branch from d4f3e5d to 7f36aad Compare October 28, 2015 17:29
@deads2k deads2k changed the title [WIP] Fix project request quota Fix project request quota Oct 28, 2015

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess all the new-project calls test the default template well enough

@liggitt

liggitt commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

[test]

@openshift-bot

Copy link
Copy Markdown
Contributor

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 7f36aad

@ironcladlou

Copy link
Copy Markdown
Contributor

Makes sense to me. It was never clear to me why it was necessary to sling []bytes and do decoding outside of the RESTClient.

@smarterclayton

Copy link
Copy Markdown
Contributor

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/6315/) (Image: devenv-rhel7_2589)

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 7f36aad

openshift-bot pushed a commit that referenced this pull request Oct 29, 2015
@openshift-bot
openshift-bot merged commit 65f8f98 into openshift:master Oct 29, 2015
@pweil- pweil- mentioned this pull request Oct 31, 2015
@deads2k
deads2k deleted the fix-project-request-quota branch November 5, 2015 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants