Skip to content

enhancement(ci): cache libsasl2 packages to avoid flaky apt - #26156

Open
thomasqueirozb wants to merge 4 commits into
masterfrom
ci/cache-libsasl2
Open

enhancement(ci): cache libsasl2 packages to avoid flaky apt#26156
thomasqueirozb wants to merge 4 commits into
masterfrom
ci/cache-libsasl2

Conversation

@thomasqueirozb

@thomasqueirozb thomasqueirozb commented Aug 19, 2026

Copy link
Copy Markdown
Member

Summary

Cache the libsasl2 .deb packages in the CI setup action so installing them no longer depends on a flaky apt-get update. On cache hit, installs via dpkg -i from the cached packages; on miss, downloads the full dependency closure via apt-get download.

References

NA

Vector configuration

NA

How did you test this PR?

Verified the install logic in an Ubuntu 24.04 container (cache-miss, cache-hit offline, version-guard idempotency) and end-to-end on real GitHub runners in vectordotdev/ci-sandbox (cache miss -> save, cache hit -> restore, key rotation -> restore-keys fallback).

Also re-ran clippy to grab a cached version of libsasl2. Run: https://github.com/vectordotdev/vector/actions/runs/32284131167/job/96197673338?pr=26156

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

Contributor Guidelines

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them. To catch issues early, add a pre-push hook (template) or run the following locally before pushing:
    • make fmt
    • make check-clippy (auto-fix with make clippy-fix)
    • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.

@thomasqueirozb thomasqueirozb added the no-changelog Changes in this PR do not need user-facing explanations in the release changelog label Aug 19, 2026
@github-actions github-actions Bot added the domain: ci Anything related to Vector's CI environment label Aug 19, 2026
@thomasqueirozb thomasqueirozb added no-changelog Changes in this PR do not need user-facing explanations in the release changelog and removed no-changelog Changes in this PR do not need user-facing explanations in the release changelog labels Aug 19, 2026
@thomasqueirozb
thomasqueirozb marked this pull request as ready for review August 19, 2026 19:51
@thomasqueirozb
thomasqueirozb requested a review from a team as a code owner August 19, 2026 19:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f13286d942

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .github/actions/setup/action.yml

@pront pront left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do something like the warm-cache.yaml but for deps (for now libsasl2). The schedule should be different though. I will leave out the details to you and come back to review later.

Comment thread .github/actions/setup/action.yml Outdated
echo "Installing libsasl2 from cached packages"
if ! install_from_cache; then
echo "Cached packages could not be installed, falling back to apt"
timeout 30m sudo apt-get update

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding something like this early in the composite action:

sudo tee /etc/apt/apt.conf.d/99-vector-ci >/dev/null <<'EOF'
Acquire::Retries "3";
Acquire::http::Timeout "30";
Acquire::https::Timeout "30";
DPkg::Lock::Timeout "60";
EOF

This way we can delete repeated ad-hoc timeouts.

@thomasqueirozb thomasqueirozb Aug 19, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acquire::Retries "3" is the default apt config value. We should never hit DPkg::Lock::Timeout "60"; on CI though. RE Acquire::http::Timeout "30"; and Acquire::https::Timeout "30"; both are per-connection idle timeouts, not a cap on total download time and also they're the apt defaults. The timeout 30m here is doing a separate job that cannot be replaced by these flags

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can at least do something like:

apt_get_with_timeout() {
timeout 30m sudo apt-get "$@"
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex can you implement the above?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Added an apt_get_with_timeout helper that consistently applies the existing 30-minute timeout and sudo apt-get invocation. .github/actions/setup/action.ymlL220-L224
  • Updated the cached-package recovery, package-index update, and package-download paths to use the shared helper, removing repeated ad hoc timeout commands. .github/actions/setup/action.ymlL244-L261
  • Committed the change as 07019f6 (ci: centralize apt timeout handling).
  • Prepared pull-request metadata with the title “ci: centralize apt timeout handling for libsasl2” and a body based on the repository PR template.
  • Preserved the pre-existing, unrelated deletion of rust-toolchain.toml; it was not included in the commit.

Testing

  • ruby -e 'require "yaml"; YAML.load_file(".github/actions/setup/action.yml", aliases: true); puts "YAML parsed"'
  • python3 - <<'PY' ... PY — verified the repeated direct timeout commands were removed and all libsasl2 APT operations use the helper.
  • git diff --check
  • git show --stat --oneline HEAD
  • ⚠️ gh pr list --head "$(git branch --show-current)" --state open --json number,url — GitHub CLI authentication is unavailable in the environment.

View task →

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44ef2ccf2e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .github/workflows/refresh-libsasl2-cache.yml Outdated
Comment thread .github/workflows/refresh-libsasl2-cache.yml
@pront

pront commented Aug 19, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: c0ad600ad2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28bbc600e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- name: Delete stale libsasl2 cache
run: |
set -euo pipefail
ids=$(gh api --method GET "repos/${{ github.repository }}/actions/caches" -f key="Linux-libsasl2-" -f per_page=100 --jq '.actions_caches[].id')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Export the workflow token before invoking gh

On both scheduled and manual runs, this clean GitHub-hosted runner has no stored gh credentials, and the job never exposes github.token as GH_TOKEN or GITHUB_TOKEN; therefore the first gh api invocation exits for lack of authentication and the setup step never re-warms the cache. gh help environment confirms that GH_TOKEN/GITHUB_TOKEN supplies authentication, so pass the job token through the step's env in addition to granting actions: write.

Useful? React with 👍 / 👎.

Comment on lines +244 to +245
if compgen -G "$DEBS_DIR"/*.deb > /dev/null; then
echo "Installing libsasl2 from cached packages"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve apt index refresh for subsequent installs

When this cache-hit branch runs on a release builder with missing or outdated apt indexes, setup no longer executes the apt-get update that the previous implementation always performed. The build-linux-cross job in .github/workflows/publish.yml then immediately runs apt-get install for the cross-compilation tools at line 168 without updating first, so releases can fail with unavailable-package or stale-index download errors even though libsasl2 installation succeeded; update the indexes in that workflow or retain the refresh before later apt consumers.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: ci Anything related to Vector's CI environment no-changelog Changes in this PR do not need user-facing explanations in the release changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants