From acbe35f168558846b874d98eca484cd661ddb43e Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Tue, 23 Apr 2024 22:03:02 +0200 Subject: [PATCH] Ensure manager gets set into runner group creation (#588) --- runner_manager/jobs/startup.py | 6 ++++-- tests/unit/jobs/test_startup.py | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/runner_manager/jobs/startup.py b/runner_manager/jobs/startup.py index 12f15cee..ebc96d01 100644 --- a/runner_manager/jobs/startup.py +++ b/runner_manager/jobs/startup.py @@ -32,10 +32,12 @@ def sync_runner_groups(settings: Settings): if runner_group_config.name in [group.name for group in existing_groups]: runner_group: RunnerGroup = RunnerGroup.find_from_base(runner_group_config) existing_groups.remove(runner_group) - runner_group.update(**runner_group_config.dict()) + runner_group.update(manager=settings.name, **runner_group_config.dict()) runner_group.save(github=github) else: - runner_group: RunnerGroup = RunnerGroup(**runner_group_config.dict()) + runner_group: RunnerGroup = RunnerGroup( + manager=settings.name, **runner_group_config.dict() + ) runner_group.save(github=github) for runner_group in existing_groups: diff --git a/tests/unit/jobs/test_startup.py b/tests/unit/jobs/test_startup.py index 61fc020c..1a809851 100644 --- a/tests/unit/jobs/test_startup.py +++ b/tests/unit/jobs/test_startup.py @@ -19,13 +19,18 @@ def test_startup(queue: Queue, settings: Settings, github: GitHub): RunnerGroup.name == settings_group.name ).first() assert runner_group.backend.name == settings_group.backend.name + assert runner_group.manager == settings.name # Run startup again + settings.name = "new-name" job: Job = queue.enqueue(startup, settings) status: JobStatus = job.get_status() assert status == JobStatus.FINISHED assert RunnerGroup.find().count() == 1 - + runner_group: RunnerGroup = RunnerGroup.find( + RunnerGroup.name == settings_group.name + ).first() + assert runner_group.manager == settings.name # Add leftover that should be deleted runner_group = RunnerGroup( name="leftover",