Commit 100f4d19 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Pass context in to embedded etcd so that it can be stopped

Partial cherry-pick from 29c8b238Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent 4fa89524
......@@ -4,6 +4,7 @@
package executor
import (
"context"
"io/ioutil"
"path/filepath"
"strings"
......@@ -18,7 +19,7 @@ func (e Embedded) CurrentETCDOptions() (InitialOptions, error) {
return InitialOptions{}, nil
}
func (e Embedded) ETCD(args ETCDConfig, extraArgs []string) error {
func (e Embedded) ETCD(ctx context.Context, args ETCDConfig, extraArgs []string) error {
configFile, err := args.ToConfigFile(extraArgs)
if err != nil {
return err
......@@ -45,6 +46,9 @@ func (e Embedded) ETCD(args ETCDConfig, extraArgs []string) error {
return
}
case <-ctx.Done():
logrus.Infof("stopping etcd")
etcd.Close()
case <-etcd.Server.StopNotify():
logrus.Fatalf("etcd stopped")
case err := <-etcd.Err():
......
......@@ -30,7 +30,7 @@ type Executor interface {
Scheduler(apiReady <-chan struct{}, args []string) error
ControllerManager(apiReady <-chan struct{}, args []string) error
CurrentETCDOptions() (InitialOptions, error)
ETCD(args ETCDConfig, extraArgs []string) error
ETCD(ctx context.Context, args ETCDConfig, extraArgs []string) error
CloudControllerManager(ccmRBACReady <-chan struct{}, args []string) error
}
......@@ -161,8 +161,8 @@ func CurrentETCDOptions() (InitialOptions, error) {
return executor.CurrentETCDOptions()
}
func ETCD(args ETCDConfig, extraArgs []string) error {
return executor.ETCD(args, extraArgs)
func ETCD(ctx context.Context, args ETCDConfig, extraArgs []string) error {
return executor.ETCD(ctx, args, extraArgs)
}
func CloudControllerManager(ccmRBACReady <-chan struct{}, args []string) error {
......
......@@ -616,7 +616,7 @@ func (e *ETCD) metricsURL(expose bool) string {
// cluster returns ETCDConfig for a cluster
func (e *ETCD) cluster(ctx context.Context, forceNew bool, options executor.InitialOptions) error {
return executor.ETCD(executor.ETCDConfig{
return executor.ETCD(ctx, executor.ETCDConfig{
Name: e.name,
InitialOptions: options,
ForceNewCluster: forceNew,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment