Esempio 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
            self.info(
                "Disabling indexer permanently until reenabled by user because the authentication failed"
            )
        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])
            self.info(
                "Disabling indexer temporarily due to access problems. Will be reenabled %s"
                % indexer_status.disabled_until.humanize())

        if saveIndexerStatus:
            self.saveIndexerStatus(indexer_status)

        return indexer_status
Esempio n. 2
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
            self.info("Disabling indexer permanently until reenabled by user because the authentication failed")
        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])
            self.info(
                "Disabling indexer temporarily due to access problems. Will be reenabled %s"
                % indexer_status.disabled_until.humanize()
            )

        if saveIndexerStatus:
            self.saveIndexerStatus(indexer_status)

        return indexer_status
Esempio n. 3
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:
            self.saveIndexerStatus(indexer_status)
        return indexer_status
Esempio n. 4
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()})
Esempio n. 5
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()})
Esempio n. 6
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()
Esempio n. 7
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
Esempio n. 8
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()