mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 05:15:45 +07:00
[IMP] runbot: improve archive failure logging
This commit is contained in:
parent
57a32ee937
commit
a91b08897f
@ -10,7 +10,7 @@ import time
|
|||||||
import datetime
|
import datetime
|
||||||
from ..common import dt2time, fqdn, now, grep, uniq_list, local_pgadmin_cursor, s2human, Commit
|
from ..common import dt2time, fqdn, now, grep, uniq_list, local_pgadmin_cursor, s2human, Commit
|
||||||
from ..container import docker_build, docker_stop, docker_is_running, Command
|
from ..container import docker_build, docker_stop, docker_is_running, Command
|
||||||
from odoo.addons.runbot.models.repo import HashMissingException
|
from odoo.addons.runbot.models.repo import HashMissingException, ArchiveFailException
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
@ -729,6 +729,9 @@ class runbot_build(models.Model):
|
|||||||
except HashMissingException:
|
except HashMissingException:
|
||||||
self._log('_checkout', "Commit %s is unreachable. Did you force push the branch since build creation?" % commit, level='ERROR')
|
self._log('_checkout', "Commit %s is unreachable. Did you force push the branch since build creation?" % commit, level='ERROR')
|
||||||
self._kill(result='ko')
|
self._kill(result='ko')
|
||||||
|
except ArchiveFailException:
|
||||||
|
self._log('_checkout', "Archive %s failed. Did you force push the branch since build creation?" % commit, level='ERROR')
|
||||||
|
self._kill(result='ko')
|
||||||
return exports
|
return exports
|
||||||
|
|
||||||
def _get_modules_to_test(self, commits=None):
|
def _get_modules_to_test(self, commits=None):
|
||||||
|
@ -25,6 +25,9 @@ _logger = logging.getLogger(__name__)
|
|||||||
class HashMissingException(Exception):
|
class HashMissingException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class ArchiveFailException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class runbot_repo(models.Model):
|
class runbot_repo(models.Model):
|
||||||
|
|
||||||
_name = "runbot.repo"
|
_name = "runbot.repo"
|
||||||
@ -121,8 +124,8 @@ class runbot_repo(models.Model):
|
|||||||
def _git(self, cmd):
|
def _git(self, cmd):
|
||||||
"""Execute a git command 'cmd'"""
|
"""Execute a git command 'cmd'"""
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
_logger.debug("git command: git (dir %s) %s", self.short_name, ' '.join(cmd))
|
||||||
cmd = ['git', '--git-dir=%s' % self.path] + cmd
|
cmd = ['git', '--git-dir=%s' % self.path] + cmd
|
||||||
_logger.debug("git command: %s", ' '.join(cmd))
|
|
||||||
return subprocess.check_output(cmd).decode('utf-8')
|
return subprocess.check_output(cmd).decode('utf-8')
|
||||||
|
|
||||||
def _git_rev_parse(self, branch_name):
|
def _git_rev_parse(self, branch_name):
|
||||||
@ -142,7 +145,7 @@ class runbot_repo(models.Model):
|
|||||||
self._update(force=True)
|
self._update(force=True)
|
||||||
if not self._hash_exists(sha):
|
if not self._hash_exists(sha):
|
||||||
try:
|
try:
|
||||||
self._git(['fetch', 'origin', sha])
|
result = self._git(['fetch', 'origin', sha])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if not self._hash_exists(sha):
|
if not self._hash_exists(sha):
|
||||||
@ -150,10 +153,14 @@ class runbot_repo(models.Model):
|
|||||||
|
|
||||||
_logger.info('git export: checkouting to %s (new)' % export_path)
|
_logger.info('git export: checkouting to %s (new)' % export_path)
|
||||||
os.makedirs(export_path)
|
os.makedirs(export_path)
|
||||||
|
|
||||||
p1 = subprocess.Popen(['git', '--git-dir=%s' % self.path, 'archive', sha], stdout=subprocess.PIPE)
|
p1 = subprocess.Popen(['git', '--git-dir=%s' % self.path, 'archive', sha], stdout=subprocess.PIPE)
|
||||||
p2 = subprocess.Popen(['tar', '-xmC', export_path], stdin=p1.stdout, stdout=subprocess.PIPE)
|
p2 = subprocess.Popen(['tar', '-xmC', export_path], stdin=p1.stdout, stdout=subprocess.PIPE)
|
||||||
p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
|
p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
|
||||||
p2.communicate()[0]
|
(out, err) = p2.communicate()
|
||||||
|
if err:
|
||||||
|
raise ArchiveFailException(err)
|
||||||
|
|
||||||
# TODO get result and fallback on cleaing in case of problem
|
# TODO get result and fallback on cleaing in case of problem
|
||||||
return export_path
|
return export_path
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user