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
            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
Exemplo 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
Exemplo 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
Exemplo n.º 4
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()