Skip to content
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
29 changes: 29 additions & 0 deletions lib/bolt/core/src/dep/k8s/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,22 @@ pub async fn gen_svc(exec_ctx: &ExecServiceContext) -> Vec<serde_json::Value> {
"data": secret_data
}));

// Create config for /etc/rivet
//
// Use cjson for consistent outputs
let regions_json = cjson::to_string(&project_ctx.ns().regions).unwrap();
specs.push(json!({
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": {
"name": format!("rivet-etc-{}", svc_ctx.name()),
"namespace": "rivet-service"
},
"data": {
"region_config.json": regions_json
}
}));

// Render ports
let (pod_ports, service_ports) = {
let mut pod_ports = Vec::new();
Expand Down Expand Up @@ -638,6 +654,19 @@ async fn build_volumes(
let mut volumes = Vec::<serde_json::Value>::new();
let mut volume_mounts = Vec::<serde_json::Value>::new();

// TODO: Move this to reading vanilla config inside service instead of populating this
// Add static config
volumes.push(json!({
"name": "rivet-etc",
"configMap": {
"name": format!("rivet-etc-{}", svc_ctx.name()),
}
}));
volume_mounts.push(json!({
"name": "rivet-etc",
"mountPath": "/etc/rivet"
}));

// Add volumes based on exec service
match driver {
// Mount the service binaries to execute directly in the container.
Expand Down
16 changes: 0 additions & 16 deletions lib/bolt/core/src/tasks/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ pub async fn generate_project(ctx: &ProjectContext, skip_config_sync_check: bool

// Generate root
generate_root(ctx.path()).await;

// Generate regions
generate_regions(ctx).await;
}

async fn generate_root(path: &Path) {
Expand Down Expand Up @@ -237,19 +234,6 @@ pub async fn generate_service(_ctx: &ServiceContext) {
// println!(" * Generating service {}", ctx.name());
}

async fn generate_regions(ctx: &ProjectContext) {
let svc = ctx.service_with_name("region-config-get").await;
let gen_path = svc.path().join("gen");
let gen_config_path = gen_path.join("region_config.json");

// Make gen dir
fs::create_dir_all(gen_path).await.unwrap();

// Write config. Use cjson in order to get deterministic output.
let regions_json = cjson::to_string(&ctx.ns().regions).unwrap();
write_if_different(&gen_config_path, &regions_json).await;
}

/// Writes to a file if the contents are different.
///
/// This prevents needlessly updating the modify timestamp of a Cargo manifest, which triggers a
Expand Down
2 changes: 0 additions & 2 deletions svc/pkg/region/ops/config-get/.gitignore

This file was deleted.

6 changes: 4 additions & 2 deletions svc/pkg/region/ops/config-get/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use proto::backend::pkg::*;
use rivet_operation::prelude::*;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use tokio::fs;

#[operation(name = "region-config-get")]
pub async fn handle(
Expand Down Expand Up @@ -29,12 +30,13 @@ pub async fn read() -> HashMap<String, region::config_get::Region> {
READ_CONFIG_ONCE
.get_or_init(|| async {
// Read config
let config_buf = include_bytes!("../gen/region_config.json");
let config_buf = fs::read("/etc/rivet/region_config.json")
.await
.expect("failed to read /region_config.json");
let config = serde_json::from_slice::<HashMap<String, Region>>(config_buf.as_slice())
.expect("invalid region config");

// Convert to proto

config
.into_iter()
.map(|(k, v)| {
Expand Down