catchpoint / workflow-telemetry-action

Github action to collect metrics (CPU, memory, I/O, etc ...) from your workflows to help you debug and optimize your CI/CD pipeline
Apache License 2.0
292 stars 39 forks source link

Post Workflow Telemetry fails with 'Error: Resource not accessible by integration' #21

Closed tim-silico closed 2 years ago

tim-silico commented 2 years ago

Hi,

I've added the step to my workflow with.

- name: Workflow Telemetry
  uses: runforesight/workflow-telemetry-action@v1

And the post step is failing with the error Error: Resource not accessible by integration

Setup Log:

##[debug]Evaluating condition for step: 'Workflow Telemetry'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Workflow Telemetry
##[debug]Register post job cleanup for action: runforesight/workflow-telemetry-action@v1
##[debug]Loading inputs
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run runforesight/workflow-telemetry-action@v1
[Workflow Telemetry] Initializing ...
[Workflow Telemetry] Starting step tracer ...
[Workflow Telemetry] Started step tracer
[Workflow Telemetry] Starting stat collector ...
[Workflow Telemetry] Started stat collector
[Workflow Telemetry] Starting process tracer ...
::save-state name=PROC_TRACER_PID::1745588
##[debug]Save intra-action state PROC_TRACER_PID = 1745588
[Workflow Telemetry] Started process tracer
[Workflow Telemetry] Initialization completed
##[debug]Node Action run completed with exit code 0
##[debug]Finishing: Workflow Telemetry

Post log:

##[debug]Evaluating condition for step: 'Post Workflow Telemetry'
##[debug]Evaluating: always()
##[debug]Evaluating always:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Post Workflow Telemetry
##[debug]Loading inputs
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Post job cleanup.
[Workflow Telemetry] Finishing ...
(node:1747867) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Error: Resource not accessible by integration
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Post Workflow Telemetry

I suspect this is related to permissions as we have restricted them in our workflows, but I can't work out which need to be enabled from a cursory look. We're also using a custom runner, but hopefully that won't cause any issues?

permissions:
  contents: read
  packages: write

Thanks for developing this, it looks really fantastic.

serkan-ozal commented 2 years ago

Hi @tim-silico,

workflow-telemetric-action needs actions:read permission to be able to access current workflow job info. We have applied a fix to prevent action from failing (but logs error message) in case of lack of actions:read permission.

Could you please try by adding actions:read permission:

permissions:
  actions: read
  ...
tim-silico commented 2 years ago

Hi @serkan-ozal

Thanks so much, that's fixed our issue. We're still getting a failure during posting, but it's during the comment posting, which we don't want anyway so I've remove it.

I suspect it's this line: https://github.com/runforesight/workflow-telemetry-action/blob/cd839468e37dd167ab4e5328cb95b0f8689dcf19/src/post.ts#L102 And giving pr write permissions would fix it though.

The Job Summary is exactly what we need, should help debug our slow workflow.

serkan-ozal commented 2 years ago

Hi @tim-silico, you can disable PR comment feature by setting comment_on_pr input to false as mentioned here: https://github.com/runforesight/workflow-telemetry-action#configuration

In this case (PR comment disabled), you still will be able to see the results in the Github job summary page.

oliversalzburg commented 1 year ago

Just FYI, because you want to write a comment into a pull request, you also need pull-requests: write.

sjoedwards commented 9 months ago

Hi! Can we please update the readme with this very useful information - thank you :)

serkan-ozal commented 8 months ago

Thanks for informing @oliversalzburg @sjoedwards. Added required permission to the description of comment_on_pr configuration.