Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing explicit check for workflow status failure #230

Closed
ventsislav-georgiev opened this issue Jul 12, 2023 · 10 comments
Closed

Missing explicit check for workflow status failure #230

ventsislav-georgiev opened this issue Jul 12, 2023 · 10 comments
Labels
bug Something isn't working
Milestone

Comments

@ventsislav-georgiev
Copy link
Contributor

The workflow status is documented to have 14 unique values: completed, action_required, cancelled, failure, neutral, skipped, stale, success, timed_out, in_progress, queued, requested, waiting, pending
Ref: https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28

From looking at the code:

func conclusionToGauge(conclusion string) float64 {
switch conclusion {
case "completed":
return 1.0
case "action_required":
return 2.0
case "cancelled":
return 3.0
case "neutral":
return 4.0
case "skipped":
return 5.0
case "stale":
return 6.0
case "success":
return 7.0
case "timed_out":
return 8.0
case "in_progress":
return 9.0
case "queued":
return 10.0
case "requested":
return 11.0
case "waiting":
return 12.0
case "pending":
return 13.0
}
return 0.0
}

There is no check if the conclusion is failure and the only way to match against that is to use 0 as a failure status.
Is this expected?

@tboerger
Copy link
Member

Yes, 0 should be used for failure. This is something that needs to be properly documented.

@ventsislav-georgiev
Copy link
Contributor Author

Something seems to be wrong with the status reported. I'll have to debug for details but it seems that when the workflow is In Progress on Github, getting the metrics from github_exporter reports 0 for github_workflow_status. It then changes to 7 when the workflow completes.

@ventsislav-georgiev
Copy link
Contributor Author

@tboerger I've added the following log:
image

And testing by running a workflow and querying the /metrics endpoint from a local build. Doesn't matter if the Github status is Queued or In Progress, the log is:

{"collector":"workflow","conclusion":"","level":"info","msg":"Returned 0 as conclusion","ts":"2023-07-12T16:39:24.072135Z"}

It seems the lib used for querying the API returns and empty string in this case...

@ventsislav-georgiev
Copy link
Contributor Author

The label status (record.GetStatus()) seems to be the one with the expected queued, in_progress and other values. Conclusion returns value after the workflow is finished and it cannot be in most states that are cases in the switch.

@ventsislav-georgiev
Copy link
Contributor Author

@tboerger I've pushed a small PR for the above scenario. Let me know what you think.

@tboerger tboerger added the bug Something isn't working label Jul 13, 2023
@tboerger tboerger added this to the v2.3.0 milestone Jul 13, 2023
@tboerger
Copy link
Member

Please give it a try with the latest tag of the image, this should work now. After getting it confirmed by you I would tag the new release v2.3.0

@ventsislav-georgiev
Copy link
Contributor Author

@tboerger Thanks! Tried the latest tag and it works as expected, scraping Queued and In Progress states.

@ventsislav-georgiev
Copy link
Contributor Author

@tboerger will you have time to push the v2.3.0 release?

@tboerger
Copy link
Member

Since nobody complained about it I think I will roll a release after merging #236 and updating the changelog.

@tboerger
Copy link
Member

I have just pushed v2.3.0, will be available in a few minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants