Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions runbot/models/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,14 @@ def _get_builds(self, domain, order=None):
def _process_messages(self):
return self.host_message_ids._process()

def _action_pause(self):
for host in self:
host.paused = True

def _action_unpause(self):
for host in self:
host.paused = False


class MessageQueue(models.Model):
_name = 'runbot.host.message'
Expand Down
25 changes: 24 additions & 1 deletion runbot/views/host_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<field name="is_leader"/>
<field name="is_builder"/>
<field name="is_registry"/>

<field name="paused" widget="boolean_toggle"/>
</list>
</field>
</record>
Expand All @@ -75,5 +75,28 @@
<field name="path">host</field>
</record>

<record model="ir.actions.server" id="action_pause_hosts">
<field name="name">Pause Selected Hosts</field>
<field name="model_id" ref="runbot.model_runbot_host" />
<field name="binding_model_id" ref="runbot.model_runbot_host" />
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="code">
action = records._action_pause()
</field>
</record>

<record model="ir.actions.server" id="action_unpause_hosts">
<field name="name">Unpause Selected Hosts</field>
<field name="model_id" ref="runbot.model_runbot_host" />
<field name="binding_model_id" ref="runbot.model_runbot_host" />
<field name="type">ir.actions.server</field>
<field name="state">code</field>
<field name="code">
action = records._action_unpause()
</field>
</record>

</data>

</odoo>
7 changes: 7 additions & 0 deletions runbot_builder/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pathlib import Path
from logging.handlers import WatchedFileHandler


LOG_FORMAT = '%(asctime)s %(levelname)s %(name)s: %(message)s'
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
logging.getLogger('odoo.addons.runbot').setLevel(logging.DEBUG)
Expand All @@ -40,6 +41,7 @@ def on_start(self):
def main_loop(self):
from odoo import fields
from odoo.tools.profiler import Profiler
from odoo.tools.misc import str2bool
self.on_start()
signal.signal(signal.SIGINT, self.signal_handler)
signal.signal(signal.SIGTERM, self.signal_handler)
Expand All @@ -55,6 +57,11 @@ def main_loop(self):
' (assigned only)' if self.host.assigned_only else ''
)
while True:
if str2bool(self.env['ir.config_parameter'].sudo().get_param('pause_all_hosts', 'False')):
# don't even access hosts to make upgrades possible
_logger.info('All hosts are paused, sleeping 10s')
self.sleep(10)
continue
context_manager = Profiler(db=self.env.cr.dbname) if self.host.profile else nullcontext()
with context_manager:
try:
Expand Down