-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Opt-in email notifications when {repo sync, cv promote, cv publish, p…
…roxy sync} fails (#10742) * Fixes #17748 - Opt-in email notification on repo sync failure * Fixes #17748 - Opt-in email notification on cv publish failure * Fixes #17748 - Opt-in email notification on cv promote failure * Fixes #17748 - Opt-in email notification on proxy sync failure * Refs #17748 - Make rubocop happy * Refs #17748 - Expose capsule content sync in events to be consumed from webhooks * Refs #17748 - Send emails also when things go into paused
- Loading branch information
1 parent
9d03ca6
commit fbf7739
Showing
14 changed files
with
352 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module Katello | ||
class TaskMailer < ApplicationMailer | ||
helper ApplicationHelper | ||
include Rails.application.routes.url_helpers | ||
|
||
def repo_sync_failure(options) | ||
user, @repo, @task = options.values_at(:user, :repo, :task) | ||
|
||
::User.as(user.login) do | ||
subject = _("Repository %{label} failed to synchronize") % { :label => @repo.label } | ||
|
||
set_locale_for(user) do | ||
mail(:to => user.mail, :subject => subject) | ||
end | ||
end | ||
end | ||
|
||
def cv_publish_failure(options) | ||
user, @content_view, @task = options.values_at(:user, :content_view, :task) | ||
|
||
::User.as(user.login) do | ||
subject = _("%{label} failed") % { :label => @task.action } | ||
|
||
set_locale_for(user) do | ||
mail(:to => user.mail, :subject => subject) | ||
end | ||
end | ||
end | ||
|
||
def cv_promote_failure(options) | ||
user, @content_view, @task = options.values_at(:user, :content_view, :task) | ||
|
||
::User.as(user.login) do | ||
subject = _("%{label} failed") % { :label => @task.action } | ||
|
||
set_locale_for(user) do | ||
mail(:to => user.mail, :subject => subject) | ||
end | ||
end | ||
end | ||
|
||
def proxy_sync_failure(options) | ||
user, @environment, @repo, @content_view, @task, @smart_proxy = options.values_at(:user, :environment, :repository, :content_view, :task, :smart_proxy) | ||
|
||
::User.as(user.login) do | ||
subject = _("%{label} failed") % { :label => @task.action } | ||
|
||
set_locale_for(user) do | ||
mail(:to => user.mail, :subject => subject) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<p> | ||
<%= _("%{label} failed.") % { :label => @task.action } %> | ||
</p> | ||
|
||
<div class="dashboard"> | ||
<table> | ||
<tr> | ||
<td><%= _('Content view') %></td> | ||
<td><%= link_to @content_view.name, "#{katello_url}content_views/#{@content_view.id}" %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task ID') %></td> | ||
<td><%= link_to @task.id, foreman_tasks_task_url(@task.id) %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task state') %></td> | ||
<td><%= @task.state %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task result') %></td> | ||
<td><%= @task.result %></td> | ||
</tr> | ||
</table> | ||
|
||
Errors: | ||
<ul> | ||
<% @task.execution_plan.errors.each do |error| %> | ||
<li><%= error.exception_class %>: <%= error.message %></li> | ||
<% end %> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%= _("%{label} failed.") % { :label => @task.action } %> | ||
|
||
<%= _('Content view ID') %>: <%= @content_view.id %> | ||
<%= _('Content view name') %>: <%= @content_view.name %> | ||
<%= _('Task ID') %>: <%= @task.id %> | ||
<%= _('Task state') %>: <%= @task.state %> | ||
<%= _('Task result') %>: <%= @task.result %> | ||
<%= _('Task details') %>: <%= foreman_tasks_task_url(@task) %> | ||
|
||
Errors: | ||
<% @task.execution_plan.errors.each do |error| %> | ||
- <%= error.exception_class %>: <%= error.message %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<p> | ||
<%= _("%{label} failed.") % { :label => @task.action } %> | ||
</p> | ||
|
||
<div class="dashboard"> | ||
<table> | ||
<tr> | ||
<td><%= _('Content view') %></td> | ||
<td><%= link_to @content_view.name, "#{katello_url}content_views/#{@content_view.id}" %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task ID') %></td> | ||
<td><%= link_to @task.id, foreman_tasks_task_url(@task.id) %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task state') %></td> | ||
<td><%= @task.state %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task result') %></td> | ||
<td><%= @task.result %></td> | ||
</tr> | ||
</table> | ||
|
||
Errors: | ||
<ul> | ||
<% @task.execution_plan.errors.each do |error| %> | ||
<li><%= error.exception_class %>: <%= error.message %></li> | ||
<% end %> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%= _("%{label} failed.") % { :label => @task.action } %> | ||
|
||
<%= _('Content view ID') %>: <%= @content_view.id %> | ||
<%= _('Content view name') %>: <%= @content_view.name %> | ||
<%= _('Task ID') %>: <%= @task.id %> | ||
<%= _('Task state') %>: <%= @task.state %> | ||
<%= _('Task result') %>: <%= @task.result %> | ||
<%= _('Task details') %>: <%= foreman_tasks_task_url(@task) %> | ||
|
||
Errors: | ||
<% @task.execution_plan.errors.each do |error| %> | ||
- <%= error.exception_class %>: <%= error.message %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<p> | ||
<%= _("%{label} failed.") % { :label => @task.action } %> | ||
</p> | ||
|
||
<div class="dashboard"> | ||
<table> | ||
<% if @environment %> | ||
<tr> | ||
<td><%= _('Environment') %></td> | ||
<td><%= link_to @environment.name, "#{katello_url}lifecycle_environments/#{@environment.id}" %></td> | ||
</tr> | ||
<% end %> | ||
<% if @content_view %> | ||
<tr> | ||
<td><%= _('Content view') %></td> | ||
<td><%= link_to @content_view.name, "#{katello_url}content_views/#{@content_view.id}" %></td> | ||
</tr> | ||
<% end %> | ||
<% if @repo %> | ||
<tr> | ||
<td><%= _('Repository') %></td> | ||
<td><%= link_to @repo.name, "#{katello_url}products/#{@repo.product.id}/repositories/#{@repo.id}" %></td> | ||
</tr> | ||
<% end %> | ||
<tr> | ||
<td><%= _('Task ID') %></td> | ||
<td><%= link_to @task.id, foreman_tasks_task_url(@task.id) %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task state') %></td> | ||
<td><%= @task.state %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task result') %></td> | ||
<td><%= @task.result %></td> | ||
</tr> | ||
</table> | ||
|
||
Errors: | ||
<ul> | ||
<% @task.execution_plan.errors.each do |error| %> | ||
<li><%= error.exception_class %>: <%= error.message %></li> | ||
<% end %> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<%= _("%{label} failed.") % { :label => @task.action } %> | ||
|
||
<%= _('Smart proxy ID') %>: <%= @smart_proxy.id %> | ||
<%= _('Smart proxy name') %>: <%= @smart_proxy.name %> | ||
<% if @environment %> | ||
<%= _('Environment ID') %>: <%= @environment&.id %> | ||
<%= _('Environment name') %>: <%= @environment&.name %> | ||
<% end %> | ||
<% if @content_view %> | ||
<%= _('Content view ID') %>: <%= @content_view&.id %> | ||
<%= _('Content view name') %>: <%= @content_view&.name %> | ||
<% end %> | ||
<% if @repo %> | ||
<%= _('Repository ID') %>: <%= @repo&.id %> | ||
<%= _('Repository name') %>: <%= @repo&.name %> | ||
<% end %> | ||
<%= _('Task ID') %>: <%= @task.id %> | ||
<%= _('Task state') %>: <%= @task.state %> | ||
<%= _('Task result') %>: <%= @task.result %> | ||
<%= _('Task details') %>: <%= foreman_tasks_task_url(@task) %> | ||
|
||
Errors: | ||
<% @task.execution_plan.errors.each do |error| %> | ||
- <%= error.exception_class %>: <%= error.message %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<p> | ||
<%= _("%{label} failed.") % { :label => @task.action } %> | ||
</p> | ||
|
||
<div class="dashboard"> | ||
<table> | ||
<tr> | ||
<td><%= _('Repository') %></td> | ||
<td><%= link_to @repo.label, "#{katello_url}products/#{@repo.product.id}/repositories/#{@repo.id}" %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Product') %></td> | ||
<td><%= link_to @repo.product.label, "#{katello_url}products/#{@repo.product.id}" %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task ID') %></td> | ||
<td><%= link_to @task.id, foreman_tasks_task_url(@task.id) %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task state') %></td> | ||
<td><%= @task.state %></td> | ||
</tr> | ||
<tr> | ||
<td><%= _('Task result') %></td> | ||
<td><%= @task.result %></td> | ||
</tr> | ||
</table> | ||
|
||
Errors: | ||
<ul> | ||
<% @task.execution_plan.errors.each do |error| %> | ||
<li><%= error.exception_class %>: <%= error.message %></li> | ||
<% end %> | ||
</ul> | ||
</div> |
Oops, something went wrong.