2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-22 02:02:14 +00:00

add config for zone sync scheduler

This commit is contained in:
Aravindh-Raju 2023-03-08 15:40:07 +05:30
parent 8e215e49ba
commit 62ec7a6a52
No known key found for this signature in database
GPG Key ID: 6B4D566AC36626F6
9 changed files with 55 additions and 7 deletions

View File

@ -27,10 +27,16 @@ vinyldns {
scheduled-changes-enabled = ${?SCHEDULED_CHANGES_ENABLED}
multi-record-batch-change-enabled = true
multi-record-batch-change-enabled = ${?MULTI_RECORD_BATCH_CHANGE_ENABLED}
# Server settings
use-recordset-cache = true
use-recordset-cache = ${?USE_RECORDSET_CACHE}
load-test-data = false
load-test-data = ${?LOAD_TEST_DATA}
# should be true while running locally or when we have only one api server/instance, for zone sync scheduler to work
is-zone-sync-schedule-allowed = true
# should be set to true only on a single server/instance else automated sync will be performed at every server/instance
is-zone-sync-schedule-allowed = ${?IS_ZONE_SYNC_SCHEDULE_ALLOWED}
# configured backend providers
backend {

View File

@ -27,10 +27,16 @@ vinyldns {
scheduled-changes-enabled = ${?SCHEDULED_CHANGES_ENABLED}
multi-record-batch-change-enabled = true
multi-record-batch-change-enabled = ${?MULTI_RECORD_BATCH_CHANGE_ENABLED}
# Server settings
use-recordset-cache = false
use-recordset-cache = ${?USE_RECORDSET_CACHE}
load-test-data = false
load-test-data = ${?LOAD_TEST_DATA}
# should be true while running locally or when we have only one api server/instance, for zone sync scheduler to work
is-zone-sync-schedule-allowed = true
# should be set to true only on a single server/instance else automated sync will be performed at every server/instance
is-zone-sync-schedule-allowed = ${?IS_ZONE_SYNC_SCHEDULE_ALLOWED}
# configured backend providers
backend {

View File

@ -232,4 +232,9 @@ vinyldns {
load-test-data = false
load-test-data = ${?LOAD_TEST_DATA}
# should be true while running locally or when we have only one api server/instance, for zone sync scheduler to work
is-zone-sync-schedule-allowed = true
# should be set to true only on a single server/instance else automated sync will be performed at every server/instance
is-zone-sync-schedule-allowed = ${?IS_ZONE_SYNC_SCHEDULE_ALLOWED}
}

View File

@ -100,7 +100,7 @@ object Boot extends App {
)
_ <- APIMetrics.initialize(vinyldnsConfig.apiMetricSettings)
// Schedule the zone sync task to be executed every 5 seconds
_ <- IO(executor.scheduleAtFixedRate(() => {
_ <- if (vinyldnsConfig.serverConfig.isZoneSyncScheduleAllowed){ IO(executor.scheduleAtFixedRate(() => {
val zoneChanges = for {
zoneChanges <- ZoneSyncScheduleHandler.zoneSyncScheduler(repositories.zoneRepository)
_ <- if (zoneChanges.nonEmpty) messageQueue.sendBatch(NonEmptyList.fromList(zoneChanges.toList).get) else IO.unit
@ -111,7 +111,7 @@ object Boot extends App {
case Left(error) =>
logger.error(s"An error occurred while performing the scheduled zone sync. Error: $error")
}
}, 0, 1, TimeUnit.SECONDS))
}, 0, 1, TimeUnit.SECONDS)) } else IO.unit
_ <- CommandHandler.run(
messageQueue,
msgsPerPoll,

View File

@ -34,13 +34,14 @@ final case class ServerConfig(
keyName: String,
processingDisabled: Boolean,
useRecordSetCache: Boolean,
loadTestData: Boolean
loadTestData: Boolean,
isZoneSyncScheduleAllowed: Boolean,
)
object ServerConfig {
import ZoneRecordValidations.toCaseIgnoredRegexList
implicit val configReader: ConfigReader[ServerConfig] = ConfigReader.forProduct12[
implicit val configReader: ConfigReader[ServerConfig] = ConfigReader.forProduct13[
ServerConfig,
Int,
Int,
@ -53,6 +54,7 @@ object ServerConfig {
Config,
Boolean,
Boolean,
Boolean,
Boolean
](
"health-check-timeout",
@ -66,7 +68,8 @@ object ServerConfig {
"defaultZoneConnection",
"processing-disabled",
"use-recordset-cache",
"load-test-data"
"load-test-data",
"is-zone-sync-schedule-allowed"
) {
case (
timeout,
@ -80,7 +83,8 @@ object ServerConfig {
zoneConnConfig,
processingDisabled,
useRecordSetCache,
loadTestData) =>
loadTestData,
isZoneSyncScheduleAllowed) =>
ServerConfig(
timeout,
ttl,
@ -93,7 +97,8 @@ object ServerConfig {
zoneConnConfig.getString("keyName"),
processingDisabled,
useRecordSetCache,
loadTestData
loadTestData,
isZoneSyncScheduleAllowed
)
}
}

View File

@ -27,10 +27,16 @@ vinyldns {
scheduled-changes-enabled = ${?SCHEDULED_CHANGES_ENABLED}
multi-record-batch-change-enabled = true
multi-record-batch-change-enabled = ${?MULTI_RECORD_BATCH_CHANGE_ENABLED}
# Server settings
use-recordset-cache = false
use-recordset-cache = ${?USE_RECORDSET_CACHE}
load-test-data = false
load-test-data = ${?LOAD_TEST_DATA}
# should be true while running locally or when we have only one api server/instance, for zone sync scheduler to work
is-zone-sync-schedule-allowed = true
# should be set to true only on a single server/instance else automated sync will be performed at every server/instance
is-zone-sync-schedule-allowed = ${?IS_ZONE_SYNC_SCHEDULE_ALLOWED}
# configured backend providers
backend {

View File

@ -388,6 +388,14 @@ Version of the application that is deployed. Currently, this is a configuration
**Note: You can get installation information including color, version, default key name, and processing-disabled by
hitting the _status_ endpoint GET /status**
### Is Zone Sync Schedule Allowed
Used while deploying. Should be set to `true` only on one api server/instance and `false` on every other api servers/instances.
Thus automated sync will be done only once on a single server/instance instead of every api servers/instances.
Set it to `true` while running locally or when we have only a single api server/instance.
`is-zone-sync-schedule-allowed = true`
### HTTP Host and Port
To specify what host and port to bind to when starting up the API server, default is 9000.

View File

@ -262,10 +262,16 @@ vinyldns {
manual-batch-review-enabled = true
scheduled-changes-enabled = true
multi-record-batch-change-enabled = true
#Server settings
use-recordset-cache = true
use-recordset-cache = ${?USE_RECORDSET_CACHE}
load-test-data = true
load-test-data = ${?LOAD_TEST_DATA}
# should be true while running locally or when we have only one api server/instance, for zone sync scheduler to work
is-zone-sync-schedule-allowed = true
# should be set to true only on a single server/instance else automated sync will be performed at every server/instance
is-zone-sync-schedule-allowed = ${?IS_ZONE_SYNC_SCHEDULE_ALLOWED}
global-acl-rules = [
{

View File

@ -31,10 +31,16 @@ vinyldns {
scheduled-changes-enabled = ${?SCHEDULED_CHANGES_ENABLED}
multi-record-batch-change-enabled = true
multi-record-batch-change-enabled = ${?MULTI_RECORD_BATCH_CHANGE_ENABLED}
# Server settings
use-recordset-cache = true
use-recordset-cache = ${?USE_RECORDSET_CACHE}
load-test-data = true
load-test-data = ${?LOAD_TEST_DATA}
# should be true while running locally or when we have only one api server/instance, for zone sync scheduler to work
is-zone-sync-schedule-allowed = true
# should be set to true only on a single server/instance else automated sync will be performed at every server/instance
is-zone-sync-schedule-allowed = ${?IS_ZONE_SYNC_SCHEDULE_ALLOWED}
# configured backend providers
backend {