Skip to content

Commit

Permalink
Ampgw 879 (#519)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
wkolsi authored Aug 24, 2022
1 parent aca30fd commit 3a5bc44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ func InitializeWithAgentFeatures(centralCfg config.CentralConfig, agentFeaturesC
}

if util.IsNotTest() && agent.agentFeaturesCfg.ConnectionToCentralEnabled() {
StartAgentStatusUpdate()
if agent.agentFeaturesCfg.AgentStatusUpdatesEnabled() {
StartAgentStatusUpdate()
}

registerExternalIDPs()
startTeamACLCache()

Expand All @@ -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, "", "")
}
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/config/agentfeaturesconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type AgentFeaturesConfig interface {
PersistCacheEnabled() bool
MarketplaceProvisioningEnabled() bool
GetExternalIDPConfig() ExternalIDPConfig
AgentStatusUpdatesEnabled() bool
}

// AgentFeaturesConfiguration - Structure to hold the agent features config
Expand All @@ -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
Expand All @@ -34,6 +36,7 @@ func NewAgentFeaturesConfiguration() AgentFeaturesConfig {
VersionChecker: true,
PersistCache: false,
MarketplaceProvisioning: false,
AgentStatusUpdates: true,
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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)
}

Expand All @@ -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 {
Expand Down

0 comments on commit 3a5bc44

Please sign in to comment.