diff options
Diffstat (limited to 'lib/api/ci')
-rw-r--r-- | lib/api/ci/helpers/runner.rb | 6 | ||||
-rw-r--r-- | lib/api/ci/pipelines.rb | 3 | ||||
-rw-r--r-- | lib/api/ci/runner.rb | 2 | ||||
-rw-r--r-- | lib/api/ci/secure_files.rb | 11 |
4 files changed, 18 insertions, 4 deletions
diff --git a/lib/api/ci/helpers/runner.rb b/lib/api/ci/helpers/runner.rb index 7ca8b2df3dd..94c1942a244 100644 --- a/lib/api/ci/helpers/runner.rb +++ b/lib/api/ci/helpers/runner.rb @@ -146,6 +146,12 @@ module API # noop: overridden in EE end + def check_if_backoff_required! + return unless Gitlab::Database::Migrations::RunnerBackoff::Communicator.backoff_runner? + + too_many_requests!('Executing database migrations. Please retry later.', retry_after: 1.minute) + end + private def get_runner_config_from_request diff --git a/lib/api/ci/pipelines.rb b/lib/api/ci/pipelines.rb index 6416de6d2a9..809a9bd781b 100644 --- a/lib/api/ci/pipelines.rb +++ b/lib/api/ci/pipelines.rb @@ -329,7 +329,8 @@ module API post ':id/pipelines/:pipeline_id/cancel', urgency: :low, feature_category: :continuous_integration do authorize! :update_pipeline, pipeline - pipeline.cancel_running + # TODO: inconsistent behavior: when pipeline is not cancelable we should return an error + ::Ci::CancelPipelineService.new(pipeline: pipeline, current_user: current_user).execute status 200 present pipeline.reset, with: Entities::Ci::Pipeline diff --git a/lib/api/ci/runner.rb b/lib/api/ci/runner.rb index 0247ce301e2..25ac1780a36 100644 --- a/lib/api/ci/runner.rb +++ b/lib/api/ci/runner.rb @@ -7,6 +7,8 @@ module API content_type :txt, 'text/plain' + before { check_if_backoff_required! } + resource :runners do desc 'Register a new runner' do detail "Register a new runner for the instance" diff --git a/lib/api/ci/secure_files.rb b/lib/api/ci/secure_files.rb index 41faaf80c82..02f625f2130 100644 --- a/lib/api/ci/secure_files.rb +++ b/lib/api/ci/secure_files.rb @@ -6,6 +6,7 @@ module API include PaginationParams before do + check_api_enabled! authenticate! authorize! :read_secure_files, user_project end @@ -64,7 +65,7 @@ module API resource do before do - read_only_feature_flag_enabled? + check_read_only_feature_flag_enabled! authorize! :admin_secure_files, user_project end @@ -81,7 +82,7 @@ module API route_setting :authentication, basic_auth_personal_access_token: true, job_token_allowed: true post ':id/secure_files' do secure_file = user_project.secure_files.new( - name: Gitlab::Utils.check_path_traversal!(params[:name]) + name: Gitlab::PathTraversal.check_path_traversal!(params[:name]) ) secure_file.file = params[:file] @@ -112,7 +113,11 @@ module API end helpers do - def read_only_feature_flag_enabled? + def check_api_enabled! + forbidden! unless Gitlab.config.ci_secure_files.enabled + end + + def check_read_only_feature_flag_enabled! service_unavailable! if Feature.enabled?(:ci_secure_files_read_only, user_project, type: :ops) end end |