Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions mod_ci/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def start_platforms(repository, delay=None, platform=None) -> None:
db = create_session(config.get('DATABASE_URI', ''))

compute = get_compute_service_object()
delete_expired_instances(compute, vm_max_runtime, project, zone)
delete_expired_instances(compute, vm_max_runtime, project, zone, db, repository)

if platform is None or platform == TestPlatform.linux:
log.info('Define process to run Linux GCP instances')
Expand Down Expand Up @@ -155,7 +155,7 @@ def is_instance_testing(vm_name) -> bool:
return False


def delete_expired_instances(compute, max_runtime, project, zone) -> None:
def delete_expired_instances(compute, max_runtime, project, zone, db, repository) -> None:
"""
Get all running instances and delete instances whose maximum runtime limit is reached.

Expand All @@ -182,8 +182,6 @@ def delete_expired_instances(compute, max_runtime, project, zone) -> None:
g.db.add(progress)
g.db.commit()

gh = Github(g.github['bot_token'])
repository = gh.get_repo(f"{g.github['repository_owner']}/{g.github['repository']}")
gh_commit = repository.get_commit(test.commit)
if gh_commit is not None:
update_status_on_github(gh_commit, Status.ERROR, message, f"CI - {platform_name}")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ci/test_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def test_delete_expired_instances(self, mock_get_running_instances, mock_update_
{'status': "PENDING"}
]
compute.zoneOperations.return_value.get.return_value.execute = pendingOperations.pop
delete_expired_instances(compute, 120, 'a', 'a')
delete_expired_instances(compute, 120, 'a', 'a', None, MagicMock())
mock_get_running_instances.assert_called_once()
mock_update_github_status.assert_called_once()

Expand Down