Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
65c381bf
Commit
65c381bf
authored
Nov 25, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide internal etcd errors.
parent
e95e3dec
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
29 deletions
+24
-29
etcd_util.go
pkg/storage/etcd/util/etcd_util.go
+23
-6
etcd_util_test.go
pkg/storage/etcd/util/etcd_util_test.go
+1
-5
interfaces.go
pkg/tools/interfaces.go
+0
-18
No files found.
pkg/storage/etcd/util/etcd_util.go
View file @
65c381bf
...
@@ -23,32 +23,49 @@ import (
...
@@ -23,32 +23,49 @@ import (
"net/http"
"net/http"
goetcd
"github.com/coreos/go-etcd/etcd"
goetcd
"github.com/coreos/go-etcd/etcd"
"k8s.io/kubernetes/pkg/tools"
)
const
(
etcdErrorCodeNotFound
=
100
etcdErrorCodeTestFailed
=
101
etcdErrorCodeNodeExist
=
105
etcdErrorCodeValueRequired
=
200
etcdErrorCodeWatchExpired
=
401
etcdErrorCodeUnreachable
=
501
)
var
(
etcdErrorNotFound
=
&
goetcd
.
EtcdError
{
ErrorCode
:
etcdErrorCodeNotFound
}
etcdErrorTestFailed
=
&
goetcd
.
EtcdError
{
ErrorCode
:
etcdErrorCodeTestFailed
}
etcdErrorNodeExist
=
&
goetcd
.
EtcdError
{
ErrorCode
:
etcdErrorCodeNodeExist
}
etcdErrorValueRequired
=
&
goetcd
.
EtcdError
{
ErrorCode
:
etcdErrorCodeValueRequired
}
etcdErrorWatchExpired
=
&
goetcd
.
EtcdError
{
ErrorCode
:
etcdErrorCodeWatchExpired
}
etcdErrorUnreachable
=
&
goetcd
.
EtcdError
{
ErrorCode
:
etcdErrorCodeUnreachable
}
)
)
// IsEtcdNotFound returns true if and only if err is an etcd not found error.
// IsEtcdNotFound returns true if and only if err is an etcd not found error.
func
IsEtcdNotFound
(
err
error
)
bool
{
func
IsEtcdNotFound
(
err
error
)
bool
{
return
isEtcdErrorNum
(
err
,
tools
.
E
tcdErrorCodeNotFound
)
return
isEtcdErrorNum
(
err
,
e
tcdErrorCodeNotFound
)
}
}
// IsEtcdNodeExist returns true if and only if err is an etcd node already exist error.
// IsEtcdNodeExist returns true if and only if err is an etcd node already exist error.
func
IsEtcdNodeExist
(
err
error
)
bool
{
func
IsEtcdNodeExist
(
err
error
)
bool
{
return
isEtcdErrorNum
(
err
,
tools
.
E
tcdErrorCodeNodeExist
)
return
isEtcdErrorNum
(
err
,
e
tcdErrorCodeNodeExist
)
}
}
// IsEtcdTestFailed returns true if and only if err is an etcd write conflict.
// IsEtcdTestFailed returns true if and only if err is an etcd write conflict.
func
IsEtcdTestFailed
(
err
error
)
bool
{
func
IsEtcdTestFailed
(
err
error
)
bool
{
return
isEtcdErrorNum
(
err
,
tools
.
E
tcdErrorCodeTestFailed
)
return
isEtcdErrorNum
(
err
,
e
tcdErrorCodeTestFailed
)
}
}
// IsEtcdWatchExpired returns true if and only if err indicates the watch has expired.
// IsEtcdWatchExpired returns true if and only if err indicates the watch has expired.
func
IsEtcdWatchExpired
(
err
error
)
bool
{
func
IsEtcdWatchExpired
(
err
error
)
bool
{
return
isEtcdErrorNum
(
err
,
tools
.
E
tcdErrorCodeWatchExpired
)
return
isEtcdErrorNum
(
err
,
e
tcdErrorCodeWatchExpired
)
}
}
// IsEtcdUnreachable returns true if and only if err indicates the server could not be reached.
// IsEtcdUnreachable returns true if and only if err indicates the server could not be reached.
func
IsEtcdUnreachable
(
err
error
)
bool
{
func
IsEtcdUnreachable
(
err
error
)
bool
{
return
isEtcdErrorNum
(
err
,
tools
.
E
tcdErrorCodeUnreachable
)
return
isEtcdErrorNum
(
err
,
e
tcdErrorCodeUnreachable
)
}
}
// isEtcdErrorNum returns true if and only if err is an etcd error, whose errorCode matches errorCode
// isEtcdErrorNum returns true if and only if err is an etcd error, whose errorCode matches errorCode
...
...
pkg/storage/etcd/util/etcd_util_test.go
View file @
65c381bf
...
@@ -28,10 +28,6 @@ import (
...
@@ -28,10 +28,6 @@ import (
"github.com/coreos/go-etcd/etcd"
"github.com/coreos/go-etcd/etcd"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
// TODO: once fakeClient has been purged move utils
// and eliminate these deps
"k8s.io/kubernetes/pkg/tools"
)
)
const
validEtcdVersion
=
"etcd 2.0.9"
const
validEtcdVersion
=
"etcd 2.0.9"
...
@@ -42,7 +38,7 @@ func TestIsEtcdNotFound(t *testing.T) {
...
@@ -42,7 +38,7 @@ func TestIsEtcdNotFound(t *testing.T) {
t
.
Errorf
(
"Expected %#v to return %v, but it did not"
,
err
,
isNotFound
)
t
.
Errorf
(
"Expected %#v to return %v, but it did not"
,
err
,
isNotFound
)
}
}
}
}
try
(
tools
.
E
tcdErrorNotFound
,
true
)
try
(
e
tcdErrorNotFound
,
true
)
try
(
&
etcd
.
EtcdError
{
ErrorCode
:
101
},
false
)
try
(
&
etcd
.
EtcdError
{
ErrorCode
:
101
},
false
)
try
(
nil
,
false
)
try
(
nil
,
false
)
try
(
fmt
.
Errorf
(
"some other kind of error"
),
false
)
try
(
fmt
.
Errorf
(
"some other kind of error"
),
false
)
...
...
pkg/tools/interfaces.go
View file @
65c381bf
...
@@ -20,24 +20,6 @@ import (
...
@@ -20,24 +20,6 @@ import (
"github.com/coreos/go-etcd/etcd"
"github.com/coreos/go-etcd/etcd"
)
)
const
(
EtcdErrorCodeNotFound
=
100
EtcdErrorCodeTestFailed
=
101
EtcdErrorCodeNodeExist
=
105
EtcdErrorCodeValueRequired
=
200
EtcdErrorCodeWatchExpired
=
401
EtcdErrorCodeUnreachable
=
501
)
var
(
EtcdErrorNotFound
=
&
etcd
.
EtcdError
{
ErrorCode
:
EtcdErrorCodeNotFound
}
EtcdErrorTestFailed
=
&
etcd
.
EtcdError
{
ErrorCode
:
EtcdErrorCodeTestFailed
}
EtcdErrorNodeExist
=
&
etcd
.
EtcdError
{
ErrorCode
:
EtcdErrorCodeNodeExist
}
EtcdErrorValueRequired
=
&
etcd
.
EtcdError
{
ErrorCode
:
EtcdErrorCodeValueRequired
}
EtcdErrorWatchExpired
=
&
etcd
.
EtcdError
{
ErrorCode
:
EtcdErrorCodeWatchExpired
}
EtcdErrorUnreachable
=
&
etcd
.
EtcdError
{
ErrorCode
:
EtcdErrorCodeUnreachable
}
)
// EtcdClient is an injectable interface for testing.
// EtcdClient is an injectable interface for testing.
type
EtcdClient
interface
{
type
EtcdClient
interface
{
GetCluster
()
[]
string
GetCluster
()
[]
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment