Commit 896b27d8 authored by Allison Browne's avatar Allison Browne

Add urgency to job related endpoints

parent a96243b0
...@@ -5,6 +5,9 @@ class Projects::BuildsController < Projects::ApplicationController ...@@ -5,6 +5,9 @@ class Projects::BuildsController < Projects::ApplicationController
feature_category :continuous_integration feature_category :continuous_integration
urgency :high, [:index, :show]
urgency :low, [:raw]
def index def index
redirect_to project_jobs_path(project) redirect_to project_jobs_path(project)
end end
......
...@@ -4,6 +4,8 @@ class Projects::JobsController < Projects::ApplicationController ...@@ -4,6 +4,8 @@ class Projects::JobsController < Projects::ApplicationController
include SendFileUpload include SendFileUpload
include ContinueParams include ContinueParams
urgency :low, [:index, :show, :trace, :retry, :play, :cancel, :unschedule, :status, :erase, :raw]
before_action :find_job_as_build, except: [:index, :play, :show] before_action :find_job_as_build, except: [:index, :play, :show]
before_action :find_job_as_processable, only: [:play, :show] before_action :find_job_as_processable, only: [:play, :show]
before_action :authorize_read_build_trace!, only: [:trace, :raw] before_action :authorize_read_build_trace!, only: [:trace, :raw]
......
...@@ -87,7 +87,8 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -87,7 +87,8 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
:ci_environments_status, :ci_environments_status,
:destroy, :destroy,
:rebase, :rebase,
:discussions :discussions,
:pipelines
] ]
def index def index
......
...@@ -5,6 +5,10 @@ module Projects ...@@ -5,6 +5,10 @@ module Projects
class StagesController < Projects::Pipelines::ApplicationController class StagesController < Projects::Pipelines::ApplicationController
before_action :authorize_update_pipeline! before_action :authorize_update_pipeline!
urgency :low, [
:play_manual
]
def play_manual def play_manual
::Ci::PlayManualStageService ::Ci::PlayManualStageService
.new(@project, current_user, pipeline: pipeline) .new(@project, current_user, pipeline: pipeline)
......
...@@ -4,6 +4,9 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -4,6 +4,9 @@ class Projects::PipelinesController < Projects::ApplicationController
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
include RedisTracking include RedisTracking
urgency :default, [:status]
urgency :low, [:index, :new, :builds, :show, :failures, :create, :stage, :retry, :dag, :cancel]
before_action :disable_query_limiting, only: [:create, :retry] before_action :disable_query_limiting, only: [:create, :retry]
before_action :pipeline, except: [:index, :new, :create, :charts, :config_variables] before_action :pipeline, except: [:index, :new, :create, :charts, :config_variables]
before_action :set_pipeline_path, only: [:show] before_action :set_pipeline_path, only: [:show]
......
...@@ -38,7 +38,7 @@ module API ...@@ -38,7 +38,7 @@ module API
use :pagination use :pagination
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
get ':id/jobs', feature_category: :continuous_integration do get ':id/jobs', urgency: :low, feature_category: :continuous_integration do
authorize_read_builds! authorize_read_builds!
builds = user_project.builds.order('id DESC') builds = user_project.builds.order('id DESC')
...@@ -55,7 +55,7 @@ module API ...@@ -55,7 +55,7 @@ module API
params do params do
requires :job_id, type: Integer, desc: 'The ID of a job' requires :job_id, type: Integer, desc: 'The ID of a job'
end end
get ':id/jobs/:job_id', feature_category: :continuous_integration do get ':id/jobs/:job_id', urgency: :low, feature_category: :continuous_integration do
authorize_read_builds! authorize_read_builds!
build = find_build!(params[:job_id]) build = find_build!(params[:job_id])
...@@ -70,7 +70,7 @@ module API ...@@ -70,7 +70,7 @@ module API
params do params do
requires :job_id, type: Integer, desc: 'The ID of a job' requires :job_id, type: Integer, desc: 'The ID of a job'
end end
get ':id/jobs/:job_id/trace', feature_category: :continuous_integration do get ':id/jobs/:job_id/trace', urgency: :low, feature_category: :continuous_integration do
authorize_read_builds! authorize_read_builds!
build = find_build!(params[:job_id]) build = find_build!(params[:job_id])
...@@ -92,7 +92,7 @@ module API ...@@ -92,7 +92,7 @@ module API
params do params do
requires :job_id, type: Integer, desc: 'The ID of a job' requires :job_id, type: Integer, desc: 'The ID of a job'
end end
post ':id/jobs/:job_id/cancel', feature_category: :continuous_integration do post ':id/jobs/:job_id/cancel', urgency: :low, feature_category: :continuous_integration do
authorize_update_builds! authorize_update_builds!
build = find_build!(params[:job_id]) build = find_build!(params[:job_id])
...@@ -109,7 +109,7 @@ module API ...@@ -109,7 +109,7 @@ module API
params do params do
requires :job_id, type: Integer, desc: 'The ID of a build' requires :job_id, type: Integer, desc: 'The ID of a build'
end end
post ':id/jobs/:job_id/retry', feature_category: :continuous_integration do post ':id/jobs/:job_id/retry', urgency: :low, feature_category: :continuous_integration do
authorize_update_builds! authorize_update_builds!
build = find_build!(params[:job_id]) build = find_build!(params[:job_id])
...@@ -127,7 +127,7 @@ module API ...@@ -127,7 +127,7 @@ module API
params do params do
requires :job_id, type: Integer, desc: 'The ID of a build' requires :job_id, type: Integer, desc: 'The ID of a build'
end end
post ':id/jobs/:job_id/erase', feature_category: :continuous_integration do post ':id/jobs/:job_id/erase', urgency: :low, feature_category: :continuous_integration do
authorize_update_builds! authorize_update_builds!
build = find_build!(params[:job_id]) build = find_build!(params[:job_id])
...@@ -146,7 +146,7 @@ module API ...@@ -146,7 +146,7 @@ module API
requires :job_id, type: Integer, desc: 'The ID of a Job' requires :job_id, type: Integer, desc: 'The ID of a Job'
end end
post ":id/jobs/:job_id/play", feature_category: :continuous_integration do post ':id/jobs/:job_id/play', urgency: :low, feature_category: :continuous_integration do
authorize_read_builds! authorize_read_builds!
job = find_job!(params[:job_id]) job = find_job!(params[:job_id])
...@@ -168,11 +168,11 @@ module API ...@@ -168,11 +168,11 @@ module API
end end
resource :job do resource :job do
desc 'Get current project using job token' do desc 'Get current job using job token' do
success Entities::Ci::Job success Entities::Ci::Job
end end
route_setting :authentication, job_token_allowed: true route_setting :authentication, job_token_allowed: true
get '', feature_category: :continuous_integration do get '', feature_category: :continuous_integration, urgency: :low do
validate_current_authenticated_job validate_current_authenticated_job
present current_authenticated_job, with: Entities::Ci::Job present current_authenticated_job, with: Entities::Ci::Job
......
...@@ -123,7 +123,7 @@ module API ...@@ -123,7 +123,7 @@ module API
use :pagination use :pagination
end end
get ':id/pipelines/:pipeline_id/jobs', feature_category: :continuous_integration do get ':id/pipelines/:pipeline_id/jobs', urgency: :low, feature_category: :continuous_integration do
authorize!(:read_pipeline, user_project) authorize!(:read_pipeline, user_project)
pipeline = user_project.all_pipelines.find(params[:pipeline_id]) pipeline = user_project.all_pipelines.find(params[:pipeline_id])
......
...@@ -118,7 +118,7 @@ module API ...@@ -118,7 +118,7 @@ module API
formatter :build_json, ->(object, _) { object } formatter :build_json, ->(object, _) { object }
parser :build_json, ::Grape::Parser::Json parser :build_json, ::Grape::Parser::Json
post '/request', feature_category: :continuous_integration do post '/request', urgency: :low, feature_category: :continuous_integration do
authenticate_runner! authenticate_runner!
unless current_runner.active? unless current_runner.active?
...@@ -172,7 +172,7 @@ module API ...@@ -172,7 +172,7 @@ module API
end end
optional :exit_code, type: Integer, desc: %q(Job's exit code) optional :exit_code, type: Integer, desc: %q(Job's exit code)
end end
put '/:id', feature_category: :continuous_integration do put '/:id', urgency: :low, feature_category: :continuous_integration do
job = authenticate_job!(heartbeat_runner: true) job = authenticate_job!(heartbeat_runner: true)
Gitlab::Metrics.add_event(:update_build) Gitlab::Metrics.add_event(:update_build)
...@@ -199,7 +199,7 @@ module API ...@@ -199,7 +199,7 @@ module API
requires :id, type: Integer, desc: %q(Job's ID) requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token) optional :token, type: String, desc: %q(Job's authentication token)
end end
patch '/:id/trace', feature_category: :continuous_integration do patch '/:id/trace', urgency: :default, feature_category: :continuous_integration do
job = authenticate_job!(heartbeat_runner: true) job = authenticate_job!(heartbeat_runner: true)
error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range') error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment