Esempio n. 1
0
    def wait(self):
        blob_count = self.archiver.blob_count
        log.info('Started job %s processing %i blobs', self.job.name,
                 blob_count)
        self._notify(JOB_WAIT)
        try:
            jobout = self.job.wait()
            log.info('Done waiting for job %s', self.job.name)
            self._profile(self.job)
            self._tag_results(self.job.name)
            if not self.settings.get('debug'):
                try_to_execute(
                    partial(self._process_results, jobout, self.job.name))
            else:
                results = self._get_job_results(jobout)
                reduce_result(results)
            self._purge(self._safe_str(self.job.name))
        except Exception as e:
            log.error('Job %s failed with %s', self.job.name, e.message)
            self._notify(JOB_ERROR)
            if self.rule.notify_on_fail:
                try:
                    from inferno.lib.notifications import send_mail
                    send_mail(job_id=self.job.name,
                              job_fail=e,
                              mail_to=self.rule.notify_addresses,
                              mail_from=self.settings.get('mail_from'),
                              mail_server=self.settings.get('mail_server'),
                              retry=self.rule.retry,
                              retry_delay=self.rule.retry_delay)
                except Exception as e:
                    log.error('Job %s failed notification: %s',
                              self.job.name,
                              e,
                              exc_info=sys.exc_info())
            raise
        else:
            if not self.settings.get('debug'):
                try_to_execute(partial(self._archive_tags, self.archiver))

            if self.rule.rule_cleanup:
                self._notify(JOB_CLEANUP)
                self.rule.rule_cleanup(self, )
            self._notify(JOB_DONE)
            if self.rule.notify_on_success:
                try:
                    from inferno.lib.notifications import send_mail
                    msg = "Job %s finished successfully." % self.job.name
                    send_mail(job_id=self.job.name,
                              job_fail=msg,
                              mail_to=self.rule.notify_addresses,
                              mail_from=self.settings.get('mail_from'),
                              mail_server=self.settings.get('mail_server'))
                except Exception as e:
                    log.error('Job %s failed notification: %s',
                              self.job.name,
                              e,
                              exc_info=sys.exc_info())
        log.info('Finished job %s', self.job.name)
Esempio n. 2
0
    def wait(self):
        blob_count = self.archiver.blob_count
        log.info("Started job %s processing %i blobs", self.job.name, blob_count)
        self._notify(JOB_WAIT)
        try:
            jobout = self.job.wait()
            log.info("Done waiting for job %s", self.job.name)
            self._profile(self.job)
            self._tag_results(self.job.name)
            if not self.settings.get("debug"):
                self._process_results(jobout, self.job.name)
            else:
                results = self._get_job_results(jobout)
                reduce_result(results)
            self._purge(self._safe_str(self.job.name))
        except Exception as e:
            log.error("Job %s failed", self.job.name)
            self._notify(JOB_ERROR)
            if self.rule.notify_on_fail:
                try:
                    from inferno.lib.notifications import send_mail

                    send_mail(
                        job_id=self.job.name,
                        job_fail=e,
                        mail_to=self.rule.notify_addresses,
                        mail_from=self.settings.get("mail_from"),
                        mail_server=self.settings.get("mail_server"),
                    )
                except Exception as e:
                    log.error("Job %s failed notification: %s", self.job.name, e, exc_info=sys.exc_info())
            raise
        else:
            if not self.settings.get("debug"):
                self._archive_tags(self.archiver)
            if self.rule.rule_cleanup:
                self._notify(JOB_CLEANUP)
                self.rule.rule_cleanup(self)
            self._notify(JOB_DONE)
            if self.rule.notify_on_success:
                try:
                    from inferno.lib.notifications import send_mail

                    msg = "Job %s finished successfully." % self.job.name
                    send_mail(
                        job_id=self.job.name,
                        job_fail=msg,
                        mail_to=self.rule.notify_addresses,
                        mail_from=self.settings.get("mail_from"),
                        mail_server=self.settings.get("mail_server"),
                    )
                except Exception as e:
                    log.error("Job %s failed notification: %s", self.job.name, e, exc_info=sys.exc_info())
        log.info("Finished job %s", self.job.name)
Esempio n. 3
0
    def wait(self):
        blob_count = self.archiver.blob_count
        log.info('Started job %s processing %i blobs',
                 self.job.name, blob_count)
        self._notify(JOB_WAIT)
        try:
            jobout = self.job.wait()
            log.info('Done waiting for job %s', self.job.name)
            self._profile(self.job)
            self._tag_results(self.job.name)
            if not self.settings.get('debug'):
                try_to_execute(partial(self._process_results, jobout, self.job.name))
            else:
                results = self._get_job_results(jobout)
                reduce_result(results)
            self._purge(self._safe_str(self.job.name))
        except Exception as e:
            log.error('Job %s failed with %s', self.job.name, e.message)
            self._notify(JOB_ERROR)
            if self.rule.notify_on_fail:
                try:
                    from inferno.lib.notifications import send_mail
                    send_mail(job_id=self.job.name, job_fail=e,
                              mail_to=self.rule.notify_addresses,
                              mail_from=self.settings.get('mail_from'),
                              mail_server=self.settings.get('mail_server'),
                              retry=self.rule.retry,
                              retry_delay=self.rule.retry_delay)
                except Exception as e:
                    log.error('Job %s failed notification: %s', self.job.name, e, exc_info=sys.exc_info())
            raise
        else:
            if not self.settings.get('debug'):
                try_to_execute(partial(self._archive_tags, self.archiver))

            if self.rule.rule_cleanup:
                self._notify(JOB_CLEANUP)
                self.rule.rule_cleanup(self, )
            self._notify(JOB_DONE)
            if self.rule.notify_on_success:
                try:
                    from inferno.lib.notifications import send_mail
                    msg = "Job %s finished successfully." % self.job.name
                    send_mail(job_id=self.job.name, job_fail=msg,
                              mail_to=self.rule.notify_addresses,
                              mail_from=self.settings.get('mail_from'),
                              mail_server=self.settings.get('mail_server'))
                except Exception as e:
                    log.error('Job %s failed notification: %s', self.job.name, e, exc_info=sys.exc_info())
        log.info('Finished job %s', self.job.name)