Commit 0715b53b authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents b2d21327 c61fd077
......@@ -31,7 +31,9 @@ class WikiPage
pages.each_with_object([]) do |page, grouped_pages|
next grouped_pages << page unless page.directory.present?
directory = grouped_pages.find { |dir| dir.slug == page.directory }
directory = grouped_pages.find do |obj|
obj.is_a?(WikiDirectory) && obj.slug == page.directory
end
next directory.pages << page if directory
......
......@@ -7,6 +7,13 @@ module Clusters
return unless app.scheduled?
app.make_installing!
install
end
private
def install
log_event(:begin_install)
helm_api.install(install_command)
......@@ -18,7 +25,7 @@ module Clusters
app.make_errored!("Kubernetes error: #{e.error_code}")
rescue StandardError => e
log_error(e)
app.make_errored!("Can't start installation process.")
app.make_errored!('Failed to install.')
end
end
end
......
......@@ -8,6 +8,12 @@ module Clusters
app.make_updating!
patch
end
private
def patch
log_event(:begin_patch)
helm_api.update(update_command)
......@@ -16,10 +22,10 @@ module Clusters
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue Kubeclient::HttpError => e
log_error(e)
app.make_update_errored!("Kubernetes error: #{e.error_code}")
app.make_errored!("Kubernetes error: #{e.error_code}")
rescue StandardError => e
log_error(e)
app.make_update_errored!("Can't start update process.")
app.make_errored!('Failed to update.')
end
end
end
......
......@@ -6,24 +6,28 @@ module Clusters
def execute
return unless app.scheduled?
begin
app.make_updating!
app.make_updating!
log_event(:begin_upgrade)
# install_command works with upgrades too
# as it basically does `helm upgrade --install`
helm_api.update(install_command)
upgrade
end
private
def upgrade
# install_command works with upgrades too
# as it basically does `helm upgrade --install`
log_event(:begin_upgrade)
helm_api.update(install_command)
log_event(:schedule_wait_for_upgrade)
ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue Kubeclient::HttpError => e
log_error(e)
app.make_update_errored!("Kubernetes error: #{e.error_code}")
rescue StandardError => e
log_error(e)
app.make_update_errored!("Can't start upgrade process.")
end
log_event(:schedule_wait_for_upgrade)
ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue Kubeclient::HttpError => e
log_error(e)
app.make_errored!("Kubernetes error: #{e.error_code}")
rescue StandardError => e
log_error(e)
app.make_errored!('Failed to upgrade.')
end
end
end
......
......@@ -22,6 +22,7 @@ describe WikiPage do
create_page('dir_1/dir_1_1/page_3', 'content')
create_page('page_1', 'content')
create_page('dir_1/page_2', 'content')
create_page('dir_2', 'page with dir name')
create_page('dir_2/page_5', 'content')
create_page('page_6', 'content')
create_page('dir_2/page_4', 'content')
......@@ -29,6 +30,7 @@ describe WikiPage do
let(:page_1) { wiki.find_page('page_1') }
let(:page_6) { wiki.find_page('page_6') }
let(:page_dir_2) { wiki.find_page('dir_2') }
let(:dir_1) do
WikiDirectory.new('dir_1', [wiki.find_page('dir_1/page_2')])
......@@ -44,7 +46,7 @@ describe WikiPage do
context 'sort by title' do
let(:grouped_entries) { described_class.group_by_directory(wiki.pages) }
let(:expected_grouped_entries) { [dir_1_1, dir_1, dir_2, page_1, page_6] }
let(:expected_grouped_entries) { [dir_1_1, dir_1, page_dir_2, dir_2, page_1, page_6] }
it 'returns an array with pages and directories' do
grouped_entries.each_with_index do |page_or_dir, i|
......@@ -59,7 +61,7 @@ describe WikiPage do
context 'sort by created_at' do
let(:grouped_entries) { described_class.group_by_directory(wiki.pages(sort: 'created_at')) }
let(:expected_grouped_entries) { [dir_1_1, page_1, dir_1, dir_2, page_6] }
let(:expected_grouped_entries) { [dir_1_1, page_1, dir_1, page_dir_2, dir_2, page_6] }
it 'returns an array with pages and directories' do
grouped_entries.each_with_index do |page_or_dir, i|
......@@ -73,7 +75,7 @@ describe WikiPage do
end
it 'returns an array with retained order with directories at the top' do
expected_order = ['dir_1/dir_1_1/page_3', 'dir_1/page_2', 'dir_2/page_4', 'dir_2/page_5', 'page_1', 'page_6']
expected_order = ['dir_1/dir_1_1/page_3', 'dir_1/page_2', 'dir_2', 'dir_2/page_4', 'dir_2/page_5', 'page_1', 'page_6']
grouped_entries = described_class.group_by_directory(wiki.pages)
......
......@@ -58,7 +58,7 @@ describe Clusters::Applications::InstallService do
let(:error) { StandardError.new('something bad happened') }
before do
expect(application).to receive(:make_installing!).once.and_raise(error)
expect(helm_client).to receive(:install).with(install_command).and_raise(error)
end
include_examples 'logs kubernetes errors' do
......@@ -68,12 +68,10 @@ describe Clusters::Applications::InstallService do
end
it 'make the application errored' do
expect(helm_client).not_to receive(:install)
service.execute
expect(application).to be_errored
expect(application.status_reason).to eq("Can't start installation process.")
expect(application.status_reason).to eq('Failed to install.')
end
end
end
......
......@@ -66,16 +66,14 @@ describe Clusters::Applications::PatchService do
end
before do
expect(application).to receive(:make_updating!).once.and_raise(error)
expect(helm_client).to receive(:update).with(update_command).and_raise(error)
end
it 'make the application errored' do
expect(helm_client).not_to receive(:update)
service.execute
expect(application).to be_update_errored
expect(application.status_reason).to eq("Can't start update process.")
expect(application.status_reason).to eq('Failed to update.')
end
end
end
......
......@@ -60,7 +60,7 @@ describe Clusters::Applications::UpgradeService do
let(:error) { StandardError.new('something bad happened') }
before do
expect(application).to receive(:make_updating!).once.and_raise(error)
expect(helm_client).to receive(:update).with(install_command).and_raise(error)
end
include_examples 'logs kubernetes errors' do
......@@ -70,12 +70,10 @@ describe Clusters::Applications::UpgradeService do
end
it 'make the application errored' do
expect(helm_client).not_to receive(:update)
service.execute
expect(application).to be_update_errored
expect(application.status_reason).to eq("Can't start upgrade process.")
expect(application.status_reason).to eq('Failed to upgrade.')
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