-
Notifications
You must be signed in to change notification settings - Fork 0
fix: cleanup sonar-* resource groups in CI #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ jobs: | |
| name: Cleanup Integration Test Resources | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| needs: [integration-tests] | ||
| needs: [integration-tests, sonarqube-scan] | ||
| if: always() | ||
| permissions: | ||
| contents: read | ||
|
|
@@ -118,10 +118,10 @@ jobs: | |
| const tokenRes = await fetch(tokenUrl+'?'+tokenParams.toString(), {headers:{'Authorization':authHeader}}); | ||
| const token = JSON.parse(tokenRes.body).access_token; | ||
| const headers = {'Authorization':'Bearer '+token, 'AI-Resource-Group':'default'}; | ||
| const prefix = 'itest-${{ github.run_id }}-${{ github.run_attempt }}'; | ||
| const prefixes = ['itest-${{ github.run_id }}-${{ github.run_attempt }}', 'sonar-${{ github.run_id }}-${{ github.run_attempt }}']; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The If the SonarQube action uses a different prefix (e.g., The actual resource group naming scheme used by Please provide feedback on the review comment by checking the appropriate box:
|
||
| const rgRes = await fetch(apiUrl+'/v2/admin/resourceGroups', {headers}); | ||
| const groups = JSON.parse(rgRes.body).resources || []; | ||
| const toDelete = groups.filter(rg => rg.resourceGroupId && rg.resourceGroupId.startsWith(prefix)); | ||
| const toDelete = groups.filter(rg => rg.resourceGroupId && prefixes.some(p => rg.resourceGroupId.startsWith(p))); | ||
| for (const rg of toDelete) { | ||
| const res = await fetch(apiUrl+'/v2/admin/resourceGroups/'+rg.resourceGroupId, {method:'DELETE', headers}); | ||
| console.log('Delete', rg.resourceGroupId, '->', res.status); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic Error:
integration-tests-cleanupnow blocks onsonarqube-scan, butsonarqube-scanruns a matrix job (integration-tests) is also a matrix job — however more critically, whensonarqube-scanitself fails or is skipped (e.g., theSONARQ_TOKENsecret is missing in a fork), the cleanup job will still be gated and may never run, leaking theitest-*resource groups it was originally responsible for.The
if: always()on line 77 only bypassesneedsstatus requirements in some conditions — specifically, when all needed jobs either succeed, fail, or are skipped. However, ifsonarqube-scanis never triggered (e.g., in a workflow that doesn't include that job), this dependency will cause the cleanup job to be skipped entirely rather than running as a safety net.More importantly, this couples the cleanup of unrelated concerns:
integration-tests-cleanupwas responsible for cleaning up afterintegration-tests. Tying it tosonarqube-scanmeans a SonarQube infrastructure problem blocksitest-*cleanup.Consider keeping the cleanup job independent of
sonarqube-scan(restoreneeds: [integration-tests]) or using a separate cleanup step within thesonarqube-scanjob for thesonar-*resource group.Double-check suggestion before committing. Edit this comment for amendments.
Please provide feedback on the review comment by checking the appropriate box: