Commit 9aa64b62 authored by Stan Hu's avatar Stan Hu

Remove job logs from notification e-mails

Previously we included the last 30 lines of a job log in notification
e-mails to help give some details as to why a pipeline failed, but
including these logs in the e-mails has several issues:

1. Often more than 30 lines are needed to understand a build failure.
2. These logs could leak sensitive information.
3. The notification e-mails are scheduled around the same time when the
job log is archived to object storage, so the notification service may
need to read from a shared volume (NFS). There are race conditions when
the file has been archived, and we have to retry when these happen.

To avoid these pitfalls, we omit the logs from notification e-mails.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/247117
parent 039560b7
......@@ -23,10 +23,3 @@
= build.stage
%td{ align: "right", style: "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; padding: 16px 0; color: #8c8c8c; font-weight: 500; font-size: 14px;" }
= render "notify/links/#{build.to_partial_path}", pipeline: pipeline, build: build
%tr.build-log
- if build.has_trace?
%td{ colspan: "2", style: "font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; padding: 0 0 16px;" }
%pre{ style: "font-family: Monaco,'Lucida Console','Courier New',Courier,monospace; background-color: #fafafa; border-radius: 4px; overflow: hidden; white-space: pre-wrap; word-break: break-all; font-size:13px; line-height: 1.4; padding: 16px 8px; color: #333333; margin: 0;" }
= build.trace.html(last_lines: 30).html_safe
- else
%td{ colspan: "2" }
......@@ -14,7 +14,4 @@ had <%= failed.size %> failed <%= 'build'.pluralize(failed.size) %>.
<%= render "notify/links/#{build.to_partial_path}", pipeline: @pipeline, build: build %>
Stage: <%= build.stage %>
Name: <%= build.name %>
<% if build.has_trace? -%>
Trace: <%= build.trace.raw(last_lines: 30) %>
<% end -%>
<% end -%>
......@@ -34,8 +34,4 @@ had <%= failed.size %> failed <%= 'build'.pluralize(failed.size) %>.
<%= render "notify/links/#{build.to_partial_path}", pipeline: @pipeline, build: build %>
Stage: <%= build.stage %>
Name: <%= build.name %>
<% if build.has_trace? -%>
Trace: <%= build.trace.raw(last_lines: 30) %>
<% end -%>
<% end -%>
---
title: Remove job logs from notification e-mails
merge_request: 42395
author:
type: changed
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'notify/autodevops_disabled_email.text.erb' do
include Devise::Test::ControllerHelpers
let(:user) { create(:user, developer_projects: [project]) }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
:failed,
project: project,
user: user,
ref: project.default_branch,
sha: project.commit.sha)
end
before do
assign(:project, project)
assign(:pipeline, pipeline)
end
context 'when the pipeline contains a failed job' do
let!(:build) { create(:ci_build, :failed, :trace_live, pipeline: pipeline, project: pipeline.project) }
it 'renders the email correctly' do
render
expect(rendered).to have_content("Auto DevOps pipeline was disabled for #{project.name}")
expect(rendered).to match(/Pipeline ##{pipeline.id} .* triggered by #{pipeline.user.name}/)
expect(rendered).to have_content("Stage: #{build.stage}")
expect(rendered).to have_content("Name: #{build.name}")
expect(rendered).not_to have_content("Trace:")
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