From 8b44a7c3617f6ef578b2238771a218811230f432 Mon Sep 17 00:00:00 2001 From: AngelOnFira <14791619+AngelOnFira@users.noreply.github.com> Date: Thu, 8 Aug 2024 02:54:49 +0000 Subject: [PATCH] feat: add ready_ts to servers endpoint (#1006) This will close RVTEE-316 --- fern/definition/servers/common.yml | 1 + lib/convert/src/impls/ds.rs | 1 + proto/backend/ds.proto | 14 +++++++------- sdks/full/go/servers/types.go | 1 + sdks/full/openapi/openapi.yml | 3 +++ sdks/full/openapi_compat/openapi.yml | 3 +++ sdks/full/rust-cli/docs/ServersServer.md | 1 + sdks/full/rust-cli/src/models/servers_server.rs | 3 +++ sdks/full/rust/docs/ServersServer.md | 1 + sdks/full/rust/src/models/servers_server.rs | 3 +++ .../servers/migrations/20240501133910_init.up.sql | 1 + svc/pkg/ds/ops/server-create/src/lib.rs | 1 + svc/pkg/ds/ops/server-get/src/lib.rs | 3 +++ 13 files changed, 29 insertions(+), 7 deletions(-) diff --git a/fern/definition/servers/common.yml b/fern/definition/servers/common.yml index 30dc9d3f90..d821b1514c 100644 --- a/fern/definition/servers/common.yml +++ b/fern/definition/servers/common.yml @@ -20,6 +20,7 @@ types: DELETE request if needed. type: optional create_ts: long + start_ts: optional destroy_ts: optional Resources: diff --git a/lib/convert/src/impls/ds.rs b/lib/convert/src/impls/ds.rs index 86535fc0bc..dd7de2d896 100644 --- a/lib/convert/src/impls/ds.rs +++ b/lib/convert/src/impls/ds.rs @@ -13,6 +13,7 @@ impl ApiTryFrom for models::ServersServer { Ok(models::ServersServer { cluster_id: unwrap!(value.cluster_id).as_uuid(), create_ts: value.create_ts, + start_ts: value.start_ts, datacenter_id: unwrap!(value.datacenter_id).as_uuid(), destroy_ts: value.destroy_ts, game_id: unwrap!(value.game_id).as_uuid(), diff --git a/proto/backend/ds.proto b/proto/backend/ds.proto index fa0dba6592..ea90ab19a5 100644 --- a/proto/backend/ds.proto +++ b/proto/backend/ds.proto @@ -16,13 +16,13 @@ message Server { int64 kill_timeout_ms = 7; optional string webhook_url = 8; int64 create_ts = 9; - optional int64 destroy_ts = 10; - rivet.common.Uuid image_id = 11; - repeated string args = 12; - NetworkMode network_mode = 13; - map environment = 14; - map network_ports = 15; - + optional int64 start_ts = 10; + optional int64 destroy_ts = 11; + rivet.common.Uuid image_id = 12; + repeated string args = 13; + NetworkMode network_mode = 14; + map environment = 15; + map network_ports = 16; } message ServerResources { diff --git a/sdks/full/go/servers/types.go b/sdks/full/go/servers/types.go index c646521218..1812e4e0cd 100644 --- a/sdks/full/go/servers/types.go +++ b/sdks/full/go/servers/types.go @@ -314,6 +314,7 @@ type Server struct { // The duration to wait for in milliseconds before killing the server. This should be set to a safe default, and can be overridden during a DELETE request if needed. KillTimeout *int64 `json:"kill_timeout,omitempty"` CreateTs int64 `json:"create_ts"` + StartTs *int64 `json:"start_ts,omitempty"` DestroyTs *int64 `json:"destroy_ts,omitempty"` _rawJSON json.RawMessage diff --git a/sdks/full/openapi/openapi.yml b/sdks/full/openapi/openapi.yml index 4bbc8c7cae..f11906c8f1 100644 --- a/sdks/full/openapi/openapi.yml +++ b/sdks/full/openapi/openapi.yml @@ -14101,6 +14101,9 @@ components: create_ts: type: integer format: int64 + start_ts: + type: integer + format: int64 destroy_ts: type: integer format: int64 diff --git a/sdks/full/openapi_compat/openapi.yml b/sdks/full/openapi_compat/openapi.yml index ea147c29a4..4bda402582 100644 --- a/sdks/full/openapi_compat/openapi.yml +++ b/sdks/full/openapi_compat/openapi.yml @@ -4690,6 +4690,9 @@ components: server_id: format: uuid type: string + start_ts: + format: int64 + type: integer tags: {} required: - server_id diff --git a/sdks/full/rust-cli/docs/ServersServer.md b/sdks/full/rust-cli/docs/ServersServer.md index f8c79759cf..d62789a202 100644 --- a/sdks/full/rust-cli/docs/ServersServer.md +++ b/sdks/full/rust-cli/docs/ServersServer.md @@ -16,6 +16,7 @@ Name | Type | Description | Notes **network** | [**crate::models::ServersNetwork**](ServersNetwork.md) | | **resources** | [**crate::models::ServersResources**](ServersResources.md) | | **server_id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**start_ts** | Option<**i64**> | | [optional] **tags** | Option<[**serde_json::Value**](.md)> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdks/full/rust-cli/src/models/servers_server.rs b/sdks/full/rust-cli/src/models/servers_server.rs index cb93decaee..637c914820 100644 --- a/sdks/full/rust-cli/src/models/servers_server.rs +++ b/sdks/full/rust-cli/src/models/servers_server.rs @@ -38,6 +38,8 @@ pub struct ServersServer { pub resources: Box, #[serde(rename = "server_id")] pub server_id: uuid::Uuid, + #[serde(rename = "start_ts", skip_serializing_if = "Option::is_none")] + pub start_ts: Option, #[serde(rename = "tags", deserialize_with = "Option::deserialize")] pub tags: Option, } @@ -57,6 +59,7 @@ impl ServersServer { network: Box::new(network), resources: Box::new(resources), server_id, + start_ts: None, tags, } } diff --git a/sdks/full/rust/docs/ServersServer.md b/sdks/full/rust/docs/ServersServer.md index f8c79759cf..d62789a202 100644 --- a/sdks/full/rust/docs/ServersServer.md +++ b/sdks/full/rust/docs/ServersServer.md @@ -16,6 +16,7 @@ Name | Type | Description | Notes **network** | [**crate::models::ServersNetwork**](ServersNetwork.md) | | **resources** | [**crate::models::ServersResources**](ServersResources.md) | | **server_id** | [**uuid::Uuid**](uuid::Uuid.md) | | +**start_ts** | Option<**i64**> | | [optional] **tags** | Option<[**serde_json::Value**](.md)> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdks/full/rust/src/models/servers_server.rs b/sdks/full/rust/src/models/servers_server.rs index cb93decaee..637c914820 100644 --- a/sdks/full/rust/src/models/servers_server.rs +++ b/sdks/full/rust/src/models/servers_server.rs @@ -38,6 +38,8 @@ pub struct ServersServer { pub resources: Box, #[serde(rename = "server_id")] pub server_id: uuid::Uuid, + #[serde(rename = "start_ts", skip_serializing_if = "Option::is_none")] + pub start_ts: Option, #[serde(rename = "tags", deserialize_with = "Option::deserialize")] pub tags: Option, } @@ -57,6 +59,7 @@ impl ServersServer { network: Box::new(network), resources: Box::new(resources), server_id, + start_ts: None, tags, } } diff --git a/svc/pkg/ds/db/servers/migrations/20240501133910_init.up.sql b/svc/pkg/ds/db/servers/migrations/20240501133910_init.up.sql index b74991e9a1..9ff3af0560 100644 --- a/svc/pkg/ds/db/servers/migrations/20240501133910_init.up.sql +++ b/svc/pkg/ds/db/servers/migrations/20240501133910_init.up.sql @@ -13,6 +13,7 @@ CREATE TABLE servers ( webhook_url STRING, create_ts INT NOT NULL, + start_ts INT, stop_ts INT, finish_ts INT, cleanup_ts INT, diff --git a/svc/pkg/ds/ops/server-create/src/lib.rs b/svc/pkg/ds/ops/server-create/src/lib.rs index 43eba26e58..7bc1c71c7d 100644 --- a/svc/pkg/ds/ops/server-create/src/lib.rs +++ b/svc/pkg/ds/ops/server-create/src/lib.rs @@ -1402,6 +1402,7 @@ pub async fn handle( kill_timeout_ms: ctx.kill_timeout_ms, webhook_url: ctx.webhook_url.clone(), create_ts, + start_ts: None, destroy_ts: None, args: ctx.args.clone(), environment: ctx.environment.clone(), diff --git a/svc/pkg/ds/ops/server-get/src/lib.rs b/svc/pkg/ds/ops/server-get/src/lib.rs index 4319feb183..eac46df97b 100644 --- a/svc/pkg/ds/ops/server-get/src/lib.rs +++ b/svc/pkg/ds/ops/server-get/src/lib.rs @@ -15,6 +15,7 @@ struct Server { kill_timeout_ms: i64, webhook_url: Option, create_ts: i64, + start_ts: Option, destroy_ts: Option, image_id: Uuid, args: Vec, @@ -84,6 +85,7 @@ pub async fn handle( kill_timeout_ms, webhook_url, create_ts, + start_ts, destroy_ts, image_id, args, @@ -223,6 +225,7 @@ pub async fn handle( network_mode: server.network_mode.try_into()?, network_ports: ports, create_ts: server.create_ts, + start_ts: server.start_ts, destroy_ts: server.destroy_ts, };