diff --git a/bootstrap/feature/main.tf b/bootstrap/feature/main.tf index 89a4814..d46fdab 100644 --- a/bootstrap/feature/main.tf +++ b/bootstrap/feature/main.tf @@ -24,17 +24,6 @@ variable "metrics_delay" { default = "30" } -variable "dcu_per_request" { - type = map(string) - default = { - "mainnet" = "10" - "preprod" = "5" - "preview" = "5" - "sanchonet" = "5" - "vector-testnet" = "5" - } -} - variable "resources" { type = object({ limits = object({ diff --git a/bootstrap/feature/operator.tf b/bootstrap/feature/operator.tf index e9f4145..bbbd0ba 100644 --- a/bootstrap/feature/operator.tf +++ b/bootstrap/feature/operator.tf @@ -55,11 +55,6 @@ resource "kubernetes_deployment_v1" "operator" { value = var.metrics_delay } - env { - name = "DCU_PER_REQUEST" - value = "mainnet=${var.dcu_per_request["mainnet"]},preprod=${var.dcu_per_request["preprod"]},preview=${var.dcu_per_request["preview"]},vector-testnet=${var.dcu_per_request["vector-testnet"]}" - } - env { name = "DEFAULT_SUBMITAPI_VERSION" value = "stable" diff --git a/bootstrap/main.tf b/bootstrap/main.tf index b538641..fa5c106 100644 --- a/bootstrap/main.tf +++ b/bootstrap/main.tf @@ -13,7 +13,6 @@ module "submitapi_v1_feature" { ingress_class = var.ingress_class dns_zone = var.dns_zone api_key_salt = var.api_key_salt - dcu_per_request = var.dcu_per_request resources = var.operator_resources } diff --git a/bootstrap/variables.tf b/bootstrap/variables.tf index 64977bc..7e22562 100644 --- a/bootstrap/variables.tf +++ b/bootstrap/variables.tf @@ -37,17 +37,6 @@ variable "api_key_salt" { type = string } -variable "dcu_per_request" { - type = map(string) - default = { - "mainnet" = "10" - "preprod" = "5" - "preview" = "5" - "sanchonet" = "5" - "vector-testnet" = "5" - } -} - variable "metrics_delay" { type = number default = 60 diff --git a/operator/README.md b/operator/README.md index 441b659..3861ade 100644 --- a/operator/README.md +++ b/operator/README.md @@ -11,7 +11,6 @@ This operator will create a key into the CRD to allow SubmitApi to be accessed e | API_KEY_SALT | submitapi-salt | | METRICS_DELAY | 40 | | PROMETHEUS_URL | | -| DCU_PER_REQUEST | preview=5,preprod=5,mainnet=5 | | DEFAULT_SUBMITAPI_VERSION | v3 | ## Port CRD diff --git a/operator/src/config.rs b/operator/src/config.rs index 12ff499..257bdd8 100644 --- a/operator/src/config.rs +++ b/operator/src/config.rs @@ -1,5 +1,5 @@ use lazy_static::lazy_static; -use std::{collections::HashMap, env, time::Duration}; +use std::{env, time::Duration}; lazy_static! { static ref CONTROLLER_CONFIG: Config = Config::from_env(); @@ -16,7 +16,6 @@ pub struct Config { pub api_key_salt: String, pub metrics_delay: Duration, pub prometheus_url: String, - pub dcu_per_request: HashMap, pub default_submitapi_version: String, } @@ -33,18 +32,6 @@ impl Config { .expect("METRICS_DELAY must be a number"), ), prometheus_url: env::var("PROMETHEUS_URL").expect("PROMETHEUS_URL must be set"), - dcu_per_request: env::var("DCU_PER_REQUEST") - .expect("DCU_PER_REQUEST must be set") - .split(',') - .map(|pair| { - let parts: Vec<&str> = pair.split('=').collect(); - let dcu = parts[1] - .parse::() - .expect("DCU_PER_REQUEST must be NETWORK=NUMBER"); - - (parts[0].into(), dcu) - }) - .collect(), default_submitapi_version: env::var("DEFAULT_SUBMITAPI_VERSION").unwrap_or("v3".into()), } } diff --git a/operator/src/metrics.rs b/operator/src/metrics.rs index 3b080ac..ceb3460 100644 --- a/operator/src/metrics.rs +++ b/operator/src/metrics.rs @@ -14,7 +14,6 @@ use crate::{get_config, Error, State, SubmitApiPort}; #[derive(Clone)] pub struct Metrics { - pub dcu: IntCounterVec, pub usage: IntCounterVec, pub reconcile_failures: IntCounterVec, pub metrics_failures: IntCounterVec, @@ -22,12 +21,6 @@ pub struct Metrics { impl Default for Metrics { fn default() -> Self { - let dcu = IntCounterVec::new( - opts!("dmtr_consumed_dcus", "quantity of dcu consumed",), - &["project", "service", "service_type", "tenancy"], - ) - .unwrap(); - let usage = IntCounterVec::new( opts!("usage", "Feature usage",), &["feature", "project", "resource_name", "tier"], @@ -53,7 +46,6 @@ impl Default for Metrics { .unwrap(); Metrics { - dcu, usage, reconcile_failures, metrics_failures, @@ -65,7 +57,6 @@ impl Metrics { pub fn register(self, registry: &Registry) -> Result { registry.register(Box::new(self.reconcile_failures.clone()))?; registry.register(Box::new(self.metrics_failures.clone()))?; - registry.register(Box::new(self.dcu.clone()))?; registry.register(Box::new(self.usage.clone()))?; Ok(self) @@ -83,22 +74,6 @@ impl Metrics { .inc() } - pub fn count_dcu_consumed(&self, project: &str, network: &str, dcu: f64) { - let service = format!("{}-{}", SubmitApiPort::kind(&()), network); - let service_type = format!( - "{}.{}", - SubmitApiPort::plural(&()), - SubmitApiPort::group(&()) - ); - let tenancy = "proxy"; - - let dcu: u64 = dcu.ceil() as u64; - - self.dcu - .with_label_values(&[project, &service, &service_type, tenancy]) - .inc_by(dcu); - } - pub fn count_usage(&self, project: &str, resource_name: &str, tier: &str, value: f64) { let feature = &SubmitApiPort::kind(&()); let value: u64 = value.ceil() as u64; @@ -175,26 +150,11 @@ pub fn run_metrics_collector(state: Arc) { let project = project_captures.get(1).unwrap().as_str(); let resource_name = project_captures.get(2).unwrap().as_str(); - let network = result.metric.network.unwrap(); let tier = result.metric.tier.unwrap(); - let dcu_per_request = config.dcu_per_request.get(&network); - if dcu_per_request.is_none() { - let error = Error::ConfigError(format!( - "dcu_per_request not configured to {} network", - network - )); - error!(error = error.to_string()); - state.metrics.metrics_failure(&error); - continue; - } - let dcu_per_request = dcu_per_request.unwrap(); - - let dcu = result.value * dcu_per_request; - state.metrics.count_dcu_consumed(project, &network, dcu); state .metrics - .count_usage(project, resource_name, &tier, dcu); + .count_usage(project, resource_name, &tier, result.value); } } });