@@ -14,10 +14,12 @@ use serde::{Deserialize, Serialize};
1414use serde_with:: serde_as;
1515use serde_with:: DeserializeFromStr ;
1616use serde_with:: DisplayFromStr ;
17+ use serde_with:: DurationSeconds ;
1718use serde_with:: SerializeDisplay ;
1819use std:: fmt;
1920use std:: net:: SocketAddr ;
2021use std:: path:: { Path , PathBuf } ;
22+ use std:: time:: Duration ;
2123use uuid:: Uuid ;
2224
2325#[ derive( Debug ) ]
@@ -263,6 +265,37 @@ fn default_https_port() -> u16 {
263265 443
264266}
265267
268+ /// Background task configuration
269+ #[ derive( Clone , Debug , Deserialize , Eq , PartialEq , Serialize ) ]
270+ pub struct BackgroundTaskConfig {
271+ /// configuration for internal DNS background tasks
272+ pub dns_internal : DnsTasksConfig ,
273+ /// configuration for external DNS background tasks
274+ pub dns_external : DnsTasksConfig ,
275+ }
276+
277+ #[ serde_as]
278+ #[ derive( Clone , Debug , Deserialize , Eq , PartialEq , Serialize ) ]
279+ pub struct DnsTasksConfig {
280+ /// period (in seconds) for periodic activations of the background task that
281+ /// reads the latest DNS configuration from the database
282+ #[ serde_as( as = "DurationSeconds<u64>" ) ]
283+ pub period_secs_config : Duration ,
284+
285+ /// period (in seconds) for periodic activations of the background task that
286+ /// reads the latest list of DNS servers from the database
287+ #[ serde_as( as = "DurationSeconds<u64>" ) ]
288+ pub period_secs_servers : Duration ,
289+
290+ /// period (in seconds) for periodic activations of the background task that
291+ /// propagates the latest DNS configuration to the latest set of DNS servers
292+ #[ serde_as( as = "DurationSeconds<u64>" ) ]
293+ pub period_secs_propagation : Duration ,
294+
295+ /// maximum number of concurrent DNS server updates
296+ pub max_concurrent_server_updates : usize ,
297+ }
298+
266299/// Configuration for a nexus server
267300#[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
268301pub struct PackageConfig {
@@ -278,8 +311,8 @@ pub struct PackageConfig {
278311 /// Timeseries database configuration.
279312 #[ serde( default ) ]
280313 pub timeseries_db : TimeseriesDbConfig ,
281- /// Updates-related configuration. Updates APIs return 400 Bad Request when this is
282- /// unconfigured.
314+ /// Updates-related configuration. Updates APIs return 400 Bad Request when
315+ /// this is unconfigured.
283316 #[ serde( default ) ]
284317 pub updates : Option < UpdatesConfig > ,
285318 /// Tunable configuration for testing and experimentation
@@ -288,6 +321,8 @@ pub struct PackageConfig {
288321 /// `Dendrite` dataplane daemon configuration
289322 #[ serde( default ) ]
290323 pub dendrite : DpdConfig ,
324+ /// Background task configuration
325+ pub background_tasks : BackgroundTaskConfig ,
291326}
292327
293328#[ derive( Clone , Debug , PartialEq , Deserialize , Serialize ) ]
@@ -361,7 +396,8 @@ mod test {
361396 } ;
362397 use crate :: address:: { Ipv6Subnet , RACK_PREFIX } ;
363398 use crate :: nexus_config:: {
364- Database , DeploymentConfig , DpdConfig , LoadErrorKind ,
399+ BackgroundTaskConfig , Database , DeploymentConfig , DnsTasksConfig ,
400+ DpdConfig , LoadErrorKind ,
365401 } ;
366402 use dropshot:: ConfigDropshot ;
367403 use dropshot:: ConfigLogging ;
@@ -373,6 +409,7 @@ mod test {
373409 use std:: path:: Path ;
374410 use std:: path:: PathBuf ;
375411 use std:: str:: FromStr ;
412+ use std:: time:: Duration ;
376413
377414 /// Generates a temporary filesystem path unique for the given label.
378415 fn temp_path ( label : & str ) -> PathBuf {
@@ -494,6 +531,15 @@ mod test {
494531 type = "from_dns"
495532 [dendrite]
496533 address = "[::1]:12224"
534+ [background_tasks]
535+ dns_internal.period_secs_config = 1
536+ dns_internal.period_secs_servers = 2
537+ dns_internal.period_secs_propagation = 3
538+ dns_internal.max_concurrent_server_updates = 4
539+ dns_external.period_secs_config = 5
540+ dns_external.period_secs_servers = 6
541+ dns_external.period_secs_propagation = 7
542+ dns_external.max_concurrent_server_updates = 8
497543 "## ,
498544 )
499545 . unwrap ( ) ;
@@ -548,6 +594,20 @@ mod test {
548594 SocketAddr :: from_str( "[::1]:12224" ) . unwrap( )
549595 )
550596 } ,
597+ background_tasks: BackgroundTaskConfig {
598+ dns_internal: DnsTasksConfig {
599+ period_secs_config: Duration :: from_secs( 1 ) ,
600+ period_secs_servers: Duration :: from_secs( 2 ) ,
601+ period_secs_propagation: Duration :: from_secs( 3 ) ,
602+ max_concurrent_server_updates: 4 ,
603+ } ,
604+ dns_external: DnsTasksConfig {
605+ period_secs_config: Duration :: from_secs( 5 ) ,
606+ period_secs_servers: Duration :: from_secs( 6 ) ,
607+ period_secs_propagation: Duration :: from_secs( 7 ) ,
608+ max_concurrent_server_updates: 8 ,
609+ } ,
610+ } ,
551611 } ,
552612 }
553613 ) ;
@@ -584,6 +644,15 @@ mod test {
584644 type = "from_dns"
585645 [dendrite]
586646 address = "[::1]:12224"
647+ [background_tasks]
648+ dns_internal.period_secs_config = 1
649+ dns_internal.period_secs_servers = 2
650+ dns_internal.period_secs_propagation = 3
651+ dns_internal.max_concurrent_server_updates = 4
652+ dns_external.period_secs_config = 5
653+ dns_external.period_secs_servers = 6
654+ dns_external.period_secs_propagation = 7
655+ dns_external.max_concurrent_server_updates = 8
587656 "## ,
588657 )
589658 . unwrap ( ) ;
0 commit comments