boot outcomes metric: fix labels and add some checks for the new metric
[arvados.git] / lib / dispatchcloud / worker / pool.go
index bcf35e285486d817000ee07ef825b185a8489b84..12bc1cdd71636263cebc0c8f21bd283d791aec04 100644 (file)
@@ -437,6 +437,7 @@ func (wp *Pool) Shutdown(it arvados.InstanceType) bool {
                for _, wkr := range wp.workers {
                        if wkr.idleBehavior != IdleBehaviorHold && wkr.state == tryState && wkr.instType == it {
                                logger.WithField("Instance", wkr.instance.ID()).Info("shutting down")
+                               wkr.reportBootOutcome(BootOutcomeAborted)
                                wkr.shutdown()
                                return true
                        }
@@ -599,7 +600,7 @@ func (wp *Pool) registerMetrics(reg *prometheus.Registry) {
                Subsystem: "dispatchcloud",
                Name:      "boot_outcomes",
                Help:      "Boot outcomes by type.",
-       }, []string{"state"})
+       }, []string{"outcome"})
        for k := range validBootOutcomes {
                wp.mBootOutcomes.WithLabelValues(string(k)).Add(0)
        }
@@ -776,6 +777,7 @@ func (wp *Pool) KillInstance(id cloud.InstanceID, reason string) error {
                return errors.New("instance not found")
        }
        wkr.logger.WithField("Reason", reason).Info("shutting down")
+       wkr.reportBootOutcome(BootOutcomeAborted)
        wkr.shutdown()
        return nil
 }