Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ func (k *VMwareResourceCapacityKPI) Init(db *db.DB, client client.Client, opts c
"enabled",
"decommissioned",
"external_customer",
"disabled_reason",
"pinned_projects",
"disabled_reason",
"pinned_project_ids",
},
nil,
)
Expand All @@ -64,6 +65,7 @@ func (k *VMwareResourceCapacityKPI) Init(db *db.DB, client client.Client, opts c
"decommissioned",
"external_customer",
"pinned_projects",
"pinned_project_ids",
},
nil,
)
Expand Down Expand Up @@ -152,9 +154,11 @@ func (k *VMwareResourceCapacityKPI) exportCapacityMetricVMware(ch chan<- prometh
enabled := strconv.FormatBool(host.Enabled)
decommissioned := strconv.FormatBool(host.Decommissioned)
externalCustomer := strconv.FormatBool(host.ExternalCustomer)
pinnedProjects := ""
pinnedProjectIds := ""
pinnedProjects := "false"
if host.PinnedProjects != nil {
pinnedProjects = *host.PinnedProjects
pinnedProjectIds = *host.PinnedProjects
pinnedProjects = "true"
}

disabledReason := "-"
Expand All @@ -174,8 +178,9 @@ func (k *VMwareResourceCapacityKPI) exportCapacityMetricVMware(ch chan<- prometh
enabled,
decommissioned,
externalCustomer,
disabledReason,
pinnedProjects,
disabledReason,
pinnedProjectIds,
)

ch <- prometheus.MustNewConstMetric(
Expand All @@ -191,5 +196,6 @@ func (k *VMwareResourceCapacityKPI) exportCapacityMetricVMware(ch chan<- prometh
decommissioned,
externalCustomer,
pinnedProjects,
pinnedProjectIds,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func TestVMwareResourceCapacityKPI_Collect_AbsoluteMetric(t *testing.T) {
WorkloadType string
DisabledReason string
PinnedProjects string
PinnedProjectIds string
Value float64
}

Expand Down Expand Up @@ -203,6 +204,7 @@ func TestVMwareResourceCapacityKPI_Collect_AbsoluteMetric(t *testing.T) {
WorkloadType: labels["workload_type"],
DisabledReason: labels["disabled_reason"],
PinnedProjects: labels["pinned_projects"],
PinnedProjectIds: labels["pinned_project_ids"],
Value: m.GetGauge().GetValue(),
}
}
Expand All @@ -218,7 +220,8 @@ func TestVMwareResourceCapacityKPI_Collect_AbsoluteMetric(t *testing.T) {
CPUArchitecture: "cascade-lake",
WorkloadType: "general-purpose",
DisabledReason: "-",
PinnedProjects: "",
PinnedProjects: "false",
PinnedProjectIds: "",
Value: 60, // 100 - 40
},
"vmware-host-ram": {
Expand All @@ -231,7 +234,8 @@ func TestVMwareResourceCapacityKPI_Collect_AbsoluteMetric(t *testing.T) {
CPUArchitecture: "cascade-lake",
WorkloadType: "general-purpose",
DisabledReason: "-",
PinnedProjects: "",
PinnedProjects: "false",
PinnedProjectIds: "",
Value: 160, // 200 - 40
},
"vmware-host-disk": {
Expand All @@ -244,7 +248,8 @@ func TestVMwareResourceCapacityKPI_Collect_AbsoluteMetric(t *testing.T) {
CPUArchitecture: "cascade-lake",
WorkloadType: "general-purpose",
DisabledReason: "-",
PinnedProjects: "",
PinnedProjects: "false",
PinnedProjectIds: "",
Value: 260, // 300 - 40
},
}
Expand Down Expand Up @@ -284,7 +289,7 @@ func TestVMwareResourceCapacityKPI_Collect_TotalMetric(t *testing.T) {
Decommissioned: true,
ExternalCustomer: true,
DisabledReason: nil,
PinnedProjects: nil,
PinnedProjects: testlib.Ptr("project1,project2"),
},
// Skip this because it's not a VMware host
&compute.HostDetails{
Expand Down Expand Up @@ -396,6 +401,7 @@ func TestVMwareResourceCapacityKPI_Collect_TotalMetric(t *testing.T) {
CPUArchitecture string
WorkloadType string
PinnedProjects string
PinnedProjectIds string
Value float64
}

Expand Down Expand Up @@ -432,6 +438,7 @@ func TestVMwareResourceCapacityKPI_Collect_TotalMetric(t *testing.T) {
CPUArchitecture: labels["cpu_architecture"],
WorkloadType: labels["workload_type"],
PinnedProjects: labels["pinned_projects"],
PinnedProjectIds: labels["pinned_project_ids"],
Value: m.GetGauge().GetValue(),
}
}
Expand All @@ -446,7 +453,8 @@ func TestVMwareResourceCapacityKPI_Collect_TotalMetric(t *testing.T) {
ExternalCustomer: "true",
CPUArchitecture: "cascade-lake",
WorkloadType: "general-purpose",
PinnedProjects: "",
PinnedProjects: "true",
PinnedProjectIds: "project1,project2",
Value: 100,
},
"vmware-host-ram": {
Expand All @@ -458,7 +466,8 @@ func TestVMwareResourceCapacityKPI_Collect_TotalMetric(t *testing.T) {
ExternalCustomer: "true",
CPUArchitecture: "cascade-lake",
WorkloadType: "general-purpose",
PinnedProjects: "",
PinnedProjects: "true",
PinnedProjectIds: "project1,project2",
Value: 200,
},
"vmware-host-disk": {
Expand All @@ -470,7 +479,8 @@ func TestVMwareResourceCapacityKPI_Collect_TotalMetric(t *testing.T) {
ExternalCustomer: "true",
CPUArchitecture: "cascade-lake",
WorkloadType: "general-purpose",
PinnedProjects: "",
PinnedProjects: "true",
PinnedProjectIds: "project1,project2",
Value: 300,
},
}
Expand Down
Loading