Commit dd5bd821 authored by Stan Hu's avatar Stan Hu

Merge branch 'log-more-info-ci-minutes-tracking' into 'master'

Log more info when dropping jobs on CI minutes exceeded

See merge request gitlab-org/gitlab!61619
parents 56042801 d2ed2685
......@@ -30,10 +30,11 @@ module Ci
::Gitlab::AppLogger.info(
message: 'Build dropped due to CI minutes limit exceeded',
namespace: root_namespace.name,
project_path: build.project.full_path,
build_id: build.id,
user_id: build.user_id
)
user_id: build.user_id,
username: build.user&.username)
ServiceResponse.success(message: 'Build dropped due to CI minutes limit exceeded', payload: { current_balance: new_balance })
else
......
......@@ -5,7 +5,8 @@ require 'spec_helper'
RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
let(:project) { create(:project, :private, shared_runners_enabled: true, namespace: namespace) }
let(:namespace) { create(:namespace, shared_runners_minutes_limit: 100) }
let(:build) { create(:ci_build, :running, project: project, runner: runner) }
let(:user) { create(:user) }
let(:build) { create(:ci_build, :running, project: project, runner: runner, user: user) }
let(:runner) { create(:ci_runner, :instance) }
let(:service) { described_class.new(build) }
......@@ -53,9 +54,11 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
it 'logs event' do
expect(Gitlab::AppLogger).to receive(:info).with(
message: 'Build dropped due to CI minutes limit exceeded',
namespace: project.root_namespace.name,
project_path: project.full_path,
build_id: build.id,
user_id: build.user_id)
user_id: user.id,
username: user.username)
subject
end
......
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