mirror of https://github.com/k3s-io/k3s.git
Remove unnecessary listener arg from managed DB setup
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>pull/2300/head
parent
a3bbd58f37
commit
97eb28a01a
|
@ -55,7 +55,8 @@ func (c *Cluster) initClusterAndHTTPS(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
l, handler, err = c.initClusterDB(ctx, l, handler)
|
||||
// Config the cluster database and allow it to add additional request handlers
|
||||
handler, err = c.initClusterDB(ctx, handler)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -52,9 +52,10 @@ func (c *Cluster) start(ctx context.Context) error {
|
|||
return c.managedDB.Start(ctx, c.clientAccessInfo)
|
||||
}
|
||||
|
||||
func (c *Cluster) initClusterDB(ctx context.Context, l net.Listener, handler http.Handler) (net.Listener, http.Handler, error) {
|
||||
// initClusterDB registers routes for database info with the http request handler
|
||||
func (c *Cluster) initClusterDB(ctx context.Context, handler http.Handler) (http.Handler, error) {
|
||||
if c.managedDB == nil {
|
||||
return l, handler, nil
|
||||
return handler, nil
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(c.config.Datastore.Endpoint, c.managedDB.EndpointName()+"://") {
|
||||
|
@ -63,7 +64,7 @@ func (c *Cluster) initClusterDB(ctx context.Context, l net.Listener, handler htt
|
|||
}
|
||||
}
|
||||
|
||||
return c.managedDB.Register(ctx, c.config, l, handler)
|
||||
return c.managedDB.Register(ctx, c.config, handler)
|
||||
}
|
||||
|
||||
func (c *Cluster) assignManagedDriver(ctx context.Context) error {
|
||||
|
|
|
@ -2,7 +2,6 @@ package managed
|
|||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/rancher/k3s/pkg/clientaccess"
|
||||
|
@ -16,7 +15,7 @@ var (
|
|||
|
||||
type Driver interface {
|
||||
IsInitialized(ctx context.Context, config *config.Control) (bool, error)
|
||||
Register(ctx context.Context, config *config.Control, l net.Listener, handler http.Handler) (net.Listener, http.Handler, error)
|
||||
Register(ctx context.Context, config *config.Control, handler http.Handler) (http.Handler, error)
|
||||
Reset(ctx context.Context, clientAccessInfo *clientaccess.Info) error
|
||||
Start(ctx context.Context, clientAccessInfo *clientaccess.Info) error
|
||||
Test(ctx context.Context, clientAccessInfo *clientaccess.Info) error
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
@ -276,20 +275,20 @@ func (e *ETCD) join(ctx context.Context, clientAccessInfo *clientaccess.Info) er
|
|||
})
|
||||
}
|
||||
|
||||
// Register configures a new etcd client and adds db info routes for the http listener.
|
||||
func (e *ETCD) Register(ctx context.Context, config *config.Control, l net.Listener, handler http.Handler) (net.Listener, http.Handler, error) {
|
||||
// Register configures a new etcd client and adds db info routes for the http request handler.
|
||||
func (e *ETCD) Register(ctx context.Context, config *config.Control, handler http.Handler) (http.Handler, error) {
|
||||
e.config = config
|
||||
e.runtime = config.Runtime
|
||||
|
||||
client, err := getClient(ctx, e.runtime, endpoint)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
e.client = client
|
||||
|
||||
address, err := getAdvertiseAddress(config.AdvertiseIP)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
e.address = address
|
||||
|
||||
|
@ -299,10 +298,10 @@ func (e *ETCD) Register(ctx context.Context, config *config.Control, l net.Liste
|
|||
e.config.Datastore.Config.KeyFile = e.runtime.ClientETCDKey
|
||||
|
||||
if err := e.setName(false); err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return l, e.handler(handler), err
|
||||
return e.handler(handler), err
|
||||
}
|
||||
|
||||
// setName sets a unique name for this cluster member. The first time this is called,
|
||||
|
|
Loading…
Reference in New Issue