[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.
This commit is contained in:
Christophe Monniez 2022-11-03 10:06:50 +01:00 committed by xdo
parent 964a88cb36
commit ac010405dc
4 changed files with 3 additions and 4 deletions

View File

@ -26,7 +26,7 @@ class RunbotException(Exception):
def fqdn():
return socket.getfqdn()
return socket.gethostname()
def time2str(t):

View File

@ -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)

View File

@ -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

View File

@ -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'