question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Runner should cleanup _temp dir with sudo

See original GitHub issue

Describe the bug

runner failed to cleanup _temp due to the permission issue.

To Reproduce Steps to reproduce the behavior:

  1. use one docker action that will write file to _github_home dir.

Expected behavior

_temp directory should be cleanup successfully.

Runner Version and Platform

I run self hosted runner 2.263 on ubunt 18.04

What’s not working?

ubuntu@ip-172-31-2-243:/opt/actions-runner/_work/_temp/_github_home$ ls -al
total 16
drwxr-xr-x 4 ubuntu ubuntu 4096 Jun  9 15:08 .
drwxr-xr-x 3 ubuntu ubuntu 4096 Jun  9 15:11 ..
drwx------ 2 root   root   4096 Jun  9 15:07 .docker
drwxr-x--- 3 root   root   4096 Jun  9 15:08 .kube

Job Log Output

None

Runner and Worker’s Diagnostic Logs

[2020-06-09 15:08:34Z INFO TempDirectoryManager] Cleaning runner temp folder: /opt/actions-runner/_work/_temp
[2020-06-09 15:08:34Z ERR  TempDirectoryManager] System.AggregateException: One or more errors occurred. (One or more errors occurred. (Access to the path '/opt/actions-runner/_work/_temp/_github_home/.kube' is denied.)) (Access to the path '/opt/actions-runner/_work/_temp/_github_home/.kube' is denied.)
 ---> System.UnauthorizedAccessException: Access to the path '/opt/actions-runner/_work/_temp/_github_home/.kube' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
   at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
   at System.IO.Enumeration.FileSystemEnumerableFactory.FileSystemInfos(String directory, String expression, EnumerationOptions options, Boolean isNormalized)
   at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at System.IO.DirectoryInfo.GetFileSystemInfos()
   at GitHub.Runner.Sdk.IOUtil.Enumerate(DirectoryInfo directory, CancellationTokenSource tokenSource)+MoveNext()
   at System.Linq.Parallel.PartitionedDataSource`1.ContiguousChunkLazyEnumerator.MoveNext(T& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
   --- End of inner exception stack trace ---
   at System.Linq.Parallel.QueryTaskGroupState.QueryEnd(Boolean userInitiatedDispose)
   at System.Linq.Parallel.SpoolingTask.SpoolForAll[TInputOutput,TIgnoreKey](QueryTaskGroupState groupState, PartitionedStream`2 partitions, TaskScheduler taskScheduler)
   at System.Linq.Parallel.DefaultMergeHelper`2.System.Linq.Parallel.IMergeHelper<TInputOutput>.Execute()
   at System.Linq.Parallel.MergeExecutor`1.Execute()
   at System.Linq.Parallel.MergeExecutor`1.Execute[TKey](PartitionedStream`2 partitions, Boolean ignoreOutput, ParallelMergeOptions options, TaskScheduler taskScheduler, Boolean isOrdered, CancellationState cancellationState, Int32 queryId)
   at System.Linq.Parallel.PartitionedStreamMerger`1.Receive[TKey](PartitionedStream`2 partitionedStream)
   at System.Linq.Parallel.ForAllOperator`1.WrapPartitionedStream[TKey](PartitionedStream`2 inputStream, IPartitionedStreamRecipient`1 recipient, Boolean preferStriping, QuerySettings settings)
   at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.ChildResultsRecipient.Receive[TKey](PartitionedStream`2 inputStream)
   at System.Linq.Parallel.ScanQueryOperator`1.ScanEnumerableQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
   at System.Linq.Parallel.UnaryQueryOperator`2.UnaryQueryOperatorResults.GivePartitionedStream(IPartitionedStreamRecipient`1 recipient)
   at System.Linq.Parallel.QueryOperator`1.GetOpenedEnumerator(Nullable`1 mergeOptions, Boolean suppressOrder, Boolean forEffect, QuerySettings querySettings)
   at System.Linq.Parallel.ForAllOperator`1.RunSynchronously()
   at System.Linq.ParallelEnumerable.ForAll[TSource](ParallelQuery`1 source, Action`1 action)
   at GitHub.Runner.Sdk.IOUtil.DeleteDirectory(String path, Boolean contentsOnly, Boolean continueOnContentDeleteError, CancellationToken cancellationToken)
   at GitHub.Runner.Worker.TempDirectoryManager.CleanupTempDirectory()
[2020-06-09 15:08:34Z ERR  TempDirectoryManager] #####################################################
[2020-06-09 15:08:34Z ERR  TempDirectoryManager] System.UnauthorizedAccessException: Access to the path '/opt/actions-runner/_work/_temp/_github_home/.kube' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
   at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
   at System.IO.Enumeration.FileSystemEnumerableFactory.FileSystemInfos(String directory, String expression, EnumerationOptions options, Boolean isNormalized)
   at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at System.IO.DirectoryInfo.GetFileSystemInfos()
   at GitHub.Runner.Sdk.IOUtil.Enumerate(DirectoryInfo directory, CancellationTokenSource tokenSource)+MoveNext()
   at System.Linq.Parallel.PartitionedDataSource`1.ContiguousChunkLazyEnumerator.MoveNext(T& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
   at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
   at System.Linq.Parallel.QueryTask.<>c.<.cctor>b__10_0(Object o)
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
[2020-06-09 15:08:34Z ERR  TempDirectoryManager] #####################################################
[2020-06-09 15:08:34Z ERR  TempDirectoryManager] System.IO.IOException: Permission denied
[2020-06-09 15:08:34Z INFO JobRunner] Raising job completed event.
[2020-06-09 15:08:34Z INFO Worker] Job completed.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
xdayscommented, Jun 10, 2020

@TingluoHuang for your help, it’s running now.

and in case anyone else need this, ./svc.sh install root to create systemd unit file.

1reaction
TingluoHuangcommented, Jun 10, 2020

@xdays export RUNNER_ALLOW_RUNASROOT=1 before ./config.sh

Read more comments on GitHub >

github_iconTop Results From Across the Web

How is the /tmp directory cleaned up?
The cleaning of /tmp is done by the upstart script /etc/init/mounted-tmp.conf . The script is run by upstart everytime /tmp is mounted.
Read more >
How to clean the Linux temporary folder when it fills up
You can do this by pressing Ctrl + Alt + T or Ctrl + Alt + Shift + T on the keyboard. Once...
Read more >
When "/tmp" and $TMPDIR directory
When "/tmp" and $TMPDIR directory are cleaned up in macOS? I know about removing files and directories in /tmp directory in boot time....
Read more >
linux - How do I delete everything in the /tmp/ folder?
This will permanently remove any /tmp/session files and free up much space.... Share.
Read more >
How to cleanup tmp folder safely on Linux
I need to delete these orphaned tmp files or else future process will run out of space on /tmp. How can I safely...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found