Repository navigation
[FIX] Guard delete_expired_instances against missing tests and GitHub errors - #1301
Open
knowprasad wants to merge 1 commit into
Open
knowprasad wants to merge 1 commit into
knowprasad wants to merge 1 commit into
Conversation
knowprasad
requested review from
canihavesomecoffee and
thealphadollar
as code owners
December 5, 2026 08:22
|
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.



Please prefix your pull request with one of the following: [FEATURE] [FIX] [IMPROVEMENT].
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Problem
In
mod_ci/controllers.py,delete_expired_instances()can fail to delete timed-out GCP VMs and abort cleanup for subsequent VMs in two cases:Testrow (test is None):delete_expired_instances()inserts aTestProgressrow fortest_idwithout checking whetherTest.query.filter(Test.id == test_id).first()returnedNone. With foreign keys enforced,safe_db_commit()fails and skips deleting the orphaned VM viacontinue; without foreign key enforcement,repository.get_commit(test.commit)raisesAttributeErrorand aborts the loop.repository.get_commit(test.commit)is called unguarded beforedelete_instance_with_tracking(). AGithubExceptionabortsdelete_expired_instances()before the expired VM is deleted and stops cleanup of any remaining expired VMs.Fix
_notify_expired_test_on_github()inmod_ci/controllers.pyto wraprepository.get_commit(),url_for(), andupdate_status_on_github()intry...exceptso GitHub failures are logged without preventing VM deletion.delete_expired_instances(), skipTestProgressinsertion and GitHub status notification (logging a warning) whentest is None, and proceed directly todelete_instance_with_tracking(). Existingif not safe_db_commit(...): continuebehavior whentestexists is preserved.tests/test_ci/test_controllers.py:test_delete_expired_instances_missing_test_still_deletes_vmtest_delete_expired_instances_github_error_still_deletes_vmVerification
masterbefore the fix (GithubExceptionaborting before VM deletion;AssertionErrorskipping'linux-99999'deletion) and pass after the fix.nose2 tests.test_ci.test_controllers.TestControllers.test_delete_expired_instances ...(5 tests): OK.nose2 tests.test_ci.test_comparison tests.test_ci.test_markdown tests.test_ci.test_negative_runtime_fix(29 tests): OK.dodgy,isort . --check-only,pydocstyle --config=./.pydocstylerc,mypy .,pycodestyle ./ --config=./.pycodestylerc): all exit 0.pytest tests/test_ci/on Windows: 240 passed, 11 pre-existing Windows-only failures (4test_cron_job_*needingfcntl,7blocked_userstests needing/dev/urandomsecret_keytracked in#1265).