Skip to content
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
75 changes: 68 additions & 7 deletions Cargo.lock

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

5 changes: 1 addition & 4 deletions Cargo.toml

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions docker/dev-full/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,13 @@ services:
restart: unless-stopped
command: /usr/bin/rivet-guard
environment:
- RUST_LOG=debug
# - RUST_LOG=debug
- RUST_BACKTRACE=1
- RUST_LOG_ANSI_COLOR=1
- RIVET_OTEL_ENABLED=1
- RIVET_OTEL_SAMPLER_RATIO=1
- RIVET_SERVICE_NAME=rivet-guard
- RIVET_OTEL_ENDPOINT=http://otel-collector:4317
- RUST_LOG=debug,hyper=info
stop_grace_period: 0s
ports:
# HTTP
Expand Down
7 changes: 7 additions & 0 deletions examples/system-test-actor/tests/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ async function run() {
guard: {},
},
},
http2: {
protocol: "http",
internalPort: 8085,
routing: {
guard: {},
},
},
Comment on lines +52 to +58
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: HTTP2 port is configured but no tests are implemented to verify HTTP2 functionality

udp: {
protocol: "udp",
// internalPort: 80,
Expand Down
11 changes: 11 additions & 0 deletions packages/common/fdb-util/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ pub const SQLITE: usize = 44;
pub const INTERNAL: usize = 45;
pub const METADATA: usize = 46;
pub const COMPRESSED_DATA: usize = 47;
pub const RUNNER: usize = 48;
pub const RUNNERS_BY_REMAINING_SLOTS: usize = 49;
pub const REMAINING_SLOTS: usize = 50;
pub const TOTAL_SLOTS: usize = 51;
pub const IMAGE_ID: usize = 52;

// Directories with fdbrs must use string paths instead of tuples
pub mod dir {
Expand Down Expand Up @@ -103,6 +108,12 @@ pub fn key_from_str(key: &str) -> Option<usize> {
"sqlite" => Some(SQLITE),
"internal" => Some(INTERNAL),
"metadata" => Some(METADATA),
"compressed_data" => Some(COMPRESSED_DATA),
"runner" => Some(RUNNER),
"runners_by_remaining_slots" => Some(RUNNERS_BY_REMAINING_SLOTS),
"remaining_slots" => Some(REMAINING_SLOTS),
"total_slots" => Some(TOTAL_SLOTS),
"image_id" => Some(IMAGE_ID),
_ => None,
}
}
12 changes: 11 additions & 1 deletion packages/common/util/core/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
fmt,
hash::{Hash, Hasher},
marker::PhantomData,
ops::Deref,
ops::{Deref, DerefMut},
};

use indexmap::IndexMap;
Expand Down Expand Up @@ -125,6 +125,10 @@ impl<K: Eq + Hash, V: Hash> HashableMap<K, V> {
pub fn new() -> Self {
HashableMap(IndexMap::new())
}

pub fn with_capacity(capacity: usize) -> Self {
HashableMap(IndexMap::with_capacity(capacity))
}
}

impl<K: Eq + Hash, V: Hash> Default for HashableMap<K, V> {
Expand All @@ -141,6 +145,12 @@ impl<K: Eq + Hash, V: Hash> Deref for HashableMap<K, V> {
}
}

