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

feat(clusters): add pegboard pool type #1152

Closed
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
1 change: 1 addition & 0 deletions fern/definition/admin/clusters/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ types:
- job
- gg
- ats
- pegboard

Provider:
enum:
Expand Down
3 changes: 3 additions & 0 deletions lib/bolt/cli/src/commands/cluster/datacenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub enum DatacenterPoolType {
Job,
Gg,
Ats,
Pegboard,
}

impl From<DatacenterPoolType> for models::AdminClustersPoolType {
Expand All @@ -48,6 +49,7 @@ impl From<DatacenterPoolType> for models::AdminClustersPoolType {
DatacenterPoolType::Job => models::AdminClustersPoolType::Job,
DatacenterPoolType::Gg => models::AdminClustersPoolType::Gg,
DatacenterPoolType::Ats => models::AdminClustersPoolType::Ats,
DatacenterPoolType::Pegboard => models::AdminClustersPoolType::Pegboard,
}
}
}
Expand Down Expand Up @@ -329,6 +331,7 @@ mod render {
Some(models::AdminClustersPoolType::Job) => "Job".to_string(),
Some(models::AdminClustersPoolType::Gg) => "GG".to_string(),
Some(models::AdminClustersPoolType::Ats) => "ATS".to_string(),
Some(models::AdminClustersPoolType::Pegboard) => "Pegboard".to_string(),
None => String::new(),
}
}
Expand Down
7 changes: 7 additions & 0 deletions lib/bolt/cli/src/commands/cluster/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl SubCommand {
"job" => Ok(models::AdminClustersPoolType::Job),
"gg" => Ok(models::AdminClustersPoolType::Gg),
"ats" => Ok(models::AdminClustersPoolType::Ats),
"pb" | "pegboard" => Ok(models::AdminClustersPoolType::Pegboard),
_ => Err(anyhow!("invalid pool type")),
})
.transpose()?;
Expand Down Expand Up @@ -165,6 +166,7 @@ impl SubCommand {
"job" => Ok(models::AdminClustersPoolType::Job),
"gg" => Ok(models::AdminClustersPoolType::Gg),
"ats" => Ok(models::AdminClustersPoolType::Ats),
"pb" | "pegboard" => Ok(models::AdminClustersPoolType::Pegboard),
_ => Err(anyhow!("invalid pool type")),
})
.transpose()?;
Expand Down Expand Up @@ -203,6 +205,7 @@ impl SubCommand {
"job" => Ok(models::AdminClustersPoolType::Job),
"gg" => Ok(models::AdminClustersPoolType::Gg),
"ats" => Ok(models::AdminClustersPoolType::Ats),
"pb" | "pegboard" => Ok(models::AdminClustersPoolType::Pegboard),
_ => Err(anyhow!("invalid pool type")),
})
.transpose()?;
Expand Down Expand Up @@ -240,6 +243,7 @@ impl SubCommand {
"job" => Ok(models::AdminClustersPoolType::Job),
"gg" => Ok(models::AdminClustersPoolType::Gg),
"ats" => Ok(models::AdminClustersPoolType::Ats),
"pb" | "pegboard" => Ok(models::AdminClustersPoolType::Pegboard),
_ => Err(anyhow!("invalid pool type")),
})
.transpose()?;
Expand Down Expand Up @@ -284,6 +288,7 @@ impl SubCommand {
"job" => Ok(models::AdminClustersPoolType::Job),
"gg" => Ok(models::AdminClustersPoolType::Gg),
"ats" => Ok(models::AdminClustersPoolType::Ats),
"pb" | "pegboard" => Ok(models::AdminClustersPoolType::Pegboard),
_ => Err(anyhow!("invalid pool type")),
})
.transpose()?;
Expand Down Expand Up @@ -323,6 +328,7 @@ impl SubCommand {
"job" => Ok(models::AdminClustersPoolType::Job),
"gg" => Ok(models::AdminClustersPoolType::Gg),
"ats" => Ok(models::AdminClustersPoolType::Ats),
"pb" | "pegboard" => Ok(models::AdminClustersPoolType::Pegboard),
_ => Err(anyhow!("invalid pool type")),
})
.transpose()?;
Expand Down Expand Up @@ -392,6 +398,7 @@ mod render {
models::AdminClustersPoolType::Job => "Job".to_string(),
models::AdminClustersPoolType::Gg => "GG".to_string(),
models::AdminClustersPoolType::Ats => "ATS".to_string(),
models::AdminClustersPoolType::Pegboard => "Pegboard".to_string(),
}
}
}
27 changes: 25 additions & 2 deletions lib/bolt/core/src/context/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,14 @@ impl ProjectContextData {
.get(&config::ns::ProvisioningDatacenterPoolType::Job);
let job_count = job_pool.map(|pool| pool.desired_count).unwrap_or_default();

let pb_pool = datacenter
.pools
.get(&config::ns::ProvisioningDatacenterPoolType::Pegboard);
let job_count = pb_pool.map(|pool| pool.desired_count).unwrap_or_default();

assert_ne!(
job_count, 0,
"invalid datacenter ({}): Missing job servers",
job_count + pb_count, 0,
"invalid datacenter ({}): Missing job or pegboard servers",
name_id,
);
assert!(
Expand All @@ -328,6 +333,16 @@ impl ProjectContextData {
"invalid datacenter ({}): Job min > desired",
name_id,
);
assert!(
pb_count <= pb_pool.unwrap().max_count,
"invalid datacenter ({}): Pegboard desired > max",
name_id,
);
assert!(
pb_pool.unwrap().min_count <= pb_pool.unwrap().desired_count,
"invalid datacenter ({}): Pegboard min > desired",
name_id,
);

// Validate Linode
#[allow(irrefutable_let_patterns)]
Expand All @@ -353,6 +368,14 @@ impl ProjectContextData {
name_id,
);
}

if let Some(pb_pool) = &pb_pool {
assert!(
pb_pool.drain_timeout >= 55 * 60 * 1000,
"invalid datacenter ({}): Pegboard drain timeout < 55 min (Linode bills hourly, drain timeout should be close to hour intervals)",
name_id,
);
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/convert/src/impls/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ impl ApiFrom<models::AdminClustersPoolType> for cluster::types::PoolType {
models::AdminClustersPoolType::Job => cluster::types::PoolType::Job,
models::AdminClustersPoolType::Gg => cluster::types::PoolType::Gg,
models::AdminClustersPoolType::Ats => cluster::types::PoolType::Ats,
models::AdminClustersPoolType::Pegboard => cluster::types::PoolType::Pegboard,
}
}
}
Expand All @@ -21,6 +22,7 @@ impl ApiFrom<cluster::types::PoolType> for models::AdminClustersPoolType {
cluster::types::PoolType::Job => models::AdminClustersPoolType::Job,
cluster::types::PoolType::Gg => models::AdminClustersPoolType::Gg,
cluster::types::PoolType::Ats => models::AdminClustersPoolType::Ats,
cluster::types::PoolType::Pegboard => models::AdminClustersPoolType::Pegboard,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion svc/api/admin/src/route/clusters/datacenters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub async fn create(
// is to make sure that the datacenter starts in a valid state.
let pools = vec![
cluster::types::Pool {
pool_type: cluster::types::PoolType::Job,
pool_type: cluster::types::PoolType::Pegboard,
hardware: vec![cluster::types::Hardware {
provider_hardware: "g6-nanode-1".to_string(),
}],
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions svc/pkg/cluster/src/ops/datacenter/topology_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub async fn cluster_datacenter_topology_get(
)
.await?;

todo!("implement for pegboard also");

// Fetch batch data from nomad
let (allocation_info, node_info) = tokio::try_join!(
async {
Expand Down
2 changes: 2 additions & 0 deletions svc/pkg/cluster/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub enum PoolType {
Job = 0,
Gg = 1,
Ats = 2,
Pegboard = 3,
}

impl std::fmt::Display for PoolType {
Expand All @@ -83,6 +84,7 @@ impl std::fmt::Display for PoolType {
PoolType::Job => write!(f, "job"),
PoolType::Gg => write!(f, "gg"),
PoolType::Ats => write!(f, "ats"),
PoolType::Pegboard => write!(f, "pegboard"),
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions svc/pkg/cluster/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ pub fn default_cluster_id() -> Uuid {

pub fn server_name(provider_datacenter_id: &str, pool_type: PoolType, server_id: Uuid) -> String {
let ns = util::env::namespace();
let pool_type_str = match pool_type {
PoolType::Job => "job",
PoolType::Gg => "gg",
PoolType::Ats => "ats",
};

format!("{ns}-{provider_datacenter_id}-{pool_type_str}-{server_id}",)
format!("{ns}-{provider_datacenter_id}-{pool_type}-{server_id}")
}

pub(crate) async fn cf_client(
Expand Down
2 changes: 1 addition & 1 deletion svc/pkg/cluster/src/workflows/prebake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub async fn cluster_prebake(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResu
api_token: dc.provider_api_token.clone(),
hardware: linode::util::consts::PREBAKE_HARDWARE.to_string(),
firewall_preset: match input.pool_type {
PoolType::Job => linode::types::FirewallPreset::Job,
PoolType::Job | PoolType::Pegboard => linode::types::FirewallPreset::Job,
PoolType::Gg => linode::types::FirewallPreset::Gg,
PoolType::Ats => linode::types::FirewallPreset::Ats,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ pub fn configure(config: &Config, pool_type: PoolType) -> String {
.collect::<Vec<_>>()
.join(", ");

let pool_type_str = match pool_type {
PoolType::Job => "job",
PoolType::Gg => "gg",
PoolType::Ats => "ats",
};

let mut config_str = formatdoc!(
r#"
[api]
Expand All @@ -52,7 +46,7 @@ pub fn configure(config: &Config, pool_type: PoolType) -> String {
.tags.server_id = "___SERVER_ID___"
.tags.datacenter_id = "___DATACENTER_ID___"
.tags.cluster_id = "___CLUSTER_ID___"
.tags.pool_type = "{pool_type_str}"
.tags.pool_type = "{pool_type}"
.tags.public_ip = "${{PUBLIC_IP}}"
'''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ tar -xz -C /opt/cni-plugins-$version -f /tmp/cni-plugins.tgz
# Copy plugins to /opt/cni/bin
mkdir -p /opt/cni/bin /opt/cni/config
cp -r /opt/cni-plugins-$version/* /opt/cni/bin/

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ pub async fn gen_install(
script.push(components::docker::install());
script.push(components::traffic_server::install());
}
PoolType::Pegboard => {
script.push(components::docker::install());
script.push(components::lz4::install());
script.push(components::skopeo::install());
script.push(components::umoci::install());
script.push(components::cni::tool());
script.push(components::cni::plugins());
script.push(components::pegboard::install());
}
}

// MARK: Common (post)
Expand Down Expand Up @@ -113,6 +122,17 @@ pub async fn gen_initialize(pool_type: PoolType, datacenter_id: Uuid) -> GlobalR
PoolType::Ats => {
script.push(components::traffic_server::configure().await?);
}
PoolType::Pegboard => {
script.push(components::pegboard::configure()?);

prometheus_targets.insert(
"pegboard".into(),
components::vector::PrometheusTarget {
endpoint: todo!(),
scrape_interval: 15,
},
);
}
}

// MARK: Common (post)
Expand Down
6 changes: 1 addition & 5 deletions svc/pkg/cluster/src/workflows/server/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,7 @@ fn insert_metrics(
&dc.datacenter_id.to_string(),
&dc.provider_datacenter_id,
&dc.name_id,
match pool_type {
PoolType::Job => "job",
PoolType::Gg => "gg",
PoolType::Ats => "ats",
},
&pool_type.to_string(),
])
.observe(dt);
}
4 changes: 2 additions & 2 deletions svc/pkg/cluster/src/workflows/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub(crate) async fn cluster_server(ctx: &mut WorkflowCtx, input: &Input) -> Glob
api_token: dc.provider_api_token.clone(),
hardware: hardware.provider_hardware.clone(),
firewall_preset: match input.pool_type {
PoolType::Job => linode::types::FirewallPreset::Job,
PoolType::Job | PoolType::Pegboard => linode::types::FirewallPreset::Job,
PoolType::Gg => linode::types::FirewallPreset::Gg,
PoolType::Ats => linode::types::FirewallPreset::Ats,
},
Expand Down Expand Up @@ -313,7 +313,7 @@ struct GetVlanIpInput {
async fn get_vlan_ip(ctx: &ActivityCtx, input: &GetVlanIpInput) -> GlobalResult<Ipv4Addr> {
// Find next available vlan index
let mut vlan_addr_range = match input.pool_type {
PoolType::Job => util::net::job::vlan_addr_range(),
PoolType::Job | PoolType::Pegboard => util::net::job::vlan_addr_range(),
PoolType::Gg => util::net::gg::vlan_addr_range(),
PoolType::Ats => util::net::ats::vlan_addr_range(),
};
Expand Down
8 changes: 4 additions & 4 deletions svc/pkg/cluster/standalone/default-update/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ struct Pool {
}

#[derive(Deserialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "snake_case")]
enum PoolType {
#[serde(rename = "job")]
Job,
#[serde(rename = "gg")]
Gg,
#[serde(rename = "ats")]
Ats,
Pegboard,
}

impl From<PoolType> for cluster::types::PoolType {
Expand All @@ -59,6 +58,7 @@ impl From<PoolType> for cluster::types::PoolType {
PoolType::Job => cluster::types::PoolType::Job,
PoolType::Gg => cluster::types::PoolType::Gg,
PoolType::Ats => cluster::types::PoolType::Ats,
PoolType::Pegboard => cluster::types::PoolType::Pegboard,
}
}
}
Expand Down Expand Up @@ -172,7 +172,7 @@ pub async fn run_from_env(use_autoscaler: bool) -> GlobalResult<()> {
.map(|(pool_type, pool)| {
let desired_count = match pool_type {
PoolType::Ats | PoolType::Gg => Some(pool.desired_count),
PoolType::Job => {
PoolType::Job | PoolType::Pegboard => {
if use_autoscaler {
None
} else {
Expand Down
30 changes: 27 additions & 3 deletions svc/pkg/cluster/standalone/metrics-publish/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ fn insert_metrics(dc: &Datacenter, servers: &[Server]) -> GlobalResult<()> {
.filter(|s| matches!(s.pool_type, PoolType::Ats))
.collect::<Vec<_>>(),
),
(
PoolType::Pegboard,
servers_in_dc
.clone()
.filter(|s| matches!(s.pool_type, PoolType::Pegboard))
.collect::<Vec<_>>(),
),
];

// Aggregate all states per pool type
Expand All @@ -135,6 +142,7 @@ fn insert_metrics(dc: &Datacenter, servers: &[Server]) -> GlobalResult<()> {
let mut installing = 0;
let mut active = 0;
let mut nomad = 0;
let mut pegboard = 0;
let mut draining = 0;
let mut tainted = 0;
let mut draining_tainted = 0;
Expand All @@ -149,6 +157,10 @@ fn insert_metrics(dc: &Datacenter, servers: &[Server]) -> GlobalResult<()> {
if server.has_nomad_node {
nomad += 1;
}

if server.has_pegboard_client {
pegboard += 1;
}
} else {
installing += 1;
}
Expand Down Expand Up @@ -192,15 +204,27 @@ fn insert_metrics(dc: &Datacenter, servers: &[Server]) -> GlobalResult<()> {
.with_label_values(&labels)
.set(draining_tainted);

if let PoolType::Job = pool_type {
metrics::NOMAD_SERVERS
match pool_type {
PoolType::Job => {
metrics::NOMAD_SERVERS
.with_label_values(&[
&cluster_id,
&datacenter_id,
&dc.provider_datacenter_id,
&dc.name_id,
])
.set(nomad);
}
PoolType::Pegboard => {
metrics::PEGBOARD_SERVERS
.with_label_values(&[
&cluster_id,
&datacenter_id,
&dc.provider_datacenter_id,
&dc.name_id,
])
.set(nomad);
.set(pegboard);
}
}
}

Expand Down
Loading
Loading