Skip to content

Commit 578a6c1

Browse files
fix: fix cron
1 parent be64911 commit 578a6c1

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

mod_ci/controllers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def start_platforms(repository, delay=None, platform=None) -> None:
110110
db = create_session(config.get('DATABASE_URI', ''))
111111

112112
compute = get_compute_service_object()
113-
delete_expired_instances(compute, vm_max_runtime, project, zone)
113+
delete_expired_instances(compute, vm_max_runtime, project, zone, db, repository)
114114

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

157157

158-
def delete_expired_instances(compute, max_runtime, project, zone) -> None:
158+
def delete_expired_instances(compute, max_runtime, project, zone, db, repository) -> None:
159159
"""
160160
Get all running instances and delete instances whose maximum runtime limit is reached.
161161
@@ -182,8 +182,6 @@ def delete_expired_instances(compute, max_runtime, project, zone) -> None:
182182
g.db.add(progress)
183183
g.db.commit()
184184

185-
gh = Github(g.github['bot_token'])
186-
repository = gh.get_repo(f"{g.github['repository_owner']}/{g.github['repository']}")
187185
gh_commit = repository.get_commit(test.commit)
188186
if gh_commit is not None:
189187
update_status_on_github(gh_commit, Status.ERROR, message, f"CI - {platform_name}")

tests/test_ci/test_controllers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def test_delete_expired_instances(self, mock_get_running_instances, mock_update_
441441
{'status': "PENDING"}
442442
]
443443
compute.zoneOperations.return_value.get.return_value.execute = pendingOperations.pop
444-
delete_expired_instances(compute, 120, 'a', 'a')
444+
delete_expired_instances(compute, 120, 'a', 'a', None, None)
445445
mock_get_running_instances.assert_called_once()
446446
mock_update_github_status.assert_called_once()
447447

0 commit comments

Comments
 (0)