From 47d70ee3c1594e322906131b0dd56fc41b3f3a6b Mon Sep 17 00:00:00 2001 From: itvi-1234 Date: Tue, 1 Dec 2026 22:23:45 +0530 Subject: [PATCH 1/2] Wait for Go's checksum database to see new tags before the smoke test fails Twice a Go publish pushed its tags and then failed the smoke test, although the release was fine: go get asked sum.golang.org for the new version seconds after the push, the checksum database asked GitHub before GitHub served the tag, answered "unknown revision" or 404, and cached that answer for about 30 minutes. Both times the module showed up later without any change. After pushing new tags, promote now waits a minute before the smoke test asks for them. The smoke test tries go get again every 2 minutes, for up to about 40 minutes, when Go says the version is not found or the revision is unknown; any other failure still stops it at once. The publish job's timeout goes from 15 to 60 minutes to fit those retries. --- .github/workflows/binding-promote.yml | 4 +- tooling/extension-bindings/ci/publish.py | 31 ++++++++++++- tooling/extension-bindings/ci/test_publish.py | 44 +++++++++++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/.github/workflows/binding-promote.yml b/.github/workflows/binding-promote.yml index 0a88f34..296608d 100644 --- a/.github/workflows/binding-promote.yml +++ b/.github/workflows/binding-promote.yml @@ -64,7 +64,9 @@ jobs: publish: needs: build runs-on: ubuntu-24.04 - timeout-minutes: 15 + # The smoke test can wait about 40 minutes for Go's checksum database to see + # new tags; see SMOKE_ATTEMPTS in publish.py. + timeout-minutes: 60 permissions: contents: write env: diff --git a/tooling/extension-bindings/ci/publish.py b/tooling/extension-bindings/ci/publish.py index fcd0040..bf44a68 100644 --- a/tooling/extension-bindings/ci/publish.py +++ b/tooling/extension-bindings/ci/publish.py @@ -11,6 +11,7 @@ import subprocess import sys import tempfile +import time from urllib.error import HTTPError from urllib.parse import quote, urlencode from urllib.request import HTTPRedirectHandler, Request, build_opener, urlopen @@ -23,6 +24,15 @@ from serialization import read_document from generation import git, select_targets, summarize +# Right after a tag push, Go's checksum database can ask GitHub for the tag +# before GitHub serves it, answer "unknown revision", and cache that answer for +# up to about 30 minutes. Waiting a little after the push usually avoids it, and +# the smoke test retries for longer than that cache lasts. +TAG_SETTLE_SECONDS = 60 +SMOKE_RETRY_SECONDS = 120 +SMOKE_ATTEMPTS = 20 +NOT_VISIBLE_YET = ("404 Not Found", "unknown revision", "invalid version") + SUFFIXES = (".module.zip", ".source.zip", ".runtimeconditions.binding-model.yaml", ".runtimeconditions.binding-release.yaml", ".runtimeconditions.bindings.yaml", ".runtimeconditions.file-manifest.yaml") @@ -265,6 +275,7 @@ def promote(root: Path, bindings: list[GoBinding], output: Path, github: GitHub, if new_tags: # All new module versions become available together. Never move a tag. git(root, "push", "--atomic", "origin", *("refs/tags/" + tag for tag in new_tags)) + time.sleep(TAG_SETTLE_SECONDS) for binding in bindings: release = releases[binding.tag] or github.create(binding, source) existing = {asset["name"] for asset in release["assets"]} @@ -275,6 +286,24 @@ def promote(root: Path, bindings: list[GoBinding], output: Path, github: GitHub, summarize(f"Published `{binding.module}@v{binding.version}`: " + release["html_url"]) +def go_get(module: str, consumer: Path, env: dict[str, str]) -> None: + """go get a module version, waiting while Go's servers do not see a new tag yet.""" + for attempt in range(1, SMOKE_ATTEMPTS + 1): + result = subprocess.run(["go", "get", module], cwd=consumer, env=env, capture_output=True, text=True) + sys.stderr.write(result.stderr) + if result.returncode == 0: + return + if attempt == SMOKE_ATTEMPTS or not any(text in result.stderr for text in NOT_VISIBLE_YET): + raise subprocess.CalledProcessError(result.returncode, result.args, result.stdout, result.stderr) + print( + f"{module} is not visible to Go yet (attempt {attempt} of {SMOKE_ATTEMPTS}); " + f"Go's servers may still cache an answer from before the tag existed. Trying again in " + f"{SMOKE_RETRY_SECONDS} seconds.", + flush=True, + ) + time.sleep(SMOKE_RETRY_SECONDS) + + def smoke(bindings: list[GoBinding]) -> None: for proxy in ("direct", "https://proxy.golang.org,direct"): with tempfile.TemporaryDirectory(prefix="rc-go-install-") as temporary: @@ -288,7 +317,7 @@ def smoke(bindings: list[GoBinding]) -> None: (consumer / "go.mod").write_text("module consumer.invalid/bindings\n\ngo 1.25\n", encoding="utf-8") (consumer / "main.go").write_text( f'package main\nimport "{binding.module}"\nvar _ {binding.name}.Declaration\nfunc main() {{}}\n', encoding="utf-8") - subprocess.run(["go", "get", binding.module + "@v" + binding.version], cwd=consumer, env=env, check=True) + go_get(binding.module + "@v" + binding.version, consumer, env) subprocess.run(["go", "build", "./..."], cwd=consumer, env=env, check=True) summarize(f"Fresh consumer installation and unaliased imports passed with GOPROXY={proxy}.") diff --git a/tooling/extension-bindings/ci/test_publish.py b/tooling/extension-bindings/ci/test_publish.py index 767fd36..fbb8281 100644 --- a/tooling/extension-bindings/ci/test_publish.py +++ b/tooling/extension-bindings/ci/test_publish.py @@ -12,6 +12,9 @@ import yaml +import subprocess + +import publish from publish import (SUFFIXES, asset_paths, check_discovery, checksum_text, git, ordered_targets, preflight, promote) from build_extensions_site import go_page @@ -55,6 +58,9 @@ def setUp(self) -> None: summary = patch.dict("os.environ", {"GITHUB_STEP_SUMMARY": ""}) summary.start() self.addCleanup(summary.stop) + sleep = patch.object(publish.time, "sleep") + self.sleep = sleep.start() + self.addCleanup(sleep.stop) temporary = tempfile.TemporaryDirectory(prefix="binding-publication-test-") self.addCleanup(temporary.cleanup) self.work = Path(temporary.name) @@ -146,10 +152,14 @@ def test_publish_and_retry_reuse_identical_tags_and_assets(self): for binding in self.bindings: self.assertIn(binding.tag, refs) self.assertFalse(self.github.release(binding.tag)["draft"]) + # New tags get a minute before anything asks Go's servers for them. + self.sleep.assert_called_once_with(publish.TAG_SETTLE_SECONDS) uploads = self.github.uploads promote(self.root, self.bindings, self.output, self.github, False) self.assertEqual(self.github.uploads, uploads) self.assertEqual(git(self.root, "ls-remote", "origin"), refs) + # A retry pushes no tag, so it does not wait. + self.sleep.assert_called_once() def test_interrupted_upload_can_resume_without_rebuilding(self): self.github.fail_once = True @@ -228,5 +238,39 @@ def test_dependency_version_mismatch_is_rejected(self): ordered_targets(self.root, "addon:go") +class SmokeRetryTests(unittest.TestCase): + def result(self, code: int, stderr: str = "") -> subprocess.CompletedProcess: + return subprocess.CompletedProcess(["go", "get"], code, "", stderr) + + def go_get(self, *results: subprocess.CompletedProcess): + with patch.object(publish.subprocess, "run", side_effect=list(results)) as run, patch.object( + publish.time, "sleep" + ) as sleep, patch.object(publish.sys, "stderr", io.StringIO()): + publish.go_get("example.com/x@v0.1.0", Path("."), {}) + return run, sleep + + def test_a_tag_go_does_not_see_yet_is_tried_again(self) -> None: + unseen = "reading https://sum.golang.org/lookup/example.com/x@v0.1.0: 404 Not Found\n" \ + "invalid version: unknown revision" + run, sleep = self.go_get(self.result(1, unseen), self.result(1, unseen), self.result(0)) + self.assertEqual(run.call_count, 3) + sleep.assert_called_with(publish.SMOKE_RETRY_SECONDS) + + def test_other_failures_stop_at_once(self) -> None: + with self.assertRaises(subprocess.CalledProcessError): + self.go_get(self.result(1, "build constraints exclude all Go files")) + + def test_it_gives_up_after_the_last_attempt(self) -> None: + unseen = self.result(1, "404 Not Found") + with self.assertRaises(subprocess.CalledProcessError): + self.go_get(*[unseen] * publish.SMOKE_ATTEMPTS) + + def test_the_retries_outlast_the_checksum_database_cache(self) -> None: + # Go's servers keep a "not found" for about 30 minutes, and the job allows 60. + waited = (publish.SMOKE_ATTEMPTS - 1) * publish.SMOKE_RETRY_SECONDS + publish.TAG_SETTLE_SECONDS + self.assertGreater(waited, 30 * 60) + self.assertLess(waited, 50 * 60) + + if __name__ == "__main__": unittest.main() From 99043179cc9ca6c0b54e4117c414d3de29302f51 Mon Sep 17 00:00:00 2001 From: itvi-1234 Date: Wed, 2 Dec 2026 10:14:34 +0530 Subject: [PATCH 2/2] Keep only the one-minute wait after a tag push, without smoke retries Retrying go get for up to 40 minutes kept the job running for a problem that the wait after the tag push already avoids in most cases. The smoke test runs once again, the publish job's timeout is back to 15 minutes, and if Go's checksum database still has not seen a new tag, the workflow can be run again later: it reuses the tags and only repeats the smoke test. --- .github/workflows/binding-promote.yml | 4 +-- tooling/extension-bindings/ci/publish.py | 28 +++------------ tooling/extension-bindings/ci/test_publish.py | 36 ------------------- 3 files changed, 5 insertions(+), 63 deletions(-) diff --git a/.github/workflows/binding-promote.yml b/.github/workflows/binding-promote.yml index 296608d..0a88f34 100644 --- a/.github/workflows/binding-promote.yml +++ b/.github/workflows/binding-promote.yml @@ -64,9 +64,7 @@ jobs: publish: needs: build runs-on: ubuntu-24.04 - # The smoke test can wait about 40 minutes for Go's checksum database to see - # new tags; see SMOKE_ATTEMPTS in publish.py. - timeout-minutes: 60 + timeout-minutes: 15 permissions: contents: write env: diff --git a/tooling/extension-bindings/ci/publish.py b/tooling/extension-bindings/ci/publish.py index bf44a68..3999a30 100644 --- a/tooling/extension-bindings/ci/publish.py +++ b/tooling/extension-bindings/ci/publish.py @@ -26,12 +26,10 @@ # Right after a tag push, Go's checksum database can ask GitHub for the tag # before GitHub serves it, answer "unknown revision", and cache that answer for -# up to about 30 minutes. Waiting a little after the push usually avoids it, and -# the smoke test retries for longer than that cache lasts. +# about 30 minutes. Waiting a minute before the smoke test asks avoids that. +# If it still happens, the release is fine: run the workflow again later, and +# it reuses the tags and only repeats the smoke test. TAG_SETTLE_SECONDS = 60 -SMOKE_RETRY_SECONDS = 120 -SMOKE_ATTEMPTS = 20 -NOT_VISIBLE_YET = ("404 Not Found", "unknown revision", "invalid version") SUFFIXES = (".module.zip", ".source.zip", ".runtimeconditions.binding-model.yaml", ".runtimeconditions.binding-release.yaml", ".runtimeconditions.bindings.yaml", @@ -286,24 +284,6 @@ def promote(root: Path, bindings: list[GoBinding], output: Path, github: GitHub, summarize(f"Published `{binding.module}@v{binding.version}`: " + release["html_url"]) -def go_get(module: str, consumer: Path, env: dict[str, str]) -> None: - """go get a module version, waiting while Go's servers do not see a new tag yet.""" - for attempt in range(1, SMOKE_ATTEMPTS + 1): - result = subprocess.run(["go", "get", module], cwd=consumer, env=env, capture_output=True, text=True) - sys.stderr.write(result.stderr) - if result.returncode == 0: - return - if attempt == SMOKE_ATTEMPTS or not any(text in result.stderr for text in NOT_VISIBLE_YET): - raise subprocess.CalledProcessError(result.returncode, result.args, result.stdout, result.stderr) - print( - f"{module} is not visible to Go yet (attempt {attempt} of {SMOKE_ATTEMPTS}); " - f"Go's servers may still cache an answer from before the tag existed. Trying again in " - f"{SMOKE_RETRY_SECONDS} seconds.", - flush=True, - ) - time.sleep(SMOKE_RETRY_SECONDS) - - def smoke(bindings: list[GoBinding]) -> None: for proxy in ("direct", "https://proxy.golang.org,direct"): with tempfile.TemporaryDirectory(prefix="rc-go-install-") as temporary: @@ -317,7 +297,7 @@ def smoke(bindings: list[GoBinding]) -> None: (consumer / "go.mod").write_text("module consumer.invalid/bindings\n\ngo 1.25\n", encoding="utf-8") (consumer / "main.go").write_text( f'package main\nimport "{binding.module}"\nvar _ {binding.name}.Declaration\nfunc main() {{}}\n', encoding="utf-8") - go_get(binding.module + "@v" + binding.version, consumer, env) + subprocess.run(["go", "get", binding.module + "@v" + binding.version], cwd=consumer, env=env, check=True) subprocess.run(["go", "build", "./..."], cwd=consumer, env=env, check=True) summarize(f"Fresh consumer installation and unaliased imports passed with GOPROXY={proxy}.") diff --git a/tooling/extension-bindings/ci/test_publish.py b/tooling/extension-bindings/ci/test_publish.py index fbb8281..0349cab 100644 --- a/tooling/extension-bindings/ci/test_publish.py +++ b/tooling/extension-bindings/ci/test_publish.py @@ -12,8 +12,6 @@ import yaml -import subprocess - import publish from publish import (SUFFIXES, asset_paths, check_discovery, checksum_text, git, ordered_targets, preflight, promote) @@ -238,39 +236,5 @@ def test_dependency_version_mismatch_is_rejected(self): ordered_targets(self.root, "addon:go") -class SmokeRetryTests(unittest.TestCase): - def result(self, code: int, stderr: str = "") -> subprocess.CompletedProcess: - return subprocess.CompletedProcess(["go", "get"], code, "", stderr) - - def go_get(self, *results: subprocess.CompletedProcess): - with patch.object(publish.subprocess, "run", side_effect=list(results)) as run, patch.object( - publish.time, "sleep" - ) as sleep, patch.object(publish.sys, "stderr", io.StringIO()): - publish.go_get("example.com/x@v0.1.0", Path("."), {}) - return run, sleep - - def test_a_tag_go_does_not_see_yet_is_tried_again(self) -> None: - unseen = "reading https://sum.golang.org/lookup/example.com/x@v0.1.0: 404 Not Found\n" \ - "invalid version: unknown revision" - run, sleep = self.go_get(self.result(1, unseen), self.result(1, unseen), self.result(0)) - self.assertEqual(run.call_count, 3) - sleep.assert_called_with(publish.SMOKE_RETRY_SECONDS) - - def test_other_failures_stop_at_once(self) -> None: - with self.assertRaises(subprocess.CalledProcessError): - self.go_get(self.result(1, "build constraints exclude all Go files")) - - def test_it_gives_up_after_the_last_attempt(self) -> None: - unseen = self.result(1, "404 Not Found") - with self.assertRaises(subprocess.CalledProcessError): - self.go_get(*[unseen] * publish.SMOKE_ATTEMPTS) - - def test_the_retries_outlast_the_checksum_database_cache(self) -> None: - # Go's servers keep a "not found" for about 30 minutes, and the job allows 60. - waited = (publish.SMOKE_ATTEMPTS - 1) * publish.SMOKE_RETRY_SECONDS + publish.TAG_SETTLE_SECONDS - self.assertGreater(waited, 30 * 60) - self.assertLess(waited, 50 * 60) - - if __name__ == "__main__": unittest.main()