diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-30 09:09:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-30 09:09:27 +0300 |
commit | b920d2a9831056cdf907cf71fd25d94f0aaf1e6c (patch) | |
tree | 37d937a61754aa5072fd607fbd2aa8ed00225d6a /app | |
parent | 3778629470659207d15cbc8b7064b0eb3caf09ef (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/notebook/cells/markdown.vue | 9 | ||||
-rw-r--r-- | app/models/bulk_imports/tracker.rb | 2 | ||||
-rw-r--r-- | app/workers/bulk_imports/pipeline_worker.rb | 32 |
3 files changed, 36 insertions, 7 deletions
diff --git a/app/assets/javascripts/notebook/cells/markdown.vue b/app/assets/javascripts/notebook/cells/markdown.vue index 1384c9c40b3..073b27605bb 100644 --- a/app/assets/javascripts/notebook/cells/markdown.vue +++ b/app/assets/javascripts/notebook/cells/markdown.vue @@ -1,6 +1,7 @@ <script> import katex from 'katex'; import marked from 'marked'; +import { GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui'; import { sanitize } from '~/lib/dompurify'; import { hasContent, markdownConfig } from '~/lib/utils/text_utility'; import Prompt from './prompt.vue'; @@ -138,6 +139,9 @@ export default { components: { prompt: Prompt, }, + directives: { + SafeHtml, + }, inject: ['relativeRawPath'], props: { cell: { @@ -150,16 +154,17 @@ export default { renderer.attachments = this.cell.attachments; renderer.relativeRawPath = this.relativeRawPath; - return sanitize(marked(this.cell.source.join('').replace(/\\/g, '\\\\')), markdownConfig); + return marked(this.cell.source.join('').replace(/\\/g, '\\\\')); }, }, + markdownConfig, }; </script> <template> <div class="cell text-cell"> <prompt /> - <div class="markdown" v-html="markdown /* eslint-disable-line vue/no-v-html */"></div> + <div v-safe-html:[$options.markdownConfig]="markdown" class="markdown"></div> </div> </template> diff --git a/app/models/bulk_imports/tracker.rb b/app/models/bulk_imports/tracker.rb index c185470b1c2..9de3239ee0f 100644 --- a/app/models/bulk_imports/tracker.rb +++ b/app/models/bulk_imports/tracker.rb @@ -50,6 +50,8 @@ class BulkImports::Tracker < ApplicationRecord event :start do transition created: :started + # To avoid errors when re-starting a pipeline in case of network errors + transition started: :started end event :finish do diff --git a/app/workers/bulk_imports/pipeline_worker.rb b/app/workers/bulk_imports/pipeline_worker.rb index 760a309a381..35633b55489 100644 --- a/app/workers/bulk_imports/pipeline_worker.rb +++ b/app/workers/bulk_imports/pipeline_worker.rb @@ -16,7 +16,7 @@ module BulkImports def perform(pipeline_tracker_id, stage, entity_id) pipeline_tracker = ::BulkImports::Tracker - .with_status(:created) + .with_status(:created, :started) .find_by_id(pipeline_tracker_id) if pipeline_tracker.present? @@ -59,18 +59,35 @@ module BulkImports pipeline_tracker.pipeline_class.new(context).run pipeline_tracker.finish! + rescue BulkImports::NetworkError => e + if e.retriable?(pipeline_tracker) + logger.error( + worker: self.class.name, + entity_id: pipeline_tracker.entity.id, + pipeline_name: pipeline_tracker.pipeline_name, + message: "Retrying error: #{e.message}" + ) + + reenqueue(pipeline_tracker, delay: e.retry_delay) + else + fail_tracker(pipeline_tracker, e) + end rescue StandardError => e + fail_tracker(pipeline_tracker, e) + end + + def fail_tracker(pipeline_tracker, exception) pipeline_tracker.update!(status_event: 'fail_op', jid: jid) logger.error( worker: self.class.name, entity_id: pipeline_tracker.entity.id, pipeline_name: pipeline_tracker.pipeline_name, - message: e.message + message: exception.message ) Gitlab::ErrorTracking.track_exception( - e, + exception, entity_id: pipeline_tracker.entity.id, pipeline_name: pipeline_tracker.pipeline_name ) @@ -88,8 +105,13 @@ module BulkImports (Time.zone.now - pipeline_tracker.entity.created_at) > Pipeline::NDJSON_EXPORT_TIMEOUT end - def reenqueue(pipeline_tracker) - self.class.perform_in(NDJSON_PIPELINE_PERFORM_DELAY, pipeline_tracker.id, pipeline_tracker.stage, pipeline_tracker.entity.id) + def reenqueue(pipeline_tracker, delay: NDJSON_PIPELINE_PERFORM_DELAY) + self.class.perform_in( + delay, + pipeline_tracker.id, + pipeline_tracker.stage, + pipeline_tracker.entity.id + ) end end end |