Commit 77846d63 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Propagate errors up from config.Get

Fixes crash when killing agent while waiting for config from server Signed-off-by: 's avatarBrad Davidson <brad.davidson@rancher.com>
parent 16d29398
...@@ -48,8 +48,8 @@ const ( ...@@ -48,8 +48,8 @@ const (
// so this is somewhat computationally expensive on the server side, and is retried with jitter // so this is somewhat computationally expensive on the server side, and is retried with jitter
// to avoid having clients hammer on the server at fixed periods. // to avoid having clients hammer on the server at fixed periods.
// A call to this will bock until agent configuration is successfully returned by the // A call to this will bock until agent configuration is successfully returned by the
// server. // server, or the context is cancelled.
func Get(ctx context.Context, agent cmds.Agent, proxy proxy.Proxy) *config.Node { func Get(ctx context.Context, agent cmds.Agent, proxy proxy.Proxy) (*config.Node, error) {
var agentConfig *config.Node var agentConfig *config.Node
var err error var err error
...@@ -65,7 +65,7 @@ func Get(ctx context.Context, agent cmds.Agent, proxy proxy.Proxy) *config.Node ...@@ -65,7 +65,7 @@ func Get(ctx context.Context, agent cmds.Agent, proxy proxy.Proxy) *config.Node
cancel() cancel()
} }
}, 5*time.Second, 1.0, true) }, 5*time.Second, 1.0, true)
return agentConfig return agentConfig, err
} }
// KubeProxyDisabled returns a bool indicating whether or not kube-proxy has been disabled in the // KubeProxyDisabled returns a bool indicating whether or not kube-proxy has been disabled in the
......
...@@ -52,7 +52,10 @@ import ( ...@@ -52,7 +52,10 @@ import (
) )
func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error { func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error {
nodeConfig := config.Get(ctx, cfg, proxy) nodeConfig, err := config.Get(ctx, cfg, proxy)
if err != nil {
return errors.Wrap(err, "failed to retrieve agent configuration")
}
dualCluster, err := utilsnet.IsDualStackCIDRs(nodeConfig.AgentConfig.ClusterCIDRs) dualCluster, err := utilsnet.IsDualStackCIDRs(nodeConfig.AgentConfig.ClusterCIDRs)
if err != nil { if err != nil {
...@@ -234,7 +237,11 @@ func RunStandalone(ctx context.Context, cfg cmds.Agent) error { ...@@ -234,7 +237,11 @@ func RunStandalone(ctx context.Context, cfg cmds.Agent) error {
return err return err
} }
nodeConfig := config.Get(ctx, cfg, proxy) nodeConfig, err := config.Get(ctx, cfg, proxy)
if err != nil {
return errors.Wrap(err, "failed to retrieve agent configuration")
}
if err := executor.Bootstrap(ctx, nodeConfig, cfg); err != nil { if err := executor.Bootstrap(ctx, nodeConfig, cfg); err != nil {
return err return err
} }
......
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