From 80bc9d0fe215e7e191e1a09f6d26f4588228fd94 Mon Sep 17 00:00:00 2001
From: Sergei Zharinov <zharinov@users.noreply.github.com>
Date: Sun, 25 Aug 2024 08:19:58 -0300
Subject: [PATCH] refactor: Move Repology rate limits to http defaults (#30996)

---
 lib/config/presets/common.ts               |  1 +
 lib/config/presets/internal/workarounds.ts | 12 ------------
 lib/util/http/rate-limits.ts               |  8 ++++++++
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/lib/config/presets/common.ts b/lib/config/presets/common.ts
index 4fb427a4a3..d79e996f3a 100644
--- a/lib/config/presets/common.ts
+++ b/lib/config/presets/common.ts
@@ -42,6 +42,7 @@ export const removedPresets: Record<string, string | null> = {
     'customManagers:helmChartYamlAppVersions',
   'regexManagers:mavenPropertyVersions': 'customManagers:mavenPropertyVersions',
   'regexManagers:tfvarsVersions': 'customManagers:tfvarsVersions',
+  'workarounds:reduceRepologyServerLoad': null,
 };
 
 const renamedMonorepos: Record<string, string> = {
diff --git a/lib/config/presets/internal/workarounds.ts b/lib/config/presets/internal/workarounds.ts
index 815d864ec6..53ef59c34a 100644
--- a/lib/config/presets/internal/workarounds.ts
+++ b/lib/config/presets/internal/workarounds.ts
@@ -14,7 +14,6 @@ export const presets: Record<string, Preset> = {
       'workarounds:ignoreHttp4sDigestMilestones',
       'workarounds:typesNodeVersioning',
       'workarounds:nodeDockerVersioning',
-      'workarounds:reduceRepologyServerLoad',
       'workarounds:doNotUpgradeFromAlpineStableToEdge',
       'workarounds:supportRedHatImageVersion',
       'workarounds:javaLTSVersions',
@@ -201,17 +200,6 @@ export const presets: Record<string, Preset> = {
       },
     ],
   },
-  reduceRepologyServerLoad: {
-    description:
-      'Limit requests to reduce load on Repology servers until we can fix this properly, see issue `#10133`.',
-    hostRules: [
-      {
-        concurrentRequestLimit: 1,
-        matchHost: 'repology.org',
-        maxRequestsPerSecond: 0.5,
-      },
-    ],
-  },
   supportRedHatImageVersion: {
     description:
       'Use specific versioning for Red Hat-maintained container images.',
diff --git a/lib/util/http/rate-limits.ts b/lib/util/http/rate-limits.ts
index 03554db352..c6105379a1 100644
--- a/lib/util/http/rate-limits.ts
+++ b/lib/util/http/rate-limits.ts
@@ -9,6 +9,10 @@ const concurrencyDefaults: ConcurrencyLimitRule[] = [
     matchHost: 'registry.npmjs.org',
     concurrency: 999,
   },
+  {
+    matchHost: 'repology.org',
+    concurrency: 1,
+  },
   {
     matchHost: '*',
     concurrency: 16,
@@ -35,6 +39,10 @@ const throttleDefaults: ThrottleLimitRule[] = [
     matchHost: 'https://plugins.gradle.org',
     throttleMs: 50,
   },
+  {
+    matchHost: 'repology.org',
+    throttleMs: 2000,
+  },
 ];
 
 let throttleLimits: ThrottleLimitRule[] = [];
-- 
GitLab