bash 中基本操作的随机超时

bash 中基本操作的随机超时

语境

我有一个在 Linux 机器上运行的 GitHub Action。

它执行以下操作(可能想先跳到问题,因为其中大部分内容可能无关紧要):

  1. pwd:/home/runner/work/net.twisterrob.cinema/net.twisterrob.cinema
  2. 下载 zip 并解压到diff/prev
  3. 下载 zip 并解压到diff/curr
  4. 其余所有内容都在diff文件夹内运行。
  5. 对内部的文件对运行差异prevcurr如下所示:
    diff --unified=3 --new-file --text --minimal "prev/backend.lockfile" "curr/backend.lockfile" > "backend.lockfile.diff"
    
  6. 对其他文件运行另一组不同的差异:
    ./dependency-tree-diff.jar "prev/$1.dependencies" "curr/$1.dependencies" > "$1.dependencies.diff"
    
  7. 通过 shell 脚本将 diff 转换为补丁:
    ./dependency-tree-diff-to-patch.sh "$1.dependencies.diff" "${BASE}" "${HEAD}" > "$1.dependencies.patch"
    
  8. 最后,这些是目录内容:ls -la
    total 272
    drwxr-xr-x  4 runner docker  4096 Jan 27 21:13 .
    drwxr-xr-x 12 runner docker  4096 Jan 27 21:12 ..
    -rw-r--r--  1 runner docker 32293 Jan 27 21:13 backend-database.dependencies.diff
    -rw-r--r--  1 runner docker 32784 Jan 27 21:13 backend-database.dependencies.patch
    -rw-r--r--  1 runner docker  4250 Jan 27 21:13 backend-database.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 backend-database.lockfile.diff.error
    -rw-r--r--  1 runner docker 14853 Jan 27 21:13 backend-endpoint.dependencies.diff
    -rw-r--r--  1 runner docker 15322 Jan 27 21:13 backend-endpoint.dependencies.patch
    -rw-r--r--  1 runner docker  4202 Jan 27 21:13 backend-endpoint.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 backend-endpoint.lockfile.diff.error
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 backend-feed.dependencies.diff
    -rw-r--r--  1 runner docker   426 Jan 27 21:13 backend-feed.dependencies.patch
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 backend-feed.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 backend-feed.lockfile.diff.error
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 backend-network.dependencies.diff
    -rw-r--r--  1 runner docker   438 Jan 27 21:13 backend-network.dependencies.patch
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 backend-network.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 backend-network.lockfile.diff.error
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 backend-quickbook.dependencies.diff
    -rw-r--r--  1 runner docker   446 Jan 27 21:13 backend-quickbook.dependencies.patch
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 backend-quickbook.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 backend-quickbook.lockfile.diff.error
    -rw-r--r--  1 runner docker 13691 Jan 27 21:13 backend-sync.dependencies.diff
    -rw-r--r--  1 runner docker 14141 Jan 27 21:13 backend-sync.dependencies.patch
    -rw-r--r--  1 runner docker  3869 Jan 27 21:13 backend-sync.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 backend-sync.lockfile.diff.error
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 backend.dependencies.diff
    -rw-r--r--  1 runner docker   406 Jan 27 21:13 backend.dependencies.patch
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 backend.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 backend.lockfile.diff.error
    drwxr-xr-x  2 runner docker  4096 Jan 27 21:12 curr
    -rwxr-xr-x  1 runner docker   441 Jan 27 21:13 dependency-tree-diff-to-patch.sh
    -rwxr-xr-x  1 runner docker 20979 Jun 17  2022 dependency-tree-diff.jar
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 plugins-settings.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 plugins-settings.lockfile.diff.error
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 plugins.dependencies.diff
    -rw-r--r--  1 runner docker   406 Jan 27 21:13 plugins.dependencies.patch
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 plugins.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 plugins.lockfile.diff.error
    drwxr-xr-x  2 runner docker  4096 Jan 27 21:12 prev
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 root-settings.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 root-settings.lockfile.diff.error
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 root.dependencies.diff
    -rw-r--r--  1 runner docker   394 Jan 27 21:13 root.dependencies.patch
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 root.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 root.lockfile.diff.error
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 test-helpers.dependencies.diff
    -rw-r--r--  1 runner docker   426 Jan 27 21:13 test-helpers.dependencies.patch
    -rw-r--r--  1 runner docker     0 Jan 27 21:13 test-helpers.lockfile.diff
    -rw-r--r--  1 runner docker     2 Jan 27 21:13 test-helpers.lockfile.diff.error
    
  9. 为了更好地测量文件夹的大小:du -h -d 1
    2.3M    ./prev
    2.3M    ./curr
    4.8M    .
    
  10. 以及磁盘使用情况:df
    Filesystem     1K-blocks     Used Available Use% Mounted on
    /dev/root       87204404 51329544  35858476  59% /
    tmpfs            3555312      172   3555140   1% /dev/shm
    tmpfs            1422128     1092   1421036   1% /run
    tmpfs               5120        0      5120   0% /run/lock
    /dev/sdb15        106858     5329    101529   5% /boot/efi
    /dev/sda1       14341128  4194336   9396508  31% /mnt
    tmpfs             711060       12    711048   1% /run/user/1001
    
  11. 将 diff 文件合并为一个文件
    ls --format=single-column --time=ctime --reverse *.dependencies.diff | xargs tail --lines=+1 > all.dependencies.diff
    

