From 3a5bc44f311e6fa1b9fe75b12c6d8d7d027c90db Mon Sep 17 00:00:00 2001 From: wkolsi <86102242+wkolsi@users.noreply.github.com> Date: Wed, 24 Aug 2022 14:24:37 +0200 Subject: [PATCH] Ampgw 879 (#519) * [AMPGW-879] Add new agentFeatures flag "sdkAgentStatusUpdates" to enable/disable AgentStatusUpdate jobs. * [AMPGW-879] Add new agentFeatures flag "sdkAgentStatusUpdates" to enable/disable AgentStatusUpdate jobs. * [AMPGW-879] Change the flag name * [AMPGW-879] Change the flag name --- pkg/agent/agent.go | 7 +++++-- pkg/config/agentfeaturesconfig.go | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index 4fab8de7d..294c3f7a6 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -182,7 +182,10 @@ func InitializeWithAgentFeatures(centralCfg config.CentralConfig, agentFeaturesC } if util.IsNotTest() && agent.agentFeaturesCfg.ConnectionToCentralEnabled() { - StartAgentStatusUpdate() + if agent.agentFeaturesCfg.AgentStatusUpdatesEnabled() { + StartAgentStatusUpdate() + } + registerExternalIDPs() startTeamACLCache() @@ -192,7 +195,7 @@ func InitializeWithAgentFeatures(centralCfg config.CentralConfig, agentFeaturesC } // Set agent running - if agent.agentResourceManager != nil { + if agent.agentResourceManager != nil && agent.agentFeaturesCfg.AgentStatusUpdatesEnabled() { UpdateStatusWithPrevious(AgentRunning, "", "") } } diff --git a/pkg/config/agentfeaturesconfig.go b/pkg/config/agentfeaturesconfig.go index 4ba0e7fe5..da0ba6314 100644 --- a/pkg/config/agentfeaturesconfig.go +++ b/pkg/config/agentfeaturesconfig.go @@ -12,6 +12,7 @@ type AgentFeaturesConfig interface { PersistCacheEnabled() bool MarketplaceProvisioningEnabled() bool GetExternalIDPConfig() ExternalIDPConfig + AgentStatusUpdatesEnabled() bool } // AgentFeaturesConfiguration - Structure to hold the agent features config @@ -24,6 +25,7 @@ type AgentFeaturesConfiguration struct { PersistCache bool `config:"persistCache"` MarketplaceProvisioning bool `config:"marketplaceProvisioning"` ExternalIDPConfig ExternalIDPConfig `config:"idp"` + AgentStatusUpdates bool `config:"agentStatusUpdates"` } // NewAgentFeaturesConfiguration - Creates the default agent features config @@ -34,6 +36,7 @@ func NewAgentFeaturesConfiguration() AgentFeaturesConfig { VersionChecker: true, PersistCache: false, MarketplaceProvisioning: false, + AgentStatusUpdates: true, } } @@ -67,12 +70,18 @@ func (c *AgentFeaturesConfiguration) GetExternalIDPConfig() ExternalIDPConfig { return c.ExternalIDPConfig } +// AgentStatusUpdatesEnabled - True if the agent SDK should manage the status update. +func (c *AgentFeaturesConfiguration) AgentStatusUpdatesEnabled() bool { + return c.AgentStatusUpdates +} + const ( pathConnectToCentral = "agentFeatures.connectToCentral" pathProcessSystemSignals = "agentFeatures.processSystemSignals" pathVersionChecker = "agentFeatures.versionChecker" pathPersistCache = "agentFeatures.persistCache" pathMarketplaceProvisioning = "agentFeatures.marketplaceProvisioning" + pathAgentStatusUpdates = "agentFeatures.agentStatusUpdates" ) // ValidateCfg - Validates the config, implementing IConfigInterface @@ -90,6 +99,7 @@ func AddAgentFeaturesConfigProperties(props properties.Properties) { props.AddBoolProperty(pathVersionChecker, true, "Controls whether the agent SDK version checker will be enabled or not") props.AddBoolProperty(pathPersistCache, false, "Controls whether the agent SDK will persist agent cache or not") props.AddBoolProperty(pathMarketplaceProvisioning, false, "Controls whether the agent should handle Marketplace Subscriptions or not") + props.AddBoolProperty(pathAgentStatusUpdates, true, "Controls whether the agent should manage the status update or not") addExternalIDPProperties(props) } @@ -101,6 +111,7 @@ func ParseAgentFeaturesConfig(props properties.Properties) (AgentFeaturesConfig, VersionChecker: props.BoolPropertyValueOrTrue(pathVersionChecker), PersistCache: props.BoolPropertyValueOrTrue(pathPersistCache), MarketplaceProvisioning: props.BoolPropertyValueOrTrue(pathMarketplaceProvisioning), + AgentStatusUpdates: props.BoolPropertyValueOrTrue(pathAgentStatusUpdates), } externalIDPCfg, err := parseExternalIDPConfig(props) if err != nil {