Skip to content

Commit

Permalink
fix(ds): fix server list & nomad monitor alloc plan queries (#1071)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
NathanFlurry committed Aug 16, 2024
1 parent 453a19b commit eb0252c
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 34 deletions.
1 change: 0 additions & 1 deletion fern/definition/servers/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ types:
id: uuid
environment: uuid
datacenter: uuid
cluster: uuid
tags: unknown
runtime: Runtime
network: Network
Expand Down
2 changes: 1 addition & 1 deletion lib/chirp-workflow/core/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
util,
};

const TICK_INTERVAL: Duration = Duration::from_secs(30);
const TICK_INTERVAL: Duration = Duration::from_secs(5);

/// Used to spawn a new thread that indefinitely polls the database for new workflows. Only pulls workflows
/// that are registered in its registry. After pulling, the workflows are ran and their state is written to
Expand Down
1 change: 0 additions & 1 deletion sdks/full/go/servers/types.go

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

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

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

18 changes: 14 additions & 4 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: 0 additions & 1 deletion sdks/full/rust-cli/docs/ServersServer.md

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

5 changes: 1 addition & 4 deletions sdks/full/rust-cli/src/models/servers_server.rs

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

1 change: 0 additions & 1 deletion sdks/full/rust/docs/ServersServer.md

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

5 changes: 1 addition & 4 deletions sdks/full/rust/src/models/servers_server.rs

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.

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.

45 changes: 42 additions & 3 deletions svc/api/servers/src/route/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,38 @@ define_router! {
"games" / Uuid / "environments" / Uuid / "servers": {
GET: servers::list_servers(
query: servers::ListQuery,
rate_limit: {
buckets: [
{ count: 200, bucket: duration::minutes(1) },
],
},
),
POST: servers::create(
body: models::ServersCreateServerRequest,
rate_limit: {
buckets: [
{ count: 100, bucket: duration::minutes(1) },
],
},
),
},

"games" / Uuid / "environments" / Uuid / "servers" / Uuid: {
GET: servers::get(),
GET: servers::get(
rate_limit: {
buckets: [
{ count: 120, bucket: duration::minutes(1) },
],
},

),
DELETE: servers::destroy(
query: servers::DeleteQuery,
rate_limit: {
buckets: [
{ count: 200, bucket: duration::minutes(1) },
],
},
),
},

Expand All @@ -52,11 +74,22 @@ define_router! {
"games" / Uuid / "environments" / Uuid / "builds": {
GET: builds::list(
query: builds::GetQuery,
rate_limit: {
buckets: [
{ count: 200, bucket: duration::minutes(1) },
],
},
),
},

"games" / Uuid / "environments" / Uuid / "builds" / Uuid: {
GET: builds::get(),
GET: builds::get(
rate_limit: {
buckets: [
{ count: 100, bucket: duration::minutes(1) },
],
},
),
},

"games" / Uuid / "environments" / Uuid / "builds" / Uuid / "tags": {
Expand All @@ -73,7 +106,13 @@ define_router! {

// MARK: Datacenters
"games" / Uuid / "environments" / Uuid / "datacenters": {
GET: dc::list(),
GET: dc::list(
rate_limit: {
buckets: [
{ count: 100, bucket: duration::minutes(1) },
],
},
),
},
},
}
12 changes: 7 additions & 5 deletions svc/pkg/ds/src/ops/server/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ pub async fn get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output> {
),
)?;

let servers = server_rows
.into_iter()
let servers = input
.server_ids
.iter()
.filter_map(|server_id| server_rows.iter().find(|x| x.server_id == *server_id))
.map(|server| {
let server_nomad = unwrap!(server_nomad_rows
.iter()
Expand Down Expand Up @@ -205,14 +207,14 @@ pub async fn get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output> {
env_id: server.env_id,
datacenter_id: server.datacenter_id,
cluster_id: server.cluster_id,
tags: server.tags.0,
tags: server.tags.0.clone(),
resources: ServerResources {
cpu_millicores: server.resources_cpu_millicores.try_into()?,
memory_mib: server.resources_memory_mib.try_into()?,
},
kill_timeout_ms: server.kill_timeout_ms,
args: server.args,
environment: server.environment.0,
args: server.args.clone(),
environment: server.environment.0.clone(),
image_id: server.image_id,
network_mode: unwrap!(NetworkMode::from_repr(server.network_mode.try_into()?)),
network_ports: ports,
Expand Down
1 change: 0 additions & 1 deletion svc/pkg/ds/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ impl ApiTryFrom<Server> for models::ServersServer {
id: value.server_id,
environment: value.env_id,
datacenter: value.datacenter_id,
cluster: value.cluster_id,
created_at: value.create_ts,
started_at: value.start_ts,
connectable_at: value.connectable_ts,
Expand Down

0 comments on commit eb0252c

Please sign in to comment.