Forked from
GitLab.org / gitlab-runner
9527 commits behind the upstream repository.
-
Kamil Trzciński (Back 2025-01-01) authored
Retry each machine removal to up 3 times. After that allow to perform one removal of all stuck machines (machine is tried to be removed more than 3 times), at most one machine per retry interval which is 30s.
Kamil Trzciński (Back 2025-01-01) authoredRetry each machine removal to up 3 times. After that allow to perform one removal of all stuck machines (machine is tried to be removed more than 3 times), at most one machine per retry interval which is 30s.
collector.go 1.36 KiB
package machine
import (
"github.com/prometheus/client_golang/prometheus"
)
func (m *machineProvider) collectDetails() (data machinesData) {
m.lock.RLock()
defer m.lock.RUnlock()
for _, details := range m.details {
if !details.isDead() {
data.Add(details)
}
}
return
}
// Describe implements prometheus.Collector.
func (m *machineProvider) Describe(ch chan<- *prometheus.Desc) {
m.totalActions.Describe(ch)
m.creationHistogram.Describe(ch)
ch <- m.currentStatesDesc
}
// Collect implements prometheus.Collector.
func (m *machineProvider) Collect(ch chan<- prometheus.Metric) {
data := m.collectDetails()
ch <- prometheus.MustNewConstMetric(m.currentStatesDesc, prometheus.GaugeValue, float64(data.Acquired), "acquired")
ch <- prometheus.MustNewConstMetric(m.currentStatesDesc, prometheus.GaugeValue, float64(data.Creating), "creating")
ch <- prometheus.MustNewConstMetric(m.currentStatesDesc, prometheus.GaugeValue, float64(data.Idle), "idle")
ch <- prometheus.MustNewConstMetric(m.currentStatesDesc, prometheus.GaugeValue, float64(data.Used), "used")
ch <- prometheus.MustNewConstMetric(m.currentStatesDesc, prometheus.GaugeValue, float64(data.Removing), "removing")
ch <- prometheus.MustNewConstMetric(m.currentStatesDesc, prometheus.GaugeValue, float64(data.StuckOnRemoving), "stuck-on-removing")
m.totalActions.Collect(ch)
m.creationHistogram.Collect(ch)
}