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

Return standard API errors from etcd registry by operation #1192

Merged
merged 1 commit into from
Sep 8, 2014

Conversation

smarterclayton
Copy link
Contributor

Adds pkg/api/errors/etcd, which defines default conversions
for common CRUD operations from etcd to api.

@erictune
Copy link
Member

erictune commented Sep 8, 2014

LGTM for correctness.

Thoughts on naming: etcd.ErrorForCreate(...) reads like the function call is making an "etcd Error". But it is making an API error from and etcd error. If you put your new code in the parent package, and rename the functions, it would read better, to my eye. For example errors.FromEtcdError(r.assignPod(binding.PodID, binding.Host), "CREATE", "binding", "")

Even better (though out of scope for this PR), if errors was renamed to error, then: error.FromEtcdError(...)

@smarterclayton
Copy link
Contributor Author

I didn't want to put it in the parent package because I don't think etcd is special in this context - only an etcd registry impl ever needs to know about them.

etcd.CreateErrorFrom(err error)? etcd.ErrorOnCreate(err error)?

@lavalamp
Copy link
Member

lavalamp commented Sep 8, 2014

I'd suggest the naming pattern "InterpretXError". I also think the pattern should be that sub packages (like etcd) register error interpretation handlers with the main errors package. @smarterclayton did convince me that we need separate handlers for each of the REST operations, though.

@smarterclayton
Copy link
Contributor Author

I guess I don't see enough overlap between registry implementations to justify having a central registry / handler pattern. Etcd errors should never make it out of the Registry interface, much less to storage or clients.

@smarterclayton smarterclayton force-pushed the standardize_etcd_errors branch from 2c305ef to e001059 Compare September 8, 2014 20:21
@smarterclayton
Copy link
Contributor Author

Renamed with InterpretXError, still holding out against making a central registry of this vs just being domain specific helpers.

@@ -20,7 +20,7 @@ import (
"fmt"

"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd"
Copy link
Member

Choose a reason for hiding this comment

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

Can you import this under a different name? I find it confusing to have an etcd package imported into this etcd package that isn't the real etcd package.

@lavalamp
Copy link
Member

lavalamp commented Sep 8, 2014

ok, LGTM after import rename :)

Adds pkg/api/errors/etcd, which defines default conversions
for common CRUD operations from etcd to api.
@smarterclayton smarterclayton force-pushed the standardize_etcd_errors branch from e001059 to 3ffe259 Compare September 8, 2014 22:46
@smarterclayton
Copy link
Contributor Author

Import renamed

lavalamp added a commit that referenced this pull request Sep 8, 2014
Return standard API errors from etcd registry by operation
@lavalamp lavalamp merged commit 41754f5 into kubernetes:master Sep 8, 2014
@smarterclayton smarterclayton deleted the standardize_etcd_errors branch February 11, 2015 02:21
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.

3 participants