improve access to controller info

This commit is contained in:
Michael Kuhnt 2023-01-26 20:24:26 +01:00
parent 6a032bfaa2
commit 6cd18ff1fd
No known key found for this signature in database
GPG key ID: 088DC1E2EDC5A631
3 changed files with 17 additions and 25 deletions

View file

@ -115,10 +115,7 @@ func (a *APIController) handleWorkflowJobEvent(w http.ResponseWriter, r *http.Re
signature := r.Header.Get("X-Hub-Signature-256")
hookType := r.Header.Get("X-Github-Hook-Installation-Target-Type")
controllerInfo, err := a.r.GetControllerInfo(r.Context())
if err != nil {
log.Printf("failed to get controller info for metics labels: %q", err)
}
controllerInfo := a.r.GetControllerInfo(r.Context())
if err := a.r.DispatchWorkflowJob(hookType, signature, body); err != nil {
if errors.Is(err, gErrors.ErrNotFound) {

View file

@ -37,11 +37,7 @@ func (c *GarmCollector) Describe(ch chan<- *prometheus.Desc) {
}
func (c *GarmCollector) Collect(ch chan<- prometheus.Metric) {
controllerInfo, err := c.runner.GetControllerInfo(auth.GetAdminContext())
if err != nil {
log.Printf("error on fetching controllerInfo: %s", err)
// continue anyway
}
controllerInfo := c.runner.GetControllerInfo(auth.GetAdminContext())
c.CollectInstanceMetric(ch, controllerInfo.Hostname, controllerInfo.ControllerID.String())
c.CollectHealthMetric(ch, controllerInfo.Hostname, controllerInfo.ControllerID.String())