Skip to content

Commit 2db2cde

Browse files
committed
opensuse: Use metalink for the default mirror
Point the openSUSE repositories at download.opensuse.org's per-file metalink instead of a plain baseurl when using the default mirror. download.opensuse.org routes each client to a single sticky mirror, so when that mirror is slow, overloaded or has not yet synced a freshly published snapshot, downloads often fail. Note that `download.max_silent_tries` doesn't save us here, as it's just going to hit the same mirror again. The metalink is a ranked list of mirrors that libdnf/libzypp fall back across on download failure. Custom mirrors (`Mirror=`) don't serve a metalink, so they keep baseurl. This fixes the other half of #4365
1 parent 1bc5d61 commit 2db2cde

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

mkosi/distribution/opensuse.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ def repositories(cls, context: Context) -> Iterable[RpmRepository]:
107107
zypper = cls.package_manager(context.config) is Zypper
108108
mirror = context.config.mirror or "https://download.opensuse.org"
109109

110+
def repourl(base: str) -> str:
111+
if context.config.mirror:
112+
# Custom mirrors don't provide a metalink
113+
return f"baseurl={base}"
114+
115+
# download.opensuse.org serves a metalink for every repodata file. Using it lets libdnf/libzypp
116+
# fall back to another mirror when a download fails, instead of giving up when being routed us to
117+
# a slow, overloaded or out-of-date mirror.
118+
return f"metalink={base}/repodata/repomd.xml.metalink"
119+
110120
if context.config.release == "tumbleweed":
111121
gpgkeys = tuple(
112122
p
@@ -143,7 +153,7 @@ def repositories(cls, context: Context) -> Iterable[RpmRepository]:
143153
url = join_mirror(mirror, f"{subdir}/tumbleweed/repo/{repo}")
144154
yield RpmRepository(
145155
id=repo,
146-
url=f"baseurl={url}",
156+
url=repourl(url),
147157
gpgurls=gpgkeys or (fetch_gpgurls(context, url) if not zypper else ()),
148158
enabled=repo == "oss",
149159
)
@@ -155,7 +165,7 @@ def repositories(cls, context: Context) -> Iterable[RpmRepository]:
155165
url = join_mirror(mirror, f"{subdir}/{d}/tumbleweed/repo/{repo}")
156166
yield RpmRepository(
157167
id=f"{repo}-{d}",
158-
url=f"baseurl={url}",
168+
url=repourl(url),
159169
gpgurls=gpgkeys or (fetch_gpgurls(context, url) if not zypper else ()),
160170
enabled=False,
161171
)
@@ -164,14 +174,14 @@ def repositories(cls, context: Context) -> Iterable[RpmRepository]:
164174
url = join_mirror(mirror, f"{subdir}/update/tumbleweed")
165175
yield RpmRepository(
166176
id="oss-update",
167-
url=f"baseurl={url}",
177+
url=repourl(url),
168178
gpgurls=gpgkeys or (fetch_gpgurls(context, url) if not zypper else ()),
169179
)
170180

171181
url = join_mirror(mirror, f"{subdir}/update/tumbleweed-non-oss")
172182
yield RpmRepository(
173183
id="non-oss-update",
174-
url=f"baseurl={url}",
184+
url=repourl(url),
175185
gpgurls=gpgkeys or (fetch_gpgurls(context, url) if not zypper else ()),
176186
enabled=False,
177187
)
@@ -232,7 +242,7 @@ def repositories(cls, context: Context) -> Iterable[RpmRepository]:
232242
url = join_mirror(mirror, f"{subdir}/distribution/{release}/repo/{repo}")
233243
yield RpmRepository(
234244
id=repo,
235-
url=f"baseurl={url}",
245+
url=repourl(url),
236246
gpgurls=gpgkeys or (fetch_gpgurls(context, url) if not zypper else ()),
237247
enabled=repo == "oss",
238248
)
@@ -242,7 +252,7 @@ def repositories(cls, context: Context) -> Iterable[RpmRepository]:
242252
url = join_mirror(mirror, f"{subdir}/{d}/distribution/{release}/repo/{repo}")
243253
yield RpmRepository(
244254
id=f"{repo}-{d}",
245-
url=f"baseurl={url}",
255+
url=repourl(url),
246256
gpgurls=gpgkeys or (fetch_gpgurls(context, url) if not zypper else ()),
247257
enabled=False,
248258
)
@@ -259,7 +269,7 @@ def repositories(cls, context: Context) -> Iterable[RpmRepository]:
259269
url = join_mirror(mirror, f"{subdir}/{repo}")
260270
yield RpmRepository(
261271
id=f"{repo}-update",
262-
url=f"baseurl={url}",
272+
url=repourl(url),
263273
gpgurls=gpgkeys or (fetch_gpgurls(context, url) if not zypper else ()),
264274
enabled=repo == "oss",
265275
)

0 commit comments

Comments
 (0)