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
ac5fe450
Commit
ac5fe450
authored
Dec 21, 2018
by
George Tsiolis
Committed by
Douglas Barbosa Alexandre
Dec 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `ClusterPlatformConfigureWorker`
parent
82772caf
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
101 additions
and
18 deletions
+101
-18
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+1
-1
app/services/clusters/gcp/finalize_creation_service.rb
app/services/clusters/gcp/finalize_creation_service.rb
+1
-1
app/workers/all_queues.yml
app/workers/all_queues.yml
+1
-1
app/workers/cluster_configure_worker.rb
app/workers/cluster_configure_worker.rb
+1
-1
app/workers/cluster_provision_worker.rb
app/workers/cluster_provision_worker.rb
+1
-1
db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb
...9145520_migrate_cluster_configure_worker_sidekiq_queue.rb
+15
-0
db/schema.rb
db/schema.rb
+1
-1
spec/controllers/projects/clusters_controller_spec.rb
spec/controllers/projects/clusters_controller_spec.rb
+2
-2
spec/features/projects/clusters/gcp_spec.rb
spec/features/projects/clusters/gcp_spec.rb
+1
-1
spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb
...ns/migrate_cluster_configure_worker_sidekiq_queue_spec.rb
+68
-0
spec/models/clusters/platforms/kubernetes_spec.rb
spec/models/clusters/platforms/kubernetes_spec.rb
+2
-2
spec/services/clusters/gcp/finalize_creation_service_spec.rb
spec/services/clusters/gcp/finalize_creation_service_spec.rb
+3
-3
spec/services/clusters/update_service_spec.rb
spec/services/clusters/update_service_spec.rb
+1
-1
spec/workers/cluster_configure_worker_spec.rb
spec/workers/cluster_configure_worker_spec.rb
+1
-1
spec/workers/cluster_provision_worker_spec.rb
spec/workers/cluster_provision_worker_spec.rb
+2
-2
No files found.
app/models/clusters/platforms/kubernetes.rb
View file @
ac5fe450
...
@@ -228,7 +228,7 @@ module Clusters
...
@@ -228,7 +228,7 @@ module Clusters
return
unless
namespace_changed?
return
unless
namespace_changed?
run_after_commit
do
run_after_commit
do
Cluster
Platform
ConfigureWorker
.
perform_async
(
cluster_id
)
ClusterConfigureWorker
.
perform_async
(
cluster_id
)
end
end
end
end
end
end
...
...
app/services/clusters/gcp/finalize_creation_service.rb
View file @
ac5fe450
...
@@ -13,7 +13,7 @@ module Clusters
...
@@ -13,7 +13,7 @@ module Clusters
configure_kubernetes
configure_kubernetes
cluster
.
save!
cluster
.
save!
Cluster
Platform
ConfigureWorker
.
perform_async
(
cluster
.
id
)
ClusterConfigureWorker
.
perform_async
(
cluster
.
id
)
rescue
Google
::
Apis
::
ServerError
,
Google
::
Apis
::
ClientError
,
Google
::
Apis
::
AuthorizationError
=>
e
rescue
Google
::
Apis
::
ServerError
,
Google
::
Apis
::
ClientError
,
Google
::
Apis
::
AuthorizationError
=>
e
log_service_error
(
e
.
class
.
name
,
provider
.
id
,
e
.
message
)
log_service_error
(
e
.
class
.
name
,
provider
.
id
,
e
.
message
)
...
...
app/workers/all_queues.yml
View file @
ac5fe450
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
-
gcp_cluster:cluster_wait_for_app_installation
-
gcp_cluster:cluster_wait_for_app_installation
-
gcp_cluster:wait_for_cluster_creation
-
gcp_cluster:wait_for_cluster_creation
-
gcp_cluster:cluster_wait_for_ingress_ip_address
-
gcp_cluster:cluster_wait_for_ingress_ip_address
-
gcp_cluster:cluster_
platform_
configure
-
gcp_cluster:cluster_configure
-
gcp_cluster:cluster_project_configure
-
gcp_cluster:cluster_project_configure
-
github_import_advance_stage
-
github_import_advance_stage
...
...
app/workers/cluster_
platform_
configure_worker.rb
→
app/workers/cluster_configure_worker.rb
View file @
ac5fe450
# frozen_string_literal: true
# frozen_string_literal: true
class
Cluster
Platform
ConfigureWorker
class
ClusterConfigureWorker
include
ApplicationWorker
include
ApplicationWorker
include
ClusterQueue
include
ClusterQueue
...
...
app/workers/cluster_provision_worker.rb
View file @
ac5fe450
...
@@ -10,7 +10,7 @@ class ClusterProvisionWorker
...
@@ -10,7 +10,7 @@ class ClusterProvisionWorker
Clusters
::
Gcp
::
ProvisionService
.
new
.
execute
(
provider
)
if
cluster
.
gcp?
Clusters
::
Gcp
::
ProvisionService
.
new
.
execute
(
provider
)
if
cluster
.
gcp?
end
end
Cluster
Platform
ConfigureWorker
.
perform_async
(
cluster
.
id
)
if
cluster
.
user?
ClusterConfigureWorker
.
perform_async
(
cluster
.
id
)
if
cluster
.
user?
end
end
end
end
end
end
db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb
0 → 100644
View file @
ac5fe450
# frozen_string_literal: true
class
MigrateClusterConfigureWorkerSidekiqQueue
<
ActiveRecord
::
Migration
[
5.0
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
sidekiq_queue_migrate
'gcp_cluster:cluster_platform_configure'
,
to:
'gcp_cluster:cluster_configure'
end
def
down
sidekiq_queue_migrate
'gcp_cluster:cluster_configure'
,
to:
'gcp_cluster:cluster_platform_configure'
end
end
db/schema.rb
View file @
ac5fe450
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2018121
8192239
)
do
ActiveRecord
::
Schema
.
define
(
version:
2018121
9145520
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
...
spec/controllers/projects/clusters_controller_spec.rb
View file @
ac5fe450
...
@@ -311,7 +311,7 @@ describe Projects::ClustersController do
...
@@ -311,7 +311,7 @@ describe Projects::ClustersController do
describe
'security'
do
describe
'security'
do
before
do
before
do
allow
(
Cluster
Platform
ConfigureWorker
).
to
receive
(
:perform_async
)
allow
(
ClusterConfigureWorker
).
to
receive
(
:perform_async
)
stub_kubeclient_get_namespace
(
'https://kubernetes.example.com'
,
namespace:
'my-namespace'
)
stub_kubeclient_get_namespace
(
'https://kubernetes.example.com'
,
namespace:
'my-namespace'
)
end
end
...
@@ -409,7 +409,7 @@ describe Projects::ClustersController do
...
@@ -409,7 +409,7 @@ describe Projects::ClustersController do
end
end
before
do
before
do
allow
(
Cluster
Platform
ConfigureWorker
).
to
receive
(
:perform_async
)
allow
(
ClusterConfigureWorker
).
to
receive
(
:perform_async
)
stub_kubeclient_get_namespace
(
'https://kubernetes.example.com'
,
namespace:
'my-namespace'
)
stub_kubeclient_get_namespace
(
'https://kubernetes.example.com'
,
namespace:
'my-namespace'
)
end
end
...
...
spec/features/projects/clusters/gcp_spec.rb
View file @
ac5fe450
...
@@ -130,7 +130,7 @@ describe 'Gcp Cluster', :js do
...
@@ -130,7 +130,7 @@ describe 'Gcp Cluster', :js do
context
'when user changes cluster parameters'
do
context
'when user changes cluster parameters'
do
before
do
before
do
allow
(
Cluster
Platform
ConfigureWorker
).
to
receive
(
:perform_async
)
allow
(
ClusterConfigureWorker
).
to
receive
(
:perform_async
)
fill_in
'cluster_platform_kubernetes_attributes_namespace'
,
with:
'my-namespace'
fill_in
'cluster_platform_kubernetes_attributes_namespace'
,
with:
'my-namespace'
page
.
within
(
'#js-cluster-details'
)
{
click_button
'Save changes'
}
page
.
within
(
'#js-cluster-details'
)
{
click_button
'Save changes'
}
end
end
...
...
spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb
0 → 100644
View file @
ac5fe450
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb'
)
describe
MigrateClusterConfigureWorkerSidekiqQueue
,
:sidekiq
,
:redis
do
include
Gitlab
::
Database
::
MigrationHelpers
context
'when there are jobs in the queue'
do
it
'correctly migrates queue when migrating up'
do
Sidekiq
::
Testing
.
disable!
do
stubbed_worker
(
queue:
'gcp_cluster:cluster_platform_configure'
).
perform_async
(
'Something'
,
[
1
])
stubbed_worker
(
queue:
'gcp_cluster:cluster_configure'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
expect
(
sidekiq_queue_length
(
'gcp_cluster:cluster_platform_configure'
)).
to
eq
0
expect
(
sidekiq_queue_length
(
'gcp_cluster:cluster_configure'
)).
to
eq
2
end
end
it
'does not affect other queues under the same namespace'
do
Sidekiq
::
Testing
.
disable!
do
stubbed_worker
(
queue:
'gcp_cluster:cluster_install_app'
).
perform_async
(
'Something'
,
[
1
])
stubbed_worker
(
queue:
'gcp_cluster:cluster_provision'
).
perform_async
(
'Something'
,
[
1
])
stubbed_worker
(
queue:
'gcp_cluster:cluster_wait_for_app_installation'
).
perform_async
(
'Something'
,
[
1
])
stubbed_worker
(
queue:
'gcp_cluster:wait_for_cluster_creation'
).
perform_async
(
'Something'
,
[
1
])
stubbed_worker
(
queue:
'gcp_cluster:cluster_wait_for_ingress_ip_address'
).
perform_async
(
'Something'
,
[
1
])
stubbed_worker
(
queue:
'gcp_cluster:cluster_project_configure'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
up
expect
(
sidekiq_queue_length
(
'gcp_cluster:cluster_install_app'
)).
to
eq
1
expect
(
sidekiq_queue_length
(
'gcp_cluster:cluster_provision'
)).
to
eq
1
expect
(
sidekiq_queue_length
(
'gcp_cluster:cluster_wait_for_app_installation'
)).
to
eq
1
expect
(
sidekiq_queue_length
(
'gcp_cluster:wait_for_cluster_creation'
)).
to
eq
1
expect
(
sidekiq_queue_length
(
'gcp_cluster:cluster_wait_for_ingress_ip_address'
)).
to
eq
1
expect
(
sidekiq_queue_length
(
'gcp_cluster:cluster_project_configure'
)).
to
eq
1
end
end
it
'correctly migrates queue when migrating down'
do
Sidekiq
::
Testing
.
disable!
do
stubbed_worker
(
queue:
'gcp_cluster:cluster_configure'
).
perform_async
(
'Something'
,
[
1
])
described_class
.
new
.
down
expect
(
sidekiq_queue_length
(
'gcp_cluster:cluster_platform_configure'
)).
to
eq
1
expect
(
sidekiq_queue_length
(
'gcp_cluster:cluster_configure'
)).
to
eq
0
end
end
end
context
'when there are no jobs in the queues'
do
it
'does not raise error when migrating up'
do
expect
{
described_class
.
new
.
up
}.
not_to
raise_error
end
it
'does not raise error when migrating down'
do
expect
{
described_class
.
new
.
down
}.
not_to
raise_error
end
end
def
stubbed_worker
(
queue
:)
Class
.
new
do
include
Sidekiq
::
Worker
sidekiq_options
queue:
queue
end
end
end
spec/models/clusters/platforms/kubernetes_spec.rb
View file @
ac5fe450
...
@@ -394,7 +394,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -394,7 +394,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context
'when namespace is updated'
do
context
'when namespace is updated'
do
it
'should call ConfigureWorker'
do
it
'should call ConfigureWorker'
do
expect
(
Cluster
Platform
ConfigureWorker
).
to
receive
(
:perform_async
).
with
(
cluster
.
id
).
once
expect
(
ClusterConfigureWorker
).
to
receive
(
:perform_async
).
with
(
cluster
.
id
).
once
platform
.
namespace
=
'new-namespace'
platform
.
namespace
=
'new-namespace'
platform
.
save
platform
.
save
...
@@ -403,7 +403,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -403,7 +403,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
context
'when namespace is not updated'
do
context
'when namespace is not updated'
do
it
'should not call ConfigureWorker'
do
it
'should not call ConfigureWorker'
do
expect
(
Cluster
Platform
ConfigureWorker
).
not_to
receive
(
:perform_async
)
expect
(
ClusterConfigureWorker
).
not_to
receive
(
:perform_async
)
platform
.
username
=
"new-username"
platform
.
username
=
"new-username"
platform
.
save
platform
.
save
...
...
spec/services/clusters/gcp/finalize_creation_service_spec.rb
View file @
ac5fe450
...
@@ -20,7 +20,7 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
...
@@ -20,7 +20,7 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
subject
{
described_class
.
new
.
execute
(
provider
)
}
subject
{
described_class
.
new
.
execute
(
provider
)
}
before
do
before
do
allow
(
Cluster
Platform
ConfigureWorker
).
to
receive
(
:perform_async
)
allow
(
ClusterConfigureWorker
).
to
receive
(
:perform_async
)
end
end
shared_examples
'success'
do
shared_examples
'success'
do
...
@@ -43,8 +43,8 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
...
@@ -43,8 +43,8 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
expect
(
platform
.
token
).
to
eq
(
token
)
expect
(
platform
.
token
).
to
eq
(
token
)
end
end
it
'calls Cluster
Platform
ConfigureWorker in a ascync fashion'
do
it
'calls ClusterConfigureWorker in a ascync fashion'
do
expect
(
Cluster
Platform
ConfigureWorker
).
to
receive
(
:perform_async
).
with
(
cluster
.
id
)
expect
(
ClusterConfigureWorker
).
to
receive
(
:perform_async
).
with
(
cluster
.
id
)
subject
subject
end
end
...
...
spec/services/clusters/update_service_spec.rb
View file @
ac5fe450
...
@@ -37,7 +37,7 @@ describe Clusters::UpdateService do
...
@@ -37,7 +37,7 @@ describe Clusters::UpdateService do
end
end
before
do
before
do
allow
(
Cluster
Platform
ConfigureWorker
).
to
receive
(
:perform_async
)
allow
(
ClusterConfigureWorker
).
to
receive
(
:perform_async
)
stub_kubeclient_get_namespace
(
'https://kubernetes.example.com'
,
namespace:
'my-namespace'
)
stub_kubeclient_get_namespace
(
'https://kubernetes.example.com'
,
namespace:
'my-namespace'
)
end
end
...
...
spec/workers/cluster_
platform_
configure_worker_spec.rb
→
spec/workers/cluster_configure_worker_spec.rb
View file @
ac5fe450
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
'spec_helper'
require
'spec_helper'
describe
Cluster
Platform
ConfigureWorker
,
'#perform'
do
describe
ClusterConfigureWorker
,
'#perform'
do
let
(
:worker
)
{
described_class
.
new
}
let
(
:worker
)
{
described_class
.
new
}
context
'when group cluster'
do
context
'when group cluster'
do
...
...
spec/workers/cluster_provision_worker_spec.rb
View file @
ac5fe450
...
@@ -23,7 +23,7 @@ describe ClusterProvisionWorker do
...
@@ -23,7 +23,7 @@ describe ClusterProvisionWorker do
end
end
it
'configures kubernetes platform'
do
it
'configures kubernetes platform'
do
expect
(
Cluster
Platform
ConfigureWorker
).
to
receive
(
:perform_async
).
with
(
cluster
.
id
)
expect
(
ClusterConfigureWorker
).
to
receive
(
:perform_async
).
with
(
cluster
.
id
)
described_class
.
new
.
perform
(
cluster
.
id
)
described_class
.
new
.
perform
(
cluster
.
id
)
end
end
...
@@ -32,7 +32,7 @@ describe ClusterProvisionWorker do
...
@@ -32,7 +32,7 @@ describe ClusterProvisionWorker do
context
'when cluster does not exist'
do
context
'when cluster does not exist'
do
it
'does not provision a cluster'
do
it
'does not provision a cluster'
do
expect_any_instance_of
(
Clusters
::
Gcp
::
ProvisionService
).
not_to
receive
(
:execute
)
expect_any_instance_of
(
Clusters
::
Gcp
::
ProvisionService
).
not_to
receive
(
:execute
)
expect
(
Cluster
Platform
ConfigureWorker
).
not_to
receive
(
:perform_async
)
expect
(
ClusterConfigureWorker
).
not_to
receive
(
:perform_async
)
described_class
.
new
.
perform
(
123
)
described_class
.
new
.
perform
(
123
)
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