Exemplo n.º 1
0
    def handle_indexer_failure(self,
                               reason=None,
                               disable_permanently=False,
                               saveIndexerStatus=True):
        # Escalate level by 1. Set disabled-time according to level so that with increased level the time is further in the future
        try:
            indexer_status = self.indexer.status.get()
        except IndexerStatus.DoesNotExist:
            indexer_status = IndexerStatus(indexer=self.indexer)

        if indexer_status.level == 0:
            indexer_status.first_failure = arrow.utcnow()

        indexer_status.latest_failure = arrow.utcnow()
        indexer_status.reason = reason  # Overwrite the last reason if one is set, should've been logged anyway
        if disable_permanently:
            indexer_status.disabled_permanently = True
        else:
            indexer_status.level = min(
                len(self.disable_periods) - 1, indexer_status.level + 1)
            indexer_status.disabled_until = arrow.utcnow().replace(
                minutes=self.disable_periods[indexer_status.level])

        if saveIndexerStatus:
            indexer_status.save()
        return indexer_status
Exemplo n.º 2
0
def internalapi_enable_indexer(args):
    logger.debug("Enabling indexer %s" % args["name"])
    indexer_status = IndexerStatus().select().join(Indexer).where(fn.lower(Indexer.name) == args["name"].lower()).get()
    indexer_status.disabled_until = 0
    indexer_status.reason = None
    indexer_status.level = 0
    indexer_status.save()
    return jsonify({"indexerStatuses": get_indexer_statuses()})
Exemplo n.º 3
0
def internalapi_enable_indexer(args):
    logger.debug("Enabling indexer %s" % args["name"])
    indexer_status = IndexerStatus().select().join(Indexer).where(fn.lower(Indexer.name) == args["name"].lower())
    indexer_status.disabled_until = 0
    indexer_status.reason = None
    indexer_status.level = 0
    indexer_status.save()
    return jsonify({"indexerStatuses": get_indexer_statuses()})
Exemplo n.º 4
0
 def handle_indexer_success(self):
     # Deescalate level by 1 (or stay at 0) and reset reason and disable-time
     try:
         indexer_status = self.indexer.status.get()
     except IndexerStatus.DoesNotExist:
         indexer_status = IndexerStatus(indexer=self.indexer)
     if indexer_status.level > 0:
         indexer_status.level -= 1
     indexer_status.reason = None
     indexer_status.disabled_until = arrow.get(0)  # Because I'm too dumb to set it to None/null
     indexer_status.save()
Exemplo n.º 5
0
 def handle_indexer_success(self, saveIndexerStatus=True):
     # Deescalate level by 1 (or stay at 0) and reset reason and disable-time
     try:
         indexer_status = self.indexer.status.get()
     except IndexerStatus.DoesNotExist:
         indexer_status = IndexerStatus(indexer=self.indexer)
     if indexer_status.level > 0:
         indexer_status.level -= 1
     indexer_status.reason = None
     indexer_status.disabled_until = arrow.get(0)  # Because I'm too dumb to set it to None/null
     
     if saveIndexerStatus:
         indexer_status.save()
     return indexer_status
Exemplo n.º 6
0
    def handle_indexer_failure(self, reason=None, disable_permanently=False):
        # Escalate level by 1. Set disabled-time according to level so that with increased level the time is further in the future
        try:
            indexer_status = self.indexer.status.get()
        except IndexerStatus.DoesNotExist:
            indexer_status = IndexerStatus(indexer=self.indexer)

        if indexer_status.level == 0:
            indexer_status.first_failure = arrow.utcnow()

        indexer_status.latest_failure = arrow.utcnow()
        indexer_status.reason = reason  # Overwrite the last reason if one is set, should've been logged anyway
        if disable_permanently:
            indexer_status.disabled_permanently = True
        else:
            indexer_status.level = min(len(self.disable_periods) - 1, indexer_status.level + 1)
            indexer_status.disabled_until = arrow.utcnow().replace(minutes=self.disable_periods[indexer_status.level])

        indexer_status.save()