Commit 62067564 authored by Sean Arnold's avatar Sean Arnold

Add tweaks to worker, service, specs

- Add docs page
parent 431fc543
......@@ -184,3 +184,9 @@ To quickly see the latest updates on an incident, click
un-threaded and ordered chronologically, newest to oldest:
![Timeline view toggle](./img/timeline_view_toggle_v13_5.png)
### Service Level Agreement Countdown Timer
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/241663) in GitLab 13.5.
If you have enabled Incident SLA in the Incident Management Configuration then you will see an SLA timer for your newly created incidents. The timer will show the time left to close in incident within the configured SLA time period. If an incident is not closed before the SLA is exceeded, then a `missed::SLA` label is added to the incident.
......@@ -6,7 +6,7 @@ module IncidentManagement
super(incident.project)
@incident = incident
@label = incident_exceeded_label
@label = incident_exceeded_sla_label
end
def execute
......@@ -28,7 +28,7 @@ module IncidentManagement
.execute(added_labels: [label])
end
def incident_exceeded_label
def incident_exceeded_sla_label
::IncidentManagement::CreateIncidentSlaExceededLabelService
.new(project)
.execute
......
......@@ -6,7 +6,7 @@ module IncidentManagement
title: 'missed::SLA',
color: '#D9534F',
description: <<~DESCRIPTION.chomp
Incidents that have missed the targeted SLA (Service Level Agreement).
Incidents that have missed the targeted SLA (Service Level Agreement). https://docs.gitlab.com/ee/operations/incident_management/incidents.html#service-level-agreement-countdown-timer
DESCRIPTION
}.freeze
......
......@@ -201,7 +201,7 @@
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent:
:idempotent: true
:tags: []
- :name: cronjob:ingress_modsecurity_counter_metrics
:feature_category: :web_firewall
......
......@@ -5,12 +5,17 @@ module IncidentManagement
include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
idempotent!
feature_category :incident_management
def perform
IncidentSla.exceeded.find_in_batches do |incident_slas|
incident_slas.each do |incident_sla|
ApplyIncidentSlaExceededLabelService.new(incident_sla.issue).execute
rescue StandardError => e
Gitlab::AppLogger.error("Error encountered in #{self.class.name}: #{e}")
end
end
end
......
......@@ -4,5 +4,9 @@ FactoryBot.define do
factory :issuable_sla do
issue
due_at { 1.hour.from_now }
trait :exceeded do
due_at { 1.hour.ago }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe IncidentManagement::IncidentSlaExceededCheckWorker do
let(:worker) { described_class.new }
describe '#perform' do
subject(:perform) { worker.perform }
let_it_be(:incident_1) { create(:incident_sla, :exceeded) }
let_it_be(:incident_2) { create(:incident_sla, :exceeded) }
let_it_be(:incident_3) { create(:incident_sla, :exceeded) }
let(:label_service_stub) { instance_double(IncidentManagement::ApplyIncidentSlaExceededLabelService, execute: true) }
it 'calls the apply incident sla label service' do
expect(IncidentManagement::ApplyIncidentSlaExceededLabelService)
.to receive(:new)
.exactly(3)
.and_return(label_service_stub)
expect(label_service_stub).to receive(:execute).exactly(3).times
perform
end
context 'when error occurs' do
before do
allow(IncidentManagement::ApplyIncidentSlaExceededLabelService)
.to receive(:new)
.and_return(label_service_stub)
allow(IncidentManagement::ApplyIncidentSlaExceededLabelService)
.to receive(:new)
.with(incident_1.issue)
.and_raise('test')
end
it 'logs the error and continues to run the others' do
expect(Gitlab::AppLogger).to receive(:error).once
expect(label_service_stub).to receive(:execute).exactly(2).times
perform
end
end
end
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