Skip to content

Commit

Permalink
Bikeshed {Store, Scheduler}Config -> {Store, Scheduler}Spec
Browse files Browse the repository at this point in the history
This non-functional change simplifies the naming for the configuration
from "Config" to "Spec". This makes it clearer when we operate on Store
implementations and configuration fragments. The new naming scheme is
also closer aligned with common K8s intuition and a bit shorter to type.
  • Loading branch information
aaronmondal committed Nov 17, 2024
1 parent 481226b commit 48a75ae
Show file tree
Hide file tree
Showing 43 changed files with 570 additions and 711 deletions.
8 changes: 4 additions & 4 deletions nativelink-config/src/cas_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ use std::collections::HashMap;

use serde::Deserialize;

use crate::schedulers::SchedulerConfig;
use crate::schedulers::SchedulerSpec;
use crate::serde_utils::{
convert_data_size_with_shellexpand, convert_duration_with_shellexpand,
convert_numeric_with_shellexpand, convert_optional_numeric_with_shellexpand,
convert_optional_string_with_shellexpand, convert_string_with_shellexpand,
convert_vec_string_with_shellexpand,
};
use crate::stores::{ClientTlsConfig, ConfigDigestHashFunction, StoreConfig, StoreRefName};
use crate::stores::{ClientTlsConfig, ConfigDigestHashFunction, StoreRefName, StoreSpec};

/// Name of the scheduler. This type will be used when referencing a
/// scheduler in the `CasConfig::schedulers`'s map key.
Expand Down Expand Up @@ -725,15 +725,15 @@ pub struct GlobalConfig {
pub struct CasConfig {
/// List of stores available to use in this config.
/// The keys can be used in other configs when needing to reference a store.
pub stores: HashMap<StoreRefName, StoreConfig>,
pub stores: HashMap<StoreRefName, StoreSpec>,

/// Worker configurations used to execute jobs.
pub workers: Option<Vec<WorkerConfig>>,

/// List of schedulers available to use in this config.
/// The keys can be used in other configs when needing to reference a
/// scheduler.
pub schedulers: Option<HashMap<SchedulerRefName, SchedulerConfig>>,
pub schedulers: Option<HashMap<SchedulerRefName, SchedulerSpec>>,

/// Servers to setup for this process.
pub servers: Vec<ServerConfig>,
Expand Down
22 changes: 11 additions & 11 deletions nativelink-config/src/schedulers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ use crate::stores::{GrpcEndpoint, Retry, StoreRefName};

#[allow(non_camel_case_types)]
#[derive(Deserialize, Debug)]
pub enum SchedulerConfig {
simple(SimpleScheduler),
grpc(GrpcScheduler),
cache_lookup(CacheLookupScheduler),
property_modifier(PropertyModifierScheduler),
pub enum SchedulerSpec {
simple(SimpleSpec),
grpc(GrpcSpec),
cache_lookup(CacheLookupSpec),
property_modifier(PropertyModifierSpec),
}

/// When the scheduler matches tasks to workers that are capable of running
Expand Down Expand Up @@ -67,7 +67,7 @@ pub enum WorkerAllocationStrategy {

#[derive(Deserialize, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct SimpleScheduler {
pub struct SimpleSpec {
/// A list of supported platform properties mapped to how these properties
/// are used when the scheduler looks for worker nodes capable of running
/// the task.
Expand Down Expand Up @@ -154,7 +154,7 @@ pub struct ExperimentalRedisSchedulerBackend {
/// build at the main scheduler directly though.
#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct GrpcScheduler {
pub struct GrpcSpec {
/// The upstream scheduler to forward requests to.
pub endpoint: GrpcEndpoint,

Expand All @@ -176,14 +176,14 @@ pub struct GrpcScheduler {

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct CacheLookupScheduler {
pub struct CacheLookupSpec {
/// The reference to the action cache store used to return cached
/// actions from rather than running them again.
/// To prevent unintended issues, this store should probably be a CompletenessCheckingStore.
pub ac_store: StoreRefName,

/// The nested scheduler to use if cache lookup fails.
pub scheduler: Box<SchedulerConfig>,
pub scheduler: Box<SchedulerSpec>,
}

#[derive(Deserialize, Debug, Clone)]
Expand All @@ -206,7 +206,7 @@ pub enum PropertyModification {

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct PropertyModifierScheduler {
pub struct PropertyModifierSpec {
/// A list of modifications to perform to incoming actions for the nested
/// scheduler. These are performed in order and blindly, so removing a
/// property that doesn't exist is fine and overwriting an existing property
Expand All @@ -215,5 +215,5 @@ pub struct PropertyModifierScheduler {
pub modifications: Vec<PropertyModification>,

/// The nested scheduler to use after modifying the properties.
pub scheduler: Box<SchedulerConfig>,
pub scheduler: Box<SchedulerSpec>,
}
Loading

0 comments on commit 48a75ae

Please sign in to comment.