Skip to content

Commit

Permalink
Fixes #9478: Settings API
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceMacBuche committed Oct 20, 2016
1 parent c33b62e commit 1082739
Show file tree
Hide file tree
Showing 6 changed files with 426 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ trait PromiseGenerationService extends Loggable {
def getGlobalComplianceMode(): Box[GlobalComplianceMode]
def getGlobalAgentRun() : Box[AgentRunInterval]
def getAllLicenses(): Box[Map[NodeId, NovaLicense]]
def getAgentRunInterval : () => Int
def getAgentRunInterval : () => Box[Int]
def getAgentRunSplaytime : () => Box[Int]
def getAgentRunStartHour : () => Box[Int]
def getAgentRunStartMinute : () => Box[Int]
Expand Down Expand Up @@ -428,7 +428,7 @@ class PromiseGenerationServiceImpl (
, override val agentRunService : AgentRunIntervalService
, override val complianceCache : CachedFindRuleNodeStatusReports
, override val promisesFileWriterService: Cf3PromisesFileWriterService
, override val getAgentRunInterval: () => Int
, override val getAgentRunInterval: () => Box[Int]
, override val getAgentRunSplaytime: () => Box[Int]
, override val getAgentRunStartHour: () => Box[Int]
, override val getAgentRunStartMinute: () => Box[Int]
Expand Down Expand Up @@ -670,7 +670,6 @@ trait PromiseGeneration_buildNodeConfigurations extends PromiseGenerationService

}


/*
* Utility class that helps deduplicate same failures in a chain
* of failure when using bestEffort.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ object RudderConfig extends Loggable {
private[this] lazy val globalAgentRunService : AgentRunIntervalService =
new AgentRunIntervalServiceImpl(
nodeInfoServiceImpl
, () => Full(configService.agent_run_interval)
, configService.agent_run_interval
, configService.agent_run_start_hour
, configService.agent_run_start_minute
, configService.agent_run_splaytime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ trait ReadConfigService {

/**
* Agent execution interval and start run
* Note: Interval may NEVER fail, if the value is not in LDAP, then default value arise
*/
def agent_run_interval(): Int
def agent_run_interval(): Box[Int]

def agent_run_splaytime(): Box[Int]
def agent_run_start_hour(): Box[Int]
Expand Down Expand Up @@ -287,7 +286,6 @@ class LDAPBasedConfigService(configFile: Config, repos: ConfigRepository, workfl
/**
* Create a cache for already values that should never fail
*/
var cacheExecutionInterval: Option[Int] = None

val defaultConfig =
s"""rudder.ui.changeMessage.enabled=true
Expand Down Expand Up @@ -407,27 +405,8 @@ class LDAPBasedConfigService(configFile: Config, repos: ConfigRepository, workfl
def cfengine_server_skipidentify(): Box[Boolean] = get("cfengine_server_skipidentify")
def set_cfengine_server_skipidentify(value: Boolean): Box[Unit] = save("cfengine_server_skipidentify", value)

def agent_run_interval(): Int = {
toInt(get("agent_run_interval")) match {
case Full(interval) =>
cacheExecutionInterval = Some(interval)
interval
case f: EmptyBox =>
val e = f ?~! "Failure when fetching the agent run interval "
logger.error(e.messageChain)
cacheExecutionInterval match {
case Some(interval) =>
interval
case None =>
val errorMsg = "Error while fetch the agent run interval; the value is unavailable in the LDAP and in cache."
logger.error(errorMsg)
throw new RuntimeException(errorMsg)
}
}

}
def agent_run_interval(): Box[Int] = get("agent_run_interval")
def set_agent_run_interval(value: Int, actor: EventActor, reason: Option[String]): Box[Unit] = {
cacheExecutionInterval = Some(value)
val info = ModifyGlobalPropertyInfo(ModifyAgentRunIntervalEventType,actor,reason)
save("agent_run_interval", value, Some(info))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class ShowNodeDetailsFromNode(
starthour <- configService.agent_run_start_hour
startmin <- configService.agent_run_start_minute
splaytime <- configService.agent_run_splaytime
interval = configService.agent_run_interval
interval <- configService.agent_run_interval
} yield {
AgentRunInterval(
None
Expand Down

0 comments on commit 1082739

Please sign in to comment.