步骤 11 的目的相当于cat *.dependencies.diff > all.dependencies.diff进行更多的控制(顺序)和绒毛(标题)。https://stackoverflow.com/a/2817024+https://stackoverflow.com/a/7816490man ls+ 使用和扩展标志man tail

问题与疑问

最后的第 11 步有时会超时。整个 GitHub Action 有 10 分钟超时,第 11 步通常需要 9 分钟并被取消。但不总是,通常它“有效”。所有的ls,dudf都是为了尝试诊断正在发生的事情。我发布此内容是希望有人发现此设置/脚本/环境存在问题,可能导致它始终无法完成。我试图排除我的脚本有错误。

例子

我有一个很好的例子,它展示了完全相同的代码上的所有不同场景(没有任何改变):

尝试1:失败https://github.com/TWiStErRob/net.twisterrob.cinema/actions/runs/4028195985/jobs/6924812632

尝试2:失败https://github.com/TWiStErRob/net.twisterrob.cinema/actions/runs/4028195985/jobs/6925862191

尝试3:成功 https://github.com/TWiStErRob/net.twisterrob.cinema/actions/runs/4028195985/jobs/6930610577

最奇怪的是,当它失败时,它始终显示“设备上没有剩余空间”,并且总是在这一步!

System.IO.IOException: No space left on device : '/home/runner/runners/2.301.1/_diag/Worker_20230127-210915-utc.log'
   at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan`1 buffer, Int64 fileOffset)
   at System.IO.Strategies.BufferedFileStreamStrategy.FlushWrite()
   at System.IO.Strategies.BufferedFileStreamStrategy.WriteSpan(ReadOnlySpan`1 source, ArraySegment`1 arraySegment)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.Diagnostics.TextWriterTraceListener.Flush()
   at GitHub.Runner.Common.HostTraceListener.WriteHeader(String source, TraceEventType eventType, Int32 id)
   at GitHub.Runner.Common.HostTraceListener.TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, String message)
   at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String message)
   at GitHub.Runner.Worker.Worker.RunAsync(String pipeIn, String pipeOut)
   at GitHub.Runner.Worker.Program.MainAsync(IHostContext context, String[] args)
System.IO.IOException: No space left on device : '/home/runner/runners/2.301.1/_diag/Worker_20230127-210915-utc.log'
   at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan`1 buffer, Int64 fileOffset)
   at System.IO.Strategies.BufferedFileStreamStrategy.FlushWrite()
   at System.IO.Strategies.BufferedFileStreamStrategy.WriteSpan(ReadOnlySpan`1 source, ArraySegment`1 arraySegment)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.Diagnostics.TextWriterTraceListener.Flush()
   at GitHub.Runner.Common.HostTraceListener.WriteHeader(String source, TraceEventType eventType, Int32 id)
   at GitHub.Runner.Common.HostTraceListener.TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, String message)
   at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String message)
   at GitHub.Runner.Common.Tracing.Error(Exception exception)
   at GitHub.Runner.Worker.Program.MainAsync(IHostContext context, String[] args)
Unhandled exception. System.IO.IOException: No space left on device : '/home/runner/runners/2.301.1/_diag/Worker_20230127-210915-utc.log'
   at System.IO.RandomAccess.WriteAtOffset(SafeFileHandle handle, ReadOnlySpan`1 buffer, Int64 fileOffset)
   at System.IO.Strategies.BufferedFileStreamStrategy.FlushWrite()
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.Diagnostics.TextWriterTraceListener.Flush()
   at System.Diagnostics.TraceSource.Flush()
   at GitHub.Runner.Common.TraceManager.Dispose(Boolean disposing)
   at GitHub.Runner.Common.TraceManager.Dispose()
   at GitHub.Runner.Common.HostContext.Dispose(Boolean disposing)
   at GitHub.Runner.Common.HostContext.Dispose()
   at GitHub.Runner.Worker.Program.Main(String[] args)

相关内容