mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Propagate errors up from config.Get
Fixes crash when killing agent while waiting for config from server Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
parent
16d29398ad
commit
77846d63c1
@ -48,8 +48,8 @@ const (
|
||||
// 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.
|
||||
// A call to this will bock until agent configuration is successfully returned by the
|
||||
// server.
|
||||
func Get(ctx context.Context, agent cmds.Agent, proxy proxy.Proxy) *config.Node {
|
||||
// server, or the context is cancelled.
|
||||
func Get(ctx context.Context, agent cmds.Agent, proxy proxy.Proxy) (*config.Node, error) {
|
||||
var agentConfig *config.Node
|
||||
var err error
|
||||
|
||||
@ -65,7 +65,7 @@ func Get(ctx context.Context, agent cmds.Agent, proxy proxy.Proxy) *config.Node
|
||||
cancel()
|
||||
}
|
||||
}, 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
|
||||
|
@ -52,7 +52,10 @@ import (
|
||||
)
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
@ -234,7 +237,11 @@ func RunStandalone(ctx context.Context, cfg cmds.Agent) error {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user