impl<K: Eq + Hash, V: Hash> DerefMut for HashableMap<K, V> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl<K: Eq + Ord + Hash, V: Hash> Hash for HashableMap<K, V> {
fn hash<H: Hasher>(&self, state: &mut H) {
let mut kv = Vec::from_iter(&self.0);
Expand Down
2 changes: 2 additions & 0 deletions packages/core/api/actor/src/route/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ pub async fn create_build(
.compression
.map(ApiInto::api_into)
.unwrap_or(build::types::BuildCompression::None),
allocation_type: build::types::BuildAllocationType::Single,
allocation_total_slots: 1,
})
.await?;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE builds
ADD allocation_type INT NOT NULL DEFAULT 0,
ADD allocation_total_slots INT NOT NULL DEFAULT 1;
12 changes: 9 additions & 3 deletions packages/core/services/build/src/ops/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rivet_operation::prelude::proto::backend;
const MAX_UPLOAD_SIZE: u64 = util::file_size::gigabytes(8);
const MAX_JS_BUILD_UPLOAD_SIZE: u64 = util::file_size::megabytes(10);
use crate::{
types::{upload::PrepareFile, upload::PresignedUploadRequest, BuildCompression, BuildKind},
types::{upload::PrepareFile, upload::PresignedUploadRequest, BuildCompression, BuildAllocationType, BuildKind},
utils,
};

Expand All @@ -15,6 +15,8 @@ pub struct Input {
pub content: Content,
pub kind: BuildKind,
pub compression: BuildCompression,
pub allocation_type: BuildAllocationType,
pub allocation_total_slots: u64,
}

#[derive(Debug)]
Expand Down Expand Up @@ -158,10 +160,12 @@ pub async fn get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output> {
image_tag,
create_ts,
kind,
compression
compression,
allocation_type,
allocation_total_slots
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9)
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
",
build_id,
game_id,
Expand All @@ -172,6 +176,8 @@ pub async fn get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output> {
ctx.ts(),
input.kind as i32,
input.compression as i32,
input.allocation_type as i32,
input.allocation_total_slots as i64,
)
.await?;

Expand Down
8 changes: 8 additions & 0 deletions packages/core/services/build/src/ops/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub(crate) struct BuildRow {
create_ts: i64,
kind: i64,
compression: i64,
allocation_type: i64,
allocation_total_slots: i64,
tags: sqlx::types::Json<Box<serde_json::value::RawValue>>,
}

Expand All @@ -43,6 +45,10 @@ impl TryInto<types::Build> for BuildRow {
compression: unwrap!(types::BuildCompression::from_repr(
self.compression.try_into()?
)),
allocation_type: unwrap!(types::BuildAllocationType::from_repr(
self.allocation_type.try_into()?
)),
allocation_total_slots: self.allocation_total_slots.try_into()?,
// Filter out null values on tags
tags: serde_json::from_str::<HashMap<String, Option<String>>>(self.tags.0.get())?
.into_iter()
Expand Down Expand Up @@ -74,6 +80,8 @@ pub async fn build_get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output
create_ts,
kind,
compression,
allocation_type,
allocation_total_slots,
tags
FROM db_build.builds
WHERE build_id = ANY($1)
Expand Down
4 changes: 3 additions & 1 deletion packages/core/services/build/src/ops/resolve_for_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ async fn get_builds(
create_ts,
kind,
compression,
tags
tags,
allocation_type,
allocation_total_slots
FROM db_build.builds
WHERE env_id = $1 AND tags @> $2
",
Expand Down
10 changes: 10 additions & 0 deletions packages/core/services/build/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,19 @@ pub struct Build {
pub create_ts: i64,
pub kind: BuildKind,
pub compression: BuildCompression,
pub allocation_type: BuildAllocationType,
pub allocation_total_slots: u64,
pub tags: HashMap<String, String>,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize, Hash, PartialEq, Eq, FromRepr)]
#[serde(rename_all = "snake_case")]
pub enum BuildAllocationType {
None = 0,
Single = 1,
Multi = 2,
}

// TODO: Move to upload pkg when its converted to new ops
pub mod upload {
use std::convert::TryInto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

PUBLIC_IP=$(ip -4 route get 1.0.0.0 | awk '{print $7; exit}')

SUBNET_IPV4="172.26.64.0/20"
SUBNET_IPV4_GATEWAY_IP="172.26.64.1"
SUBNET_IPV6="fd00:db8:2::/64"

# MARK: Pegboard config
cat << 'EOF' > /etc/rivet-client/config.json
cat << EOF > /etc/rivet-client/config.json
{
"client": {
"cluster": {
Expand All @@ -16,7 +20,7 @@ cat << 'EOF' > /etc/rivet-client/config.json
}
},
"runner": {
"flavor": "__FLAVOR__"
"ip": "$SUBNET_IPV4_GATEWAY_IP",
},
Comment on lines +23 to 24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: There is a trailing comma after the IP configuration which is invalid JSON syntax

Suggested change
"ip": "$SUBNET_IPV4_GATEWAY_IP",
},
"ip": "$SUBNET_IPV4_GATEWAY_IP"
},

"images": {
"pull_addresses": {
Expand Down Expand Up @@ -57,8 +61,6 @@ EOF
#
# See Nomad equivalent: https://github.com/hashicorp/nomad/blob/a8f0f2612ef9d283ed903721f8453a0c0c3f51c5/client/allocrunner/networking_bridge_linux.go#L73
ADMIN_CHAIN="RIVET-ADMIN"
SUBNET_IPV4="172.26.64.0/20"
SUBNET_IPV6="fd00:db8:2::/64"

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
Expand Down
Loading
Loading