Skip to content

Commit

Permalink
Merge pull request kubernetes#18136 from nikhiljindal/del-new-etcd-st…
Browse files Browse the repository at this point in the history
…orage

Auto commit by PR queue bot
  • Loading branch information
k8s-merge-robot committed Dec 3, 2015
2 parents 5afc5e5 + 5c556ba commit 6479f5e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 326 deletions.
9 changes: 7 additions & 2 deletions cmd/kube-apiserver/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"k8s.io/kubernetes/pkg/master"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/storage"
etcdstorage "k8s.io/kubernetes/pkg/storage/etcd"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/util"
forked "k8s.io/kubernetes/third_party/forked/coreos/go-etcd/etcd"
Expand Down Expand Up @@ -306,8 +307,12 @@ func newEtcd(etcdConfigFile string, etcdServerList []string, interfacesFunc meta
etcdClient.SetTransport(transport)
client = etcdClient
}
etcdStorage, err = master.NewEtcdStorage(client, interfacesFunc, storageVersion, pathPrefix)
return etcdStorage, err
versionedInterface, err := interfacesFunc(storageVersion)
if err != nil {
return nil, err
}
etcdStorage = etcdstorage.NewEtcdStorage(client, versionedInterface.Codec, pathPrefix)
return etcdStorage, nil
}

// convert to a map between group and groupVersions.
Expand Down
13 changes: 0 additions & 13 deletions pkg/master/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"k8s.io/kubernetes/pkg/admission"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/unversioned"
apiutil "k8s.io/kubernetes/pkg/api/util"
Expand Down Expand Up @@ -75,9 +74,7 @@ import (
"k8s.io/kubernetes/pkg/registry/thirdpartyresourcedata"
thirdpartyresourcedataetcd "k8s.io/kubernetes/pkg/registry/thirdpartyresourcedata/etcd"
"k8s.io/kubernetes/pkg/storage"
etcdstorage "k8s.io/kubernetes/pkg/storage/etcd"
etcdutil "k8s.io/kubernetes/pkg/storage/etcd/util"
"k8s.io/kubernetes/pkg/tools"
"k8s.io/kubernetes/pkg/ui"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
Expand Down Expand Up @@ -349,16 +346,6 @@ type Master struct {
KubernetesServiceNodePort int
}

// NewEtcdStorage returns a storage.Interface for the provided arguments or an error if the version
// is incorrect.
func NewEtcdStorage(client tools.EtcdClient, interfacesFunc meta.VersionInterfacesFunc, version, prefix string) (etcdStorage storage.Interface, err error) {
versionInterfaces, err := interfacesFunc(version)
if err != nil {
return etcdStorage, err
}
return etcdstorage.NewEtcdStorage(client, versionInterfaces.Codec, prefix), nil
}

// setDefaults fills in any fields not set that are required to have valid data.
func setDefaults(c *Config) {
if c.ServiceClusterIPRange == nil {
Expand Down
19 changes: 0 additions & 19 deletions pkg/master/master_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net"
Expand All @@ -32,7 +31,6 @@ import (

"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/latest"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
apiutil "k8s.io/kubernetes/pkg/api/util"
Expand Down Expand Up @@ -125,23 +123,6 @@ func TestNew(t *testing.T) {
assert.Equal(master.proxyTransport.(*http.Transport).TLSClientConfig, config.ProxyTLSClientConfig)
}

// TestNewEtcdStorage verifies that the usage of NewEtcdStorage reacts properly when
// the correct data is input
func TestNewEtcdStorage(t *testing.T) {
etcdserver := etcdtesting.NewEtcdTestClientServer(t)
defer etcdserver.Terminate(t)

assert := assert.New(t)
// Pass case
_, err := NewEtcdStorage(etcdserver.Client, latest.GroupOrDie("").InterfacesFor, testapi.Default.Version(), etcdtest.PathPrefix())
assert.NoError(err, "Unable to create etcdstorage: %s", err)

// Fail case
errorFunc := func(apiVersion string) (*meta.VersionInterfaces, error) { return nil, errors.New("ERROR") }
_, err = NewEtcdStorage(etcdserver.Client, errorFunc, testapi.Default.Version(), etcdtest.PathPrefix())
assert.Error(err, "NewEtcdStorage should have failed")
}

// TestGetServersToValidate verifies the unexported getServersToValidate function
func TestGetServersToValidate(t *testing.T) {
master, etcdserver, config, assert := setUp(t)
Expand Down
Loading

0 comments on commit 6479f5e

Please sign in to comment.