Skip to content

Cache key conflict #826

Description

@vnghia

Description:
When building with python-version and architecture, only python-version is included in the final cache key, e.g setup-python-Windows-python-3.11.8-poetry-... but not architecture which will cause the Unable to reserve cache with key setup-python-Windows-python-3.11.8-poetry-v2-..., another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/main

Action version:
v5

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Repro steps:

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        target:
          - os: "windows-latest"
            architecture: "x64"
          - os: "windows-latest"
            architecture: "x86"
    defaults:
      run:
        shell: bash
    runs-on: ${{ matrix.target.os }}

    steps:
      - uses: actions/checkout@v4
      - name: Install poetry
        run: pipx install poetry
      - name: Setup Python
        uses: actions/setup-python@v5
        id: setup-python
        with:
          python-version: "3.11"
          architecture: ${{ matrix.target.architecture }}
          cache: "poetry"

Expected behavior:
Cache is cached for all architectures

Actual behavior:
Only one architecture is cached

Activity

  1. v-HarithaVattikuti commented on Mar 2, 2024

    @v-HarithaVattikuti
    Contributor

    Hello @vnghia
    Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

  2. v-priya-kinthali commented on Mar 27, 2024

    @v-priya-kinthali
    Contributor

    Hello @vnghia 👋,
    Thank you for your insightful observation. We will consider incorporating your suggestion about including the architecture in the final cache key in our future enhancements.
    Meantime as a workaround architecture can be included in the cache key using actions/cache as shown below to get separate caches for different architectures.


    - name: Setup Python
      uses: actions/setup-python@v5
      id: setup-python
      with:
        python-version: "3.11"
        architecture: ${{ matrix.target.architecture }}
    - name: Install Poetry
      run: |
        pipx install poetry
        echo "POETRY_CACHE_DIR=$(pip cache dir)" >> $GITHUB_ENV
    - name: Cache poetry
      uses: actions/cache@v3
      with:
        path: ${{ env.POETRY_CACHE_DIR }}
        key: ${{ runner.os }}-poetry-${{ steps.setup-python.outputs.python-version }}-${{ matrix.target.architecture }}-${{ hashFiles('**/poetry.lock') }}
      restore-keys: |
        ${{ runner.os }}-poetry-${{ steps.setup-python.outputs.python-version }}-${{ matrix.target.architecture }}
    

    Your patience and your valuable contribution to the improvement is immensely appreciated!!

  3. added
    feature requestNew feature or request to improve the current logic
    and removed
    bugSomething isn't working
    on Apr 3, 2024
  4. removed their assignment
    on Apr 3, 2024
  5. chongshenng commented on May 22, 2024

    @chongshenng

    +1 for this feature! Can I also suggest that this enhancement includes within the cache key the additional configurations to the matrix via jobs.<job_id>.strategy.matrix.include?

  6. v-gowridurgad commented on Dec 23, 2024

    @v-gowridurgad
    Contributor

    Hi @vnghia, Architecture was added to the cache key as part of this PR. However, the issue is still present because the architecture is taken from the runner. For example, the windows-latest runner is based on a x64 architecture, so even if you specify x86 in your workflow, the runner environment will still be x64. This can cause the architecture to default to x64 despite the x86 specification resulting in a cache key conflict. We acknowledge this limitation and are actively considering improvements to ensure the cache key accurately reflects the specified architecture in future updates.

  7. v-gowridurgad commented on Jan 3, 2025

    @v-gowridurgad
    Contributor

    Hi @vnghia,
    Just a gentle reminder. Do you have any concerns or updates regarding the previous discussion?

  8. vnghia commented on Jan 3, 2025

    @vnghia
    Author

    I don't have much to say. Thank you for working on this feature 👍

  9. v-gowridurgad commented on Jan 7, 2025

    @v-gowridurgad
    Contributor

    Hi @vnghia, Thank you for your response. We are closing this feature request as the architecture has already been incorporated into the cache key. Please feel free to reach out if you have any further questions or concerns.

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

Metadata

Metadata

Assignees

Labels

feature requestNew feature or request to improve the current logic

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions