diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index b4c38417d9..c37c25e49d 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -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 diff --git a/pkg/agent/run.go b/pkg/agent/run.go index 242d201899..a050cc3031 100644 --- a/pkg/agent/run.go +++ b/pkg/agent/run.go @@ -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 }