From ac010405dc3837e8230afe1ca80612e3b565ff07 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Thu, 3 Nov 2022 10:06:50 +0100 Subject: [PATCH] [FIX] runbot: use gethostname instead of getfqdn At boot time, it appears that when the runbot tries to get its hostname it may get a wrong fqdn. --- runbot/common.py | 2 +- runbot/tests/common.py | 2 +- runbot/tests/test_cron.py | 2 +- runbot/tests/test_repo.py | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/runbot/common.py b/runbot/common.py index 20292b96..bf5b80a9 100644 --- a/runbot/common.py +++ b/runbot/common.py @@ -26,7 +26,7 @@ class RunbotException(Exception): def fqdn(): - return socket.getfqdn() + return socket.gethostname() def time2str(t): diff --git a/runbot/tests/common.py b/runbot/tests/common.py index 6d71d985..6d00ee4a 100644 --- a/runbot/tests/common.py +++ b/runbot/tests/common.py @@ -121,7 +121,7 @@ class RunbotCase(TransactionCase): self.commit_list = {} self.start_patcher('git_patcher', 'odoo.addons.runbot.models.repo.Repo._git', new=self.mock_git_helper()) - self.start_patcher('fqdn_patcher', 'odoo.addons.runbot.common.socket.getfqdn', 'host.runbot.com') + self.start_patcher('hostname_patcher', 'odoo.addons.runbot.common.socket.gethostname', 'host.runbot.com') self.start_patcher('github_patcher', 'odoo.addons.runbot.models.repo.Remote._github', {}) self.start_patcher('repo_root_patcher', 'odoo.addons.runbot.models.runbot.Runbot._root', '/tmp/runbot_test/static') self.start_patcher('makedirs', 'odoo.addons.runbot.common.os.makedirs', True) diff --git a/runbot/tests/test_cron.py b/runbot/tests/test_cron.py index d9c8a403..de9a52b7 100644 --- a/runbot/tests/test_cron.py +++ b/runbot/tests/test_cron.py @@ -37,7 +37,7 @@ class TestCron(RunbotCase): def test_cron_build(self, mock_scheduler, mock_host_bootstrap, mock_host_docker_build, *args): """ test that cron_fetch_and_build do its work """ hostname = 'cronhost.runbot.com' - self.patchers['fqdn_patcher'].return_value = hostname + self.patchers['hostname_patcher'].return_value = hostname self.env['ir.config_parameter'].sudo().set_param('runbot.runbot_update_frequency', 1) self.env['ir.config_parameter'].sudo().set_param('runbot.runbot_do_schedule', True) self.env['runbot.repo'].search([('id', '!=', self.repo_server.id)]).write({'mode': 'disabled'}) # disable all other existing repo than repo_server diff --git a/runbot/tests/test_repo.py b/runbot/tests/test_repo.py index 78e3ca70..59a6f103 100644 --- a/runbot/tests/test_repo.py +++ b/runbot/tests/test_repo.py @@ -420,7 +420,6 @@ class TestRepoScheduler(RunbotCase): # as the _scheduler method commits, we need to protect the database super(TestRepoScheduler, self).setUp() - self.fqdn_patcher = patch('odoo.addons.runbot.models.host.fqdn') mock_root = self.patchers['repo_root_patcher'] mock_root.return_value = '/tmp/static'