mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
return EtcdErrorNodeExist when Create is called for existing node
This commit is contained in:
parent
d46bfcb132
commit
ccb7e8793b
@ -30,11 +30,13 @@ import (
|
||||
|
||||
const (
|
||||
EtcdErrorCodeNotFound = 100
|
||||
EtcdErrorCodeNodeExist = 105
|
||||
EtcdErrorCodeValueRequired = 200
|
||||
)
|
||||
|
||||
var (
|
||||
EtcdErrorNotFound = &etcd.EtcdError{ErrorCode: EtcdErrorCodeNotFound}
|
||||
EtcdErrorNodeExist = &etcd.EtcdError{ErrorCode: EtcdErrorCodeNodeExist}
|
||||
EtcdErrorValueRequired = &etcd.EtcdError{ErrorCode: EtcdErrorCodeValueRequired}
|
||||
)
|
||||
|
||||
|
@ -137,11 +137,16 @@ func (f *FakeEtcdClient) CompareAndSwap(key, value string, ttl uint64, prevValue
|
||||
}
|
||||
|
||||
func (f *FakeEtcdClient) Create(key, value string, ttl uint64) (*etcd.Response, error) {
|
||||
if prevResult, ok := f.Data[key]; ok && prevResult.R != nil && prevResult.R.Node != nil {
|
||||
return nil, EtcdErrorNodeExist
|
||||
}
|
||||
|
||||
return f.Set(key, value, ttl)
|
||||
}
|
||||
|
||||
func (f *FakeEtcdClient) Delete(key string, recursive bool) (*etcd.Response, error) {
|
||||
if f.Err != nil {
|
||||
return f.Err
|
||||
return nil, f.Err
|
||||
}
|
||||
|
||||
f.Data[key] = EtcdResponseWithError{
|
||||
|
Loading…
Reference in New Issue
Block a user