Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0715b53b
Commit
0715b53b
authored
Apr 12, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
b2d21327
c61fd077
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
35 deletions
+50
-35
app/models/wiki_page.rb
app/models/wiki_page.rb
+3
-1
app/services/clusters/applications/install_service.rb
app/services/clusters/applications/install_service.rb
+8
-1
app/services/clusters/applications/patch_service.rb
app/services/clusters/applications/patch_service.rb
+8
-2
app/services/clusters/applications/upgrade_service.rb
app/services/clusters/applications/upgrade_service.rb
+20
-16
spec/models/wiki_page_spec.rb
spec/models/wiki_page_spec.rb
+5
-3
spec/services/clusters/applications/install_service_spec.rb
spec/services/clusters/applications/install_service_spec.rb
+2
-4
spec/services/clusters/applications/patch_service_spec.rb
spec/services/clusters/applications/patch_service_spec.rb
+2
-4
spec/services/clusters/applications/upgrade_service_spec.rb
spec/services/clusters/applications/upgrade_service_spec.rb
+2
-4
No files found.
app/models/wiki_page.rb
View file @
0715b53b
...
@@ -31,7 +31,9 @@ class WikiPage
...
@@ -31,7 +31,9 @@ class WikiPage
pages
.
each_with_object
([])
do
|
page
,
grouped_pages
|
pages
.
each_with_object
([])
do
|
page
,
grouped_pages
|
next
grouped_pages
<<
page
unless
page
.
directory
.
present?
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
next
directory
.
pages
<<
page
if
directory
...
...
app/services/clusters/applications/install_service.rb
View file @
0715b53b
...
@@ -7,6 +7,13 @@ module Clusters
...
@@ -7,6 +7,13 @@ module Clusters
return
unless
app
.
scheduled?
return
unless
app
.
scheduled?
app
.
make_installing!
app
.
make_installing!
install
end
private
def
install
log_event
(
:begin_install
)
log_event
(
:begin_install
)
helm_api
.
install
(
install_command
)
helm_api
.
install
(
install_command
)
...
@@ -18,7 +25,7 @@ module Clusters
...
@@ -18,7 +25,7 @@ module Clusters
app
.
make_errored!
(
"Kubernetes error:
#{
e
.
error_code
}
"
)
app
.
make_errored!
(
"Kubernetes error:
#{
e
.
error_code
}
"
)
rescue
StandardError
=>
e
rescue
StandardError
=>
e
log_error
(
e
)
log_error
(
e
)
app
.
make_errored!
(
"Can't start installation process."
)
app
.
make_errored!
(
'Failed to install.'
)
end
end
end
end
end
end
...
...
app/services/clusters/applications/patch_service.rb
View file @
0715b53b
...
@@ -8,6 +8,12 @@ module Clusters
...
@@ -8,6 +8,12 @@ module Clusters
app
.
make_updating!
app
.
make_updating!
patch
end
private
def
patch
log_event
(
:begin_patch
)
log_event
(
:begin_patch
)
helm_api
.
update
(
update_command
)
helm_api
.
update
(
update_command
)
...
@@ -16,10 +22,10 @@ module Clusters
...
@@ -16,10 +22,10 @@ module Clusters
ClusterWaitForAppInstallationWorker
::
INTERVAL
,
app
.
name
,
app
.
id
)
ClusterWaitForAppInstallationWorker
::
INTERVAL
,
app
.
name
,
app
.
id
)
rescue
Kubeclient
::
HttpError
=>
e
rescue
Kubeclient
::
HttpError
=>
e
log_error
(
e
)
log_error
(
e
)
app
.
make_
update_
errored!
(
"Kubernetes error:
#{
e
.
error_code
}
"
)
app
.
make_errored!
(
"Kubernetes error:
#{
e
.
error_code
}
"
)
rescue
StandardError
=>
e
rescue
StandardError
=>
e
log_error
(
e
)
log_error
(
e
)
app
.
make_
update_errored!
(
"Can't start update process."
)
app
.
make_
errored!
(
'Failed to update.'
)
end
end
end
end
end
end
...
...
app/services/clusters/applications/upgrade_service.rb
View file @
0715b53b
...
@@ -6,24 +6,28 @@ module Clusters
...
@@ -6,24 +6,28 @@ module Clusters
def
execute
def
execute
return
unless
app
.
scheduled?
return
unless
app
.
scheduled?
begin
app
.
make_updating!
app
.
make_updating!
log_event
(
:begin_upgrade
)
upgrade
# install_command works with upgrades too
end
# as it basically does `helm upgrade --install`
helm_api
.
update
(
install_command
)
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
)
log_event
(
:schedule_wait_for_upgrade
)
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
::
INTERVAL
,
app
.
name
,
app
.
id
)
ClusterWaitForAppInstallationWorker
::
INTERVAL
,
app
.
name
,
app
.
id
)
rescue
Kubeclient
::
HttpError
=>
e
rescue
Kubeclient
::
HttpError
=>
e
log_error
(
e
)
log_error
(
e
)
app
.
make_update_errored!
(
"Kubernetes error:
#{
e
.
error_code
}
"
)
app
.
make_errored!
(
"Kubernetes error:
#{
e
.
error_code
}
"
)
rescue
StandardError
=>
e
rescue
StandardError
=>
e
log_error
(
e
)
log_error
(
e
)
app
.
make_update_errored!
(
"Can't start upgrade process."
)
app
.
make_errored!
(
'Failed to upgrade.'
)
end
end
end
end
end
end
end
...
...
spec/models/wiki_page_spec.rb
View file @
0715b53b
...
@@ -22,6 +22,7 @@ describe WikiPage do
...
@@ -22,6 +22,7 @@ describe WikiPage do
create_page
(
'dir_1/dir_1_1/page_3'
,
'content'
)
create_page
(
'dir_1/dir_1_1/page_3'
,
'content'
)
create_page
(
'page_1'
,
'content'
)
create_page
(
'page_1'
,
'content'
)
create_page
(
'dir_1/page_2'
,
'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
(
'dir_2/page_5'
,
'content'
)
create_page
(
'page_6'
,
'content'
)
create_page
(
'page_6'
,
'content'
)
create_page
(
'dir_2/page_4'
,
'content'
)
create_page
(
'dir_2/page_4'
,
'content'
)
...
@@ -29,6 +30,7 @@ describe WikiPage do
...
@@ -29,6 +30,7 @@ describe WikiPage do
let
(
:page_1
)
{
wiki
.
find_page
(
'page_1'
)
}
let
(
:page_1
)
{
wiki
.
find_page
(
'page_1'
)
}
let
(
:page_6
)
{
wiki
.
find_page
(
'page_6'
)
}
let
(
:page_6
)
{
wiki
.
find_page
(
'page_6'
)
}
let
(
:page_dir_2
)
{
wiki
.
find_page
(
'dir_2'
)
}
let
(
:dir_1
)
do
let
(
:dir_1
)
do
WikiDirectory
.
new
(
'dir_1'
,
[
wiki
.
find_page
(
'dir_1/page_2'
)])
WikiDirectory
.
new
(
'dir_1'
,
[
wiki
.
find_page
(
'dir_1/page_2'
)])
...
@@ -44,7 +46,7 @@ describe WikiPage do
...
@@ -44,7 +46,7 @@ describe WikiPage do
context
'sort by title'
do
context
'sort by title'
do
let
(
:grouped_entries
)
{
described_class
.
group_by_directory
(
wiki
.
pages
)
}
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
it
'returns an array with pages and directories'
do
grouped_entries
.
each_with_index
do
|
page_or_dir
,
i
|
grouped_entries
.
each_with_index
do
|
page_or_dir
,
i
|
...
@@ -59,7 +61,7 @@ describe WikiPage do
...
@@ -59,7 +61,7 @@ describe WikiPage do
context
'sort by created_at'
do
context
'sort by created_at'
do
let
(
:grouped_entries
)
{
described_class
.
group_by_directory
(
wiki
.
pages
(
sort:
'created_at'
))
}
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
it
'returns an array with pages and directories'
do
grouped_entries
.
each_with_index
do
|
page_or_dir
,
i
|
grouped_entries
.
each_with_index
do
|
page_or_dir
,
i
|
...
@@ -73,7 +75,7 @@ describe WikiPage do
...
@@ -73,7 +75,7 @@ describe WikiPage do
end
end
it
'returns an array with retained order with directories at the top'
do
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
)
grouped_entries
=
described_class
.
group_by_directory
(
wiki
.
pages
)
...
...
spec/services/clusters/applications/install_service_spec.rb
View file @
0715b53b
...
@@ -58,7 +58,7 @@ describe Clusters::Applications::InstallService do
...
@@ -58,7 +58,7 @@ describe Clusters::Applications::InstallService do
let
(
:error
)
{
StandardError
.
new
(
'something bad happened'
)
}
let
(
:error
)
{
StandardError
.
new
(
'something bad happened'
)
}
before
do
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
end
include_examples
'logs kubernetes errors'
do
include_examples
'logs kubernetes errors'
do
...
@@ -68,12 +68,10 @@ describe Clusters::Applications::InstallService do
...
@@ -68,12 +68,10 @@ describe Clusters::Applications::InstallService do
end
end
it
'make the application errored'
do
it
'make the application errored'
do
expect
(
helm_client
).
not_to
receive
(
:install
)
service
.
execute
service
.
execute
expect
(
application
).
to
be_errored
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
end
end
end
...
...
spec/services/clusters/applications/patch_service_spec.rb
View file @
0715b53b
...
@@ -66,16 +66,14 @@ describe Clusters::Applications::PatchService do
...
@@ -66,16 +66,14 @@ describe Clusters::Applications::PatchService do
end
end
before
do
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
end
it
'make the application errored'
do
it
'make the application errored'
do
expect
(
helm_client
).
not_to
receive
(
:update
)
service
.
execute
service
.
execute
expect
(
application
).
to
be_update_errored
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
end
end
end
...
...
spec/services/clusters/applications/upgrade_service_spec.rb
View file @
0715b53b
...
@@ -60,7 +60,7 @@ describe Clusters::Applications::UpgradeService do
...
@@ -60,7 +60,7 @@ describe Clusters::Applications::UpgradeService do
let
(
:error
)
{
StandardError
.
new
(
'something bad happened'
)
}
let
(
:error
)
{
StandardError
.
new
(
'something bad happened'
)
}
before
do
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
end
include_examples
'logs kubernetes errors'
do
include_examples
'logs kubernetes errors'
do
...
@@ -70,12 +70,10 @@ describe Clusters::Applications::UpgradeService do
...
@@ -70,12 +70,10 @@ describe Clusters::Applications::UpgradeService do
end
end
it
'make the application errored'
do
it
'make the application errored'
do
expect
(
helm_client
).
not_to
receive
(
:update
)
service
.
execute
service
.
execute
expect
(
application
).
to
be_update_errored
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
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment