Skip to content

Commit

Permalink
Ensure manager gets set into runner group creation (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmet authored Apr 23, 2024
1 parent 3a88a76 commit acbe35f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions runner_manager/jobs/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/jobs/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit acbe35f

Please sign in to comment.