Skip to content

fix concurrent workers causing skipped PipelineRun pruning#219

Closed
anithapriyanatarajan wants to merge 12 commits into
release-v0.1.xfrom
main
Closed

fix concurrent workers causing skipped PipelineRun pruning#219
anithapriyanatarajan wants to merge 12 commits into
release-v0.1.xfrom
main

Conversation

@anithapriyanatarajan
Copy link
Copy Markdown
Member

Changes

Included the following fixes:

This PR improves the cleanup process for PipelineRuns and TaskRuns. Previously, if a PipelineRun or TaskRun was not found, typically because a concurrent worker had already deleted it the cleanup process would error out, causing subsequent items to be skipped and not processed.
This update changes that behavior by checking if the error is a NotFound error. If so, the cleanup logic will skip that item and continue processing the rest, ensuring that all eligible PipelineRuns and TaskRuns are handled correctly even in concurrent environments.

This PR also refactors the method responsible for updating annotations when configuration changes occur. Previously, all annotation fields were copied and written back to the PipelineRun, even if only pruner-specific keys were relevant.
With this update, only the pruner-specific annotation key/value pairs are handled and updated, avoiding unnecessary overwrites of unrelated annotations and improving efficiency and clarity in annotation management.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

Release Notes

NONE

pramodbindal and others added 12 commits May 5, 2025 14:11
Signed-off-by: Pramod Bindal <prbindal@redhat.com>
Signed-off-by: Pramod Bindal <prbindal@redhat.com>
Bumps [ko-build/setup-ko](https://github.com/ko-build/setup-ko) from 0.8 to 0.9.
- [Release notes](https://github.com/ko-build/setup-ko/releases)
- [Commits](ko-build/setup-ko@v0.8...v0.9)

---
updated-dependencies:
- dependency-name: ko-build/setup-ko
  dependency-version: '0.9'
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…st to 92b1d57

Signed-off-by: red-hat-konflux-kflux-prd-rh02 <190377777+red-hat-konflux-kflux-prd-rh02[bot]@users.noreply.github.com>
…2b1d57

Signed-off-by: red-hat-konflux-kflux-prd-rh02 <190377777+red-hat-konflux-kflux-prd-rh02[bot]@users.noreply.github.com>
Signed-off-by: red-hat-konflux-kflux-prd-rh02 <konflux@no-reply.konflux-ci.dev>
Comment on lines +9 to +69
runs-on: ubuntu-latest
steps:
- name: checkout the source code
uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: ^1.23

- name: cache go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: ko-build/setup-ko@v0.9

- name: build and push container images
run: ./hack/build.sh
env:
KO_PUSH: "true"
KO_DOCKER_REPO: "ghcr.io/${{ github.repository }}"

- name: generate a build timestamp and sha256sum files
run: |
cd builds
echo `date -u +'%Y%m%d%H%M%S'` > ./build_timestamp.txt
echo `date -u +'%Y-%m-%dT%H:%M:%S%:z'` >> ./build_timestamp.txt
sha256sum *.yaml > ./SHA256SUMS.txt

- name: update release notes and executables
if: startsWith(github.ref, 'refs/tags/') # executes only for new release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
builds/*.yaml
builds/build_timestamp.txt
builds/SHA256SUMS.txt

- name: Update executables for main branch changes
if: startsWith(github.ref, 'refs/heads/main') # executes only for changes in main
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: main-devel
prerelease: true
title: "Development Build - main branch"
files: |
builds/*.yaml
builds/build_timestamp.txt
builds/SHA256SUMS.txt No newline at end of file

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 11 months ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the minimal permissions required for the workflow to function correctly. Based on the steps in the workflow:

  • contents: read is required for checking out the source code and caching Go modules.
  • packages: write is required for Docker login and pushing container images.
  • issues: write and pull-requests: write are not needed, as the workflow does not interact with issues or pull requests.
  • contents: write is required for updating release notes and executables.

The permissions block can be added at the root level of the workflow to apply to all jobs, or it can be added to individual jobs. In this case, adding it at the root level is more concise and appropriate.


Suggested changeset 1
.github/workflows/build_and_publish.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build_and_publish.yaml b/.github/workflows/build_and_publish.yaml
--- a/.github/workflows/build_and_publish.yaml
+++ b/.github/workflows/build_and_publish.yaml
@@ -1,2 +1,5 @@
 name: build and publish
+permissions:
+  contents: read
+  packages: write
 on:
EOF
@@ -1,2 +1,5 @@
name: build and publish
permissions:
contents: read
packages: write
on:
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@anithapriyanatarajan
Copy link
Copy Markdown
Member Author

Incorrect Merge Request. Intend to only cherry pick the changes for bug fix

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants