mirror of https://github.com/k3s-io/k3s
Print a helpful error when trying to join additional servers but etcd is not in use
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 5b2c14b123
)
pull/5480/head
parent
e7fbd6f18e
commit
66ed08c843
|
@ -69,9 +69,7 @@ func router(ctx context.Context, config *Config, cfg *cmds.Server) http.Handler
|
|||
serverAuthed.Path(prefix + "/encrypt/status").Handler(encryptionStatusHandler(serverConfig))
|
||||
serverAuthed.Path(prefix + "/encrypt/config").Handler(encryptionConfigHandler(ctx, serverConfig))
|
||||
serverAuthed.Path("/db/info").Handler(nodeAuthed)
|
||||
if serverConfig.Runtime.HTTPBootstrap {
|
||||
serverAuthed.Path(prefix + "/server-bootstrap").Handler(bootstrap.Handler(&serverConfig.Runtime.ControlRuntimeBootstrap))
|
||||
}
|
||||
serverAuthed.Path(prefix + "/server-bootstrap").Handler(bootstrapHandler(serverConfig.Runtime))
|
||||
|
||||
staticDir := filepath.Join(serverConfig.DataDir, "static")
|
||||
router := mux.NewRouter()
|
||||
|
@ -107,6 +105,20 @@ func apiserverDisabled() http.Handler {
|
|||
})
|
||||
}
|
||||
|
||||
func bootstrapHandler(runtime *config.ControlRuntime) http.Handler {
|
||||
if runtime.HTTPBootstrap {
|
||||
return bootstrap.Handler(&runtime.ControlRuntimeBootstrap)
|
||||
}
|
||||
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
|
||||
logrus.Warnf("Received HTTP bootstrap request from %s, but embedded etcd is not enabled.", req.RemoteAddr)
|
||||
data := []byte("etcd disabled")
|
||||
resp.WriteHeader(http.StatusBadRequest)
|
||||
resp.Header().Set("Content-Type", "text/plain")
|
||||
resp.Header().Set("Content-length", strconv.Itoa(len(data)))
|
||||
resp.Write(data)
|
||||
})
|
||||
}
|
||||
|
||||
func cacerts(serverCA string) http.Handler {
|
||||
var ca []byte
|
||||
return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
|
||||
|
|
Loading…
Reference in New Issue