fix concurrent workers causing skipped PipelineRun pruning#219
Closed
anithapriyanatarajan wants to merge 12 commits into
Closed
fix concurrent workers causing skipped PipelineRun pruning#219anithapriyanatarajan wants to merge 12 commits into
anithapriyanatarajan wants to merge 12 commits into
Conversation
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
Show autofix suggestion
Hide autofix suggestion
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: readis required for checking out the source code and caching Go modules.packages: writeis required for Docker login and pushing container images.issues: writeandpull-requests: writeare not needed, as the workflow does not interact with issues or pull requests.contents: writeis 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
| @@ -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
Member
Author
|
Incorrect Merge Request. Intend to only cherry pick the changes for bug fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
make test lintbefore submitting a PRRelease Notes