Skip to content

Commit 51e0f1c

Browse files
committed
feat: remove dcu variable and configurations
1 parent 1eeb02e commit 51e0f1c

File tree

7 files changed

+1
-88
lines changed

7 files changed

+1
-88
lines changed

bootstrap/feature/main.tf

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ variable "metrics_delay" {
2323
default = "30"
2424
}
2525

26-
variable "dcu_per_second" {
27-
type = map(string)
28-
default = {
29-
"mainnet" = "1"
30-
"preprod" = "1"
31-
"preview" = "1"
32-
"sanchonet" = "1"
33-
"vector-testnet" = "1"
34-
}
35-
}
36-
3726
variable "resources" {
3827
type = object({
3928
limits = object({

bootstrap/feature/operator.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ resource "kubernetes_deployment_v1" "operator" {
7171
value = var.metrics_delay
7272
}
7373

74-
env {
75-
name = "DCU_PER_SECOND"
76-
value = "mainnet=${var.dcu_per_second["mainnet"]},preprod=${var.dcu_per_second["preprod"]},preview=${var.dcu_per_second["preview"]},sanchonet=${var.dcu_per_second["sanchonet"]},vector-testnet=${var.dcu_per_second["vector-testnet"]}"
77-
}
78-
7974
resources {
8075
limits = {
8176
cpu = var.resources.limits.cpu

bootstrap/variables.tf

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@ variable "api_key_salt" {
3232
type = string
3333
}
3434

35-
variable "dcu_per_second" {
36-
type = map(string)
37-
default = {
38-
"mainnet" = "1"
39-
"preprod" = "1"
40-
"preview" = "1"
41-
"sanchonet" = "1"
42-
"vector-testnet" = "1"
43-
}
44-
}
45-
4635
variable "metrics_delay" {
4736
type = number
4837
default = 60

examples/manifest.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,6 @@ spec:
320320
value: "60"
321321
- name: PROMETHEUS_URL
322322
value: "http://prometheus/api/v1"
323-
- name: DCU_PER_SECOND
324-
value: "preview=5,preprod=5,mainnet=5"
325323
---
326324
apiVersion: v1
327325
kind: Service

operator/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ The controller will create a TLSroute on project namespace and a grant on node n
1515
| API_KEY_SALT | cardano-node-salt |
1616
| METRICS_DELAY | 5 |
1717
| PROMETHEUS_URL | |
18-
| DCU_PER_SECOND | NETWORK=NUMBER |
1918

2019
## Commands
2120

operator/src/config.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use lazy_static::lazy_static;
2-
use std::{collections::HashMap, env, time::Duration};
2+
use std::{env, time::Duration};
33

44
lazy_static! {
55
static ref CONTROLLER_CONFIG: Config = Config::from_env();
@@ -16,7 +16,6 @@ pub struct Config {
1616
pub api_key_salt: String,
1717
pub metrics_delay: Duration,
1818
pub prometheus_url: String,
19-
pub dcu_per_second: HashMap<String, f64>,
2019
}
2120

2221
impl Config {
@@ -32,18 +31,6 @@ impl Config {
3231
.expect("METRICS_DELAY must be a number"),
3332
),
3433
prometheus_url: env::var("PROMETHEUS_URL").expect("PROMETHEUS_URL must be set"),
35-
dcu_per_second: env::var("DCU_PER_SECOND")
36-
.expect("DCU_PER_SECOND must be set")
37-
.split(',')
38-
.map(|pair| {
39-
let parts: Vec<&str> = pair.split('=').collect();
40-
let dcu = parts[1]
41-
.parse::<f64>()
42-
.expect("DCU_PER_SECOND must be NETWORK=NUMBER");
43-
44-
(parts[0].into(), dcu)
45-
})
46-
.collect(),
4734
}
4835
}
4936
}

operator/src/metrics.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,13 @@ use crate::{get_config, CardanoNodePort, Config, Error, State};
1515

1616
#[derive(Clone)]
1717
pub struct Metrics {
18-
pub dcu: IntCounterVec,
1918
pub usage: IntCounterVec,
2019
pub reconcile_failures: IntCounterVec,
2120
pub metrics_failures: IntCounterVec,
2221
}
2322

2423
impl Default for Metrics {
2524
fn default() -> Self {
26-
let dcu = IntCounterVec::new(
27-
opts!("dmtr_consumed_dcus", "quantity of dcu consumed",),
28-
&["project", "service", "service_type", "tenancy"],
29-
)
30-
.unwrap();
31-
3225
let usage = IntCounterVec::new(
3326
opts!("usage", "Feature usage",),
3427
&["feature", "project", "resource_name", "tier"],
@@ -54,7 +47,6 @@ impl Default for Metrics {
5447
.unwrap();
5548

5649
Metrics {
57-
dcu,
5850
usage,
5951
reconcile_failures,
6052
metrics_failures,
@@ -66,7 +58,6 @@ impl Metrics {
6658
pub fn register(self, registry: &Registry) -> Result<Self, prometheus::Error> {
6759
registry.register(Box::new(self.reconcile_failures.clone()))?;
6860
registry.register(Box::new(self.metrics_failures.clone()))?;
69-
registry.register(Box::new(self.dcu.clone()))?;
7061
registry.register(Box::new(self.usage.clone()))?;
7162

7263
Ok(self)
@@ -84,22 +75,6 @@ impl Metrics {
8475
.inc()
8576
}
8677

87-
pub fn count_dcu_consumed(&self, project: &str, network: &str, dcu: f64) {
88-
let service = format!("{}-{}", CardanoNodePort::kind(&()), network);
89-
let service_type = format!(
90-
"{}.{}",
91-
CardanoNodePort::plural(&()),
92-
CardanoNodePort::group(&())
93-
);
94-
let tenancy = "proxy";
95-
96-
let dcu: u64 = dcu.ceil() as u64;
97-
98-
self.dcu
99-
.with_label_values::<&str>(&[project, &service, &service_type, tenancy])
100-
.inc_by(dcu);
101-
}
102-
10378
pub fn count_usage(&self, project: &str, resource_name: &str, tier: &str, value: f64) {
10479
let feature = &CardanoNodePort::kind(&());
10580
let value: u64 = value.ceil() as u64;
@@ -228,27 +203,8 @@ pub fn run_metrics_collector(state: Arc<State>) {
228203
warn!(instance, "invalid network to the regex");
229204
continue;
230205
}
231-
let network_captures = network_captures.unwrap();
232-
let network = network_captures.get(1).unwrap().as_str();
233-
234-
let dcu_per_second = config.dcu_per_second.get(network);
235-
if dcu_per_second.is_none() {
236-
let error = Error::ConfigError(format!(
237-
"dcu_per_package not configured to {} network",
238-
network
239-
));
240-
error!(error = error.to_string());
241-
state.metrics.metrics_failure(&error);
242-
continue;
243-
}
244-
245-
let dcu_per_second = dcu_per_second.unwrap();
246206
let total_exec_time = result.value * (interval as f64);
247207

248-
let dcu = total_exec_time * dcu_per_second;
249-
250-
state.metrics.count_dcu_consumed(project, network, dcu);
251-
252208
if let Some(tier) = result.metric.tier {
253209
state
254210
.metrics

0 commit comments

Comments
 (0)