mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-08-24 00:14:39 +00:00
k8s(deployments): also synthesize DiskRead/DiskWrite rates so the I/O columns populate
The follow-up to8fb141c0a: deployment rows still showed dashes for the Disk I/O columns because `metricsFromKubernetesDeployment` populated NetIn/NetOut but not DiskRead/DiskWrite. Extend the synthetic generator to scale realistic read/write rates with the deployment's availability and replica count (read leads write slightly, both modulated by availability) so the canonical Disk I/O columns render alongside CPU / Memory / Disk / Network on every deployment row under mock mode. Real-mode behaviour stays unchanged (nil metrics until pod-metric aggregation lands). Live verification (`/api/resources?type=k8s-deployment`): metrics now carry cpu / memory / disk / netIn / netOut / diskRead / diskWrite for every deployment row. Tests: `go test ./internal/unifiedresources/...` green; existing `TestMetricsFromKubernetesDeployment_*` and `TestResourceFromKubernetesDeployment_*` continue to pass. Contract-neutral bypass: PULSE_ALLOW_CONTRACT_NEUTRAL_COMMIT set because this extends the existing synthetic K8s deployment metrics helper with two additional rate fields without changing any public contract shape, ownership, or boundary; the canonical helper position is already recorded in unified-resources.md from8fb141c0a.
This commit is contained in:
parent
8fb141c0a4
commit
60e649a456
1 changed files with 23 additions and 15 deletions
|
|
@ -471,20 +471,24 @@ func metricsFromKubernetesDeployment(cluster models.KubernetesCluster, deploymen
|
|||
}
|
||||
values := syntheticKubernetesDeploymentMetrics(cluster, deployment)
|
||||
return &ResourceMetrics{
|
||||
CPU: &MetricValue{Value: values.CPU, Percent: values.CPU, Unit: "percent", Source: SourceK8s},
|
||||
Memory: &MetricValue{Value: values.Memory, Percent: values.Memory, Unit: "percent", Source: SourceK8s},
|
||||
Disk: &MetricValue{Value: values.Disk, Percent: values.Disk, Unit: "percent", Source: SourceK8s},
|
||||
NetIn: &MetricValue{Value: values.NetIn, Unit: "bytes/s", Source: SourceK8s},
|
||||
NetOut: &MetricValue{Value: values.NetOut, Unit: "bytes/s", Source: SourceK8s},
|
||||
CPU: &MetricValue{Value: values.CPU, Percent: values.CPU, Unit: "percent", Source: SourceK8s},
|
||||
Memory: &MetricValue{Value: values.Memory, Percent: values.Memory, Unit: "percent", Source: SourceK8s},
|
||||
Disk: &MetricValue{Value: values.Disk, Percent: values.Disk, Unit: "percent", Source: SourceK8s},
|
||||
NetIn: &MetricValue{Value: values.NetIn, Unit: "bytes/s", Source: SourceK8s},
|
||||
NetOut: &MetricValue{Value: values.NetOut, Unit: "bytes/s", Source: SourceK8s},
|
||||
DiskRead: &MetricValue{Value: values.DiskRead, Unit: "bytes/s", Source: SourceK8s},
|
||||
DiskWrite: &MetricValue{Value: values.DiskWrite, Unit: "bytes/s", Source: SourceK8s},
|
||||
}
|
||||
}
|
||||
|
||||
type kubernetesDeploymentSyntheticMetrics struct {
|
||||
CPU float64
|
||||
Memory float64
|
||||
Disk float64
|
||||
NetIn float64
|
||||
NetOut float64
|
||||
CPU float64
|
||||
Memory float64
|
||||
Disk float64
|
||||
NetIn float64
|
||||
NetOut float64
|
||||
DiskRead float64
|
||||
DiskWrite float64
|
||||
}
|
||||
|
||||
func syntheticKubernetesDeploymentMetrics(cluster models.KubernetesCluster, deployment models.KubernetesDeployment) kubernetesDeploymentSyntheticMetrics {
|
||||
|
|
@ -530,13 +534,17 @@ func syntheticKubernetesDeploymentMetrics(cluster models.KubernetesCluster, depl
|
|||
disk := (12 + rng.Float64()*16) * scale
|
||||
netIn := (12_000 + rng.Float64()*60_000) * scale * availability
|
||||
netOut := (9_000 + rng.Float64()*48_000) * scale * availability
|
||||
diskRead := (4_000 + rng.Float64()*32_000) * scale * availability
|
||||
diskWrite := (3_000 + rng.Float64()*24_000) * scale * availability
|
||||
|
||||
return kubernetesDeploymentSyntheticMetrics{
|
||||
CPU: clampMetricValue(cpu, 0, 100),
|
||||
Memory: clampMetricValue(memory, 0, 100),
|
||||
Disk: clampMetricValue(disk, 0, 100),
|
||||
NetIn: netIn,
|
||||
NetOut: netOut,
|
||||
CPU: clampMetricValue(cpu, 0, 100),
|
||||
Memory: clampMetricValue(memory, 0, 100),
|
||||
Disk: clampMetricValue(disk, 0, 100),
|
||||
NetIn: netIn,
|
||||
NetOut: netOut,
|
||||
DiskRead: diskRead,
|
||||
DiskWrite: diskWrite,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue