[19.1] Key S3 client cache by config value, not pointer

What does this MR do and why?

Backport of !6961 (merged).

Fixes the unbounded growth of the s3v2 client cache, which is a large part of the runner-manager heap leak tracked in #39595 (closed).

The package-level s3ClientCache in cache/s3v2/s3.go was keyed by *cacheconfig.CacheS3Config pointer identity. That assumption breaks in common.NewBuild, which deep-copies RunnerConfig through JSON for every job, so every cache-using job presented a config pointer the map had never seen and stored a brand-new AWS client forever.

The fix keys the cache by the effective config value instead of the pointer. newS3ClientCacheKey builds a comparable struct from the config, flattening the pointer-valued options (DualStack, PathStyle) into explicit set/value pairs so JSON deep copies of the same config compare equal. Configs without an explicit BucketLocation now bypass the cache to preserve region auto-detection self-healing.

This backport cherry-picks the four commits from the original MR cleanly with no conflicts; the resulting per-file diff is identical to the original.

Author's checklist

  • This MR is backported to a stable branch.
Edited by Stan Hu

Merge request reports

Loading