Skip to content

Commit dc19f33

Browse files
authored
feat(config): Add version configuration for the replicator (#350)
1 parent 6c5e51c commit dc19f33

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

etl-api/src/k8s/http.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ const LOGS_VOLUME_NAME: &str = "logs";
4848
pub const TRUSTED_ROOT_CERT_CONFIG_MAP_NAME: &str = "trusted-root-certs-config";
4949
/// Key inside the trusted root certificates ConfigMap.
5050
pub const TRUSTED_ROOT_CERT_KEY_NAME: &str = "trusted_root_certs";
51-
/// Environment variable for the Postgres password.
52-
const PG_PASSWORD_ENV_VAR_NAME: &str = "APP_PIPELINE__PG_CONNECTION__PASSWORD";
53-
/// Environment variable for the BigQuery service account key.
54-
const BIG_QUERY_SA_KEY_ENV_VAR_NAME: &str = "APP_DESTINATION__BIG_QUERY__SERVICE_ACCOUNT_KEY";
5551
/// Pod template annotation used to trigger rolling restarts.
5652
pub const RESTARTED_AT_ANNOTATION_KEY: &str = "etl.supabase.com/restarted-at";
5753
/// Label used to identify replicator pods.
@@ -420,6 +416,10 @@ impl K8sClient for HttpK8sClient {
420416
"name": "APP_ENVIRONMENT",
421417
"value": environment.to_string()
422418
},
419+
{
420+
"name": "APP_VERSION",
421+
"value": replicator_image
422+
},
423423
{
424424
"name": "APP_SENTRY__DSN",
425425
"valueFrom": {
@@ -430,7 +430,7 @@ impl K8sClient for HttpK8sClient {
430430
}
431431
},
432432
{
433-
"name": PG_PASSWORD_ENV_VAR_NAME,
433+
"name": "APP_PIPELINE__PG_CONNECTION__PASSWORD",
434434
"valueFrom": {
435435
"secretKeyRef": {
436436
"name": postgres_secret_name,
@@ -439,7 +439,7 @@ impl K8sClient for HttpK8sClient {
439439
}
440440
},
441441
{
442-
"name": BIG_QUERY_SA_KEY_ENV_VAR_NAME,
442+
"name": "APP_DESTINATION__BIG_QUERY__SERVICE_ACCOUNT_KEY",
443443
"valueFrom": {
444444
"secretKeyRef": {
445445
"name": bq_secret_name,

etl-replicator/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ mod config;
1818
mod core;
1919
mod migrations;
2020

21+
/// The name of the environment variable which contains version information for this replicator.
22+
const APP_VERSION_ENV_NAME: &str = "APP_VERSION";
23+
2124
/// Entry point for the replicator service.
2225
///
2326
/// Loads configuration, initializes tracing and Sentry, starts the async runtime,
@@ -92,9 +95,15 @@ fn init_sentry() -> anyhow::Result<Option<sentry::ClientInitGuard>> {
9295
..Default::default()
9396
});
9497

98+
// We load the version of the replicator which is specified via environment variable.
99+
let version = std::env::var(APP_VERSION_ENV_NAME);
100+
95101
// Set service tag to differentiate replicator from other services
96102
sentry::configure_scope(|scope| {
97103
scope.set_tag("service", "replicator");
104+
if let Ok(version) = version {
105+
scope.set_tag("version", version);
106+
}
98107
});
99108

100109
return Ok(Some(guard));

0 commit comments

Comments
 (0)