Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add min count to autoscaler #826

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fern/definition/admin/clusters/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ types:
pool_type: PoolType
hardware: list<Hardware>
desired_count: integer
min_count: integer
max_count: integer
drain_timeout: long
Hardware:
Expand All @@ -44,4 +45,3 @@ types:
properties:
server_id: uuid
public_ip: string

2 changes: 1 addition & 1 deletion fern/definition/admin/clusters/datacenters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ types:
pool_type: localCommons.PoolType
hardware: list<localCommons.Hardware>
desired_count: optional<integer>
min_count: optional<integer>
max_count: optional<integer>
drain_timeout: optional<long>

5 changes: 5 additions & 0 deletions lib/bolt/cli/src/commands/cluster/datacenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ pub enum SubCommand {
/// The desired count
#[clap(long)]
desired_count: Option<i32>,
/// The min count
#[clap(long)]
min_count: Option<i32>,
/// The max count
#[clap(long)]
max_count: Option<i32>,
Expand Down Expand Up @@ -192,6 +195,7 @@ impl SubCommand {
pool,
hardware,
desired_count,
min_count,
max_count,
drain_timeout,
} => {
Expand Down Expand Up @@ -234,6 +238,7 @@ impl SubCommand {
provider_hardware: hardware.clone(),
})
.collect(),
min_count,
max_count,
pool_type: pool.into(),
},
Expand Down
2 changes: 2 additions & 0 deletions lib/bolt/config/src/ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ pub enum ProvisioningBuildDeliveryMethod {
pub struct ProvisioningDatacenterPool {
pub hardware: Vec<ProvisioningDatacenterHardware>,
pub desired_count: u32,
#[serde(default)]
pub min_count: u32,
pub max_count: u32,
/// Server drain time in ms.
pub drain_timeout: u64,
Expand Down
24 changes: 20 additions & 4 deletions lib/bolt/core/src/context/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,18 @@ impl ProjectContextData {
panic!("invalid datacenter ({}): Missing ATS pool", name_id);
};

// Validate the build delivery method
assert!(
ats_pool.desired_count <= ats_pool.max_count,
"invalid datacenter ({}): ATS desired > max",
name_id
name_id,
);
assert!(
ats_pool.min_count <= ats_pool.desired_count,
"invalid datacenter ({}): ATS min > desired",
name_id,
);

// Validate the build delivery method
match datacenter.build_delivery_method {
config::ns::ProvisioningBuildDeliveryMethod::TrafficServer => {
assert_ne!(
Expand Down Expand Up @@ -296,7 +302,12 @@ impl ProjectContextData {
assert!(
gg_count <= gg_pool.unwrap().max_count,
"invalid datacenter ({}): GG desired > max",
name_id
name_id,
);
assert!(
gg_pool.unwrap().min_count <= gg_pool.unwrap().desired_count,
"invalid datacenter ({}): GG min > desired",
name_id,
);

let job_pool = datacenter
Expand All @@ -312,7 +323,12 @@ impl ProjectContextData {
assert!(
job_count <= job_pool.unwrap().max_count,
"invalid datacenter ({}): Job desired > max",
name_id
name_id,
);
assert!(
job_pool.unwrap().min_count <= job_pool.unwrap().desired_count,
"invalid datacenter ({}): Job min > desired",
name_id,
);
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/convert/src/impls/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl ApiTryFrom<backend::cluster::Datacenter> for models::AdminClustersDatacente
})
})
.collect::<Result<Vec<models::AdminClustersHardware>, GlobalError>>()?,
min_count: unwrap!(p.min_count.try_into()),
max_count: unwrap!(p.max_count.try_into()),
pool_type: unwrap!(backend::cluster::PoolType::from_i32(p.pool_type))
.api_into(),
Expand Down
1 change: 1 addition & 0 deletions proto/backend/cluster.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ message Pool {
// See docs on failover (/docs/packages/cluster/SERVER_PROVISIONING.md#creating-a-new-server)
repeated Hardware hardware = 2;
uint32 desired_count = 3;
uint32 min_count = 6;
uint32 max_count = 4;
// Server drain timeout In ms
uint64 drain_timeout = 5;
Expand Down
1 change: 1 addition & 0 deletions sdks/full/go/admin/clusters/datacenters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdks/full/go/admin/clusters/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions sdks/full/openapi/openapi.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions sdks/full/openapi_compat/openapi.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdks/full/rust-cli/docs/AdminClustersPool.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion sdks/full/rust-cli/src/models/admin_clusters_pool.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdks/full/rust/docs/AdminClustersPool.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion sdks/full/rust/src/models/admin_clusters_pool.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdks/full/typescript/archive.tgz

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdks/runtime/typescript/archive.tgz

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions svc/api/admin/src/route/clusters/datacenters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub async fn create(
provider_hardware: "g6-nanode-1".to_string(),
}],
desired_count: 0,
min_count: 0,
max_count: 0,
drain_timeout,
},
Expand All @@ -70,6 +71,7 @@ pub async fn create(
provider_hardware: "g6-nanode-1".to_string(),
}],
desired_count: 0,
min_count: 0,
max_count: 0,
drain_timeout,
},
Expand All @@ -79,6 +81,7 @@ pub async fn create(
provider_hardware: "g6-nanode-1".to_string(),
}],
desired_count: 0,
min_count: 0,
max_count: 0,
drain_timeout,
},
Expand Down Expand Up @@ -136,6 +139,7 @@ pub async fn update(
})
.collect(),
desired_count: body.desired_count.map(|c| c as u32),
min_count: body.min_count.map(|c| c as u32),
max_count: body.max_count.map(|c| c as u32),
drain_timeout: body.drain_timeout.map(|d| d as u64),
}];
Expand Down
3 changes: 3 additions & 0 deletions svc/pkg/cluster/standalone/default-update/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl From<Provider> for backend::cluster::Provider {
struct Pool {
hardware: Vec<Hardware>,
desired_count: u32,
min_count: u32,
max_count: u32,
drain_timeout: u64,
}
Expand Down Expand Up @@ -204,6 +205,7 @@ pub async fn run_from_env(use_autoscaler: bool) -> GlobalResult<()> {
.map(Into::into)
.collect::<Vec<_>>(),
desired_count,
min_count: Some(pool.min_count),
max_count: Some(pool.max_count),
drain_timeout: Some(pool.drain_timeout),
}
Expand Down Expand Up @@ -233,6 +235,7 @@ pub async fn run_from_env(use_autoscaler: bool) -> GlobalResult<()> {
pool_type: Into::<backend::cluster::PoolType>::into(pool_type) as i32,
hardware: pool.hardware.into_iter().map(Into::into).collect::<Vec<_>>(),
desired_count: pool.desired_count,
min_count: pool.min_count,
max_count: pool.max_count,
drain_timeout: pool.drain_timeout,
}
Expand Down
Loading
Loading