From ebb26c5fdc028ae90af8896d8e4a27af90971eef Mon Sep 17 00:00:00 2001 From: LP B Date: Wed, 29 May 2024 03:37:41 +0200 Subject: [PATCH] feat(options): ability to configure the initial edge poll frequency --- agent.go | 1 + edge/edge.go | 2 +- os/options.go | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/agent.go b/agent.go index 4e2f29a9e..4ff271e32 100644 --- a/agent.go +++ b/agent.go @@ -94,6 +94,7 @@ type ( EdgeID string EdgeUIServerAddr string EdgeUIServerPort string + EdgePollFrequency string EdgeInactivityTimeout string EdgeInsecurePoll bool EdgeTunnel bool diff --git a/edge/edge.go b/edge/edge.go index 34a531ff8..0f08f793e 100644 --- a/edge/edge.go +++ b/edge/edge.go @@ -69,7 +69,7 @@ func (manager *Manager) Start() error { pollServiceConfig := &pollServiceConfig{ APIServerAddr: apiServerAddr, EdgeID: manager.agentOptions.EdgeID, - PollFrequency: agent.DefaultEdgePollInterval, + PollFrequency: manager.agentOptions.EdgePollFrequency, InactivityTimeout: manager.agentOptions.EdgeInactivityTimeout, TunnelCapability: manager.agentOptions.EdgeTunnel, PortainerURL: manager.key.PortainerInstanceURL, diff --git a/os/options.go b/os/options.go index 3753c097e..ed8f1a5ce 100644 --- a/os/options.go +++ b/os/options.go @@ -26,6 +26,7 @@ const ( EnvKeyEdgeID = "EDGE_ID" EnvKeyEdgeServerHost = "EDGE_SERVER_HOST" EnvKeyEdgeServerPort = "EDGE_SERVER_PORT" + EnvKeyEdgePollFrequency = "EDGE_POLL_FREQUENCY" EnvKeyEdgeInactivityTimeout = "EDGE_INACTIVITY_TIMEOUT" EnvKeyEdgeInsecurePoll = "EDGE_INSECURE_POLL" EnvKeyEdgeTunnel = "EDGE_TUNNEL" @@ -79,6 +80,7 @@ var ( fEdgeID = kingpin.Flag("edge-id", EnvKeyEdgeID+" a unique identifier associated to this agent cluster").Envar(EnvKeyEdgeID).String() fEdgeServerAddr = kingpin.Flag("edge-host", EnvKeyEdgeServerHost+" address on which the Edge UI will be exposed (default to 0.0.0.0)").Envar(EnvKeyEdgeServerHost).Default(agent.DefaultEdgeServerAddr).IP() fEdgeServerPort = kingpin.Flag("edge-port", EnvKeyEdgeServerPort+" port on which the Edge UI will be exposed (default to 80)").Envar(EnvKeyEdgeServerPort).Default(agent.DefaultEdgeServerPort).Int() + fEdgePollFrequency = kingpin.Flag("edge-poll-frequency", EnvKeyEdgePollFrequency+" frequency at which the agent will poll the server before receiving its configuration remotely (default to 5s)").Envar(EnvKeyEdgePollFrequency).Default(agent.DefaultEdgePollInterval).String() fEdgeInactivityTimeout = kingpin.Flag("edge-inactivity", EnvKeyEdgeInactivityTimeout+" timeout used by the agent to close the reverse tunnel after inactivity (default to 5m)").Envar(EnvKeyEdgeInactivityTimeout).Default(agent.DefaultEdgeSleepInterval).String() fEdgeInsecurePoll = kingpin.Flag("edge-insecurepoll", EnvKeyEdgeInsecurePoll+" enable this option if you need the agent to poll a HTTPS Portainer instance with self-signed certificates. Disabled by default, set to 1 to enable it").Envar(EnvKeyEdgeInsecurePoll).Bool() fEdgeTunnel = kingpin.Flag("edge-tunnel", EnvKeyEdgeTunnel+" disable this option if you wish to prevent the agent from opening tunnels over websockets").Envar(EnvKeyEdgeTunnel).Default("true").Bool() @@ -143,6 +145,7 @@ func (parser *EnvOptionParser) Options() (*agent.Options, error) { EdgeID: *fEdgeID, EdgeUIServerAddr: fEdgeServerAddr.String(), EdgeUIServerPort: strconv.Itoa(*fEdgeServerPort), + EdgePollFrequency: *fEdgePollFrequency, EdgeInactivityTimeout: *fEdgeInactivityTimeout, EdgeInsecurePoll: *fEdgeInsecurePoll, EdgeTunnel: *fEdgeTunnel,