Пример #1
0
    def execute(self, data):
        """Pass a container to the cleanup service.
        """
        _LOGGER.critical('Monitor container cleanup: %r', data)
        running = os.path.join(self._tm_env.running_dir, data['id'])
        data_dir = supervisor.open_service(running, existing=False).data_dir
        cleanup = os.path.join(self._tm_env.cleanup_dir, data['id'])

        # pid1 will SIGABRT(6) when there is an issue
        if int(data['signal']) == 6:
            app_abort.flag_aborted(data_dir, why=app_abort.AbortedReason.PID1)

        try:
            _LOGGER.info('Moving %r -> %r', running, cleanup)
            fs.replace(running, cleanup)
        except OSError as err:
            if err.errno == errno.ENOENT:
                pass
            else:
                raise

        try:
            supervisor.control_svscan(self._tm_env.running_dir, [
                supervisor.SvscanControlAction.alarm,
                supervisor.SvscanControlAction.nuke
            ])
        except subproc.CalledProcessError as err:
            _LOGGER.warning('Failed to nuke svscan: %r',
                            self._tm_env.running_dir)

        return True
Пример #2
0
    def monitor_cmd(tkt_spool_dir, scandir, location):
        """Configure ticket locker for each cell."""
        if location:
            _LOGGER.info('Using location filter: %s', location)
        else:
            _LOGGER.info('No location filter, configuring all cells.')

        admin_cell = context.GLOBAL.admin.cell()
        while True:
            for cell in admin_cell.list({}):
                celluser = cell['username']
                cellname = cell['_id']
                celllocation = cell.get('location', '')
                if location and not fnmatch.fnmatch(celllocation, location):
                    _LOGGER.info('Skip cell by location: %s %s', cellname,
                                 celllocation)
                    continue

                _configure_locker(tkt_spool_dir, scandir, cellname, celluser)

            # TODO: need to stop/remove extra services. For now, extra
            #       services are removed on group restart.

            supervisor.control_svscan(scandir,
                                      (supervisor.SvscanControlAction.alarm,
                                       supervisor.SvscanControlAction.nuke))
            time.sleep(60)
Пример #3
0
    def _refresh_supervisor(self):
        """Notify the supervisor of new cleanup instances.
        """
        _LOGGER.info('Refreshing svscan')

        supervisor.control_svscan(self.tm_env.cleaning_dir,
                                  (supervisor.SvscanControlAction.alarm,
                                   supervisor.SvscanControlAction.nuke))
Пример #4
0
 def _scan(self, scan_dir):
     """Tells the svscan instance to rescan the given scan dir."""
     _LOGGER.debug('Scanning directory %r', scan_dir)
     try:
         supervisor.control_svscan(scan_dir,
                                   supervisor.SvscanControlAction.alarm)
     except subproc.CalledProcessError as ex:
         _LOGGER.warning(ex)
Пример #5
0
def _stop_on_lost(tm_env, state):
    _LOGGER.debug('ZK connection state: %s', state)
    if state == zkutils.states.KazooState.LOST:
        _LOGGER.info('ZK connection lost, stopping node.')
        _LOGGER.info('Terminating svscan in %s', tm_env.init_dir)
        supervisor.control_svscan(tm_env.init_dir,
                                  supervisor.SvscanControlAction.quit)
        # server_init should be terminated at this point but exit just in case.
        utils.sys_exit(-1)
Пример #6
0
 def test_control_svscan(self):
     """Tests controlling an svscan instance.
     """
     # Disable W0212(protected-access)
     # pylint: disable=W0212
     supervisor.control_svscan(self.root,
                               (supervisor.SvscanControlAction.alarm,
                                supervisor.SvscanControlAction.nuke))
     treadmill.subproc.check_call.assert_called_with(
         [supervisor._get_cmd('svscanctl'), '-an', self.root])
Пример #7
0
 def _refresh_supervisor(self):
     """Notify the supervisor of new instances to run."""
     supervisor.control_svscan(self.tm_env.running_dir,
                               (supervisor.SvscanControlAction.alarm,
                                supervisor.SvscanControlAction.nuke))