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
f3ffbc72
Commit
f3ffbc72
authored
Jul 05, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@13-12-stable-ee
parent
e99202ec
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
110 additions
and
15 deletions
+110
-15
app/models/namespace.rb
app/models/namespace.rb
+6
-2
config/feature_flags/development/recursive_approach_for_all_projects.yml
...flags/development/recursive_approach_for_all_projects.yml
+8
-0
lib/gitlab/local_and_remote_storage_migration/base_migrater.rb
...itlab/local_and_remote_storage_migration/base_migrater.rb
+3
-3
spec/lib/gitlab/local_and_remote_storage_migration/artifact_migrater_spec.rb
...al_and_remote_storage_migration/artifact_migrater_spec.rb
+14
-0
spec/lib/gitlab/local_and_remote_storage_migration/pages_deployment_migrater_spec.rb
...emote_storage_migration/pages_deployment_migrater_spec.rb
+14
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+12
-10
spec/support/shared_examples/lib/gitlab/local_and_remote_storage_migration_shared_examples.rb
...lab/local_and_remote_storage_migration_shared_examples.rb
+53
-0
No files found.
app/models/namespace.rb
View file @
f3ffbc72
...
@@ -271,8 +271,12 @@ class Namespace < ApplicationRecord
...
@@ -271,8 +271,12 @@ class Namespace < ApplicationRecord
# Includes projects from this namespace and projects from all subgroups
# Includes projects from this namespace and projects from all subgroups
# that belongs to this namespace
# that belongs to this namespace
def
all_projects
def
all_projects
namespace
=
user?
?
self
:
self_and_descendants
if
Feature
.
enabled?
(
:recursive_approach_for_all_projects
,
default_enabled: :yaml
)
Project
.
where
(
namespace:
namespace
)
namespace
=
user?
?
self
:
self_and_descendants
Project
.
where
(
namespace:
namespace
)
else
Project
.
inside_path
(
full_path
)
end
end
end
# Includes pipelines from this namespace and pipelines from all subgroups
# Includes pipelines from this namespace and pipelines from all subgroups
...
...
config/feature_flags/development/recursive_approach_for_all_projects.yml
0 → 100644
View file @
f3ffbc72
---
name
:
recursive_approach_for_all_projects
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64632
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/334817
milestone
:
'
14.1'
type
:
development
group
:
group::fulfillment
default_enabled
:
true
lib/gitlab/local_and_remote_storage_migration/base_migrater.rb
View file @
f3ffbc72
...
@@ -8,7 +8,7 @@ module Gitlab
...
@@ -8,7 +8,7 @@ module Gitlab
end
end
def
migrate_to_remote_storage
def
migrate_to_remote_storage
logger
.
info
(
'Starting transfer to
remote
storage'
)
logger
.
info
(
'Starting transfer to
object
storage'
)
migrate
(
items_with_files_stored_locally
,
ObjectStorage
::
Store
::
REMOTE
)
migrate
(
items_with_files_stored_locally
,
ObjectStorage
::
Store
::
REMOTE
)
end
end
...
@@ -38,11 +38,11 @@ module Gitlab
...
@@ -38,11 +38,11 @@ module Gitlab
end
end
def
log_success
(
item
,
store
)
def
log_success
(
item
,
store
)
logger
.
info
(
"Transferred
#{
item
.
class
.
name
}
ID
#{
item
.
id
}
of type
#{
item
.
file_type
}
with size
#{
item
.
size
}
to
#{
storage_label
(
store
)
}
storage"
)
logger
.
info
(
"Transferred
#{
item
.
class
.
name
}
ID
#{
item
.
id
}
with size
#{
item
.
size
}
to
#{
storage_label
(
store
)
}
storage"
)
end
end
def
log_error
(
err
,
item
)
def
log_error
(
err
,
item
)
logger
.
warn
(
"Failed to transfer
#{
item
.
class
.
name
}
of type
#{
item
.
file_type
}
and
ID
#{
item
.
id
}
with error:
#{
err
.
message
}
"
)
logger
.
warn
(
"Failed to transfer
#{
item
.
class
.
name
}
ID
#{
item
.
id
}
with error:
#{
err
.
message
}
"
)
end
end
def
storage_label
(
store
)
def
storage_label
(
store
)
...
...
spec/lib/gitlab/local_and_remote_storage_migration/artifact_migrater_spec.rb
0 → 100644
View file @
f3ffbc72
# frozen_string_literal: true
require
'spec_helper'
require
'support/shared_examples/lib/gitlab/local_and_remote_storage_migration_shared_examples'
RSpec
.
describe
Gitlab
::
LocalAndRemoteStorageMigration
::
ArtifactMigrater
do
before
do
stub_artifacts_object_storage
(
enabled:
true
)
end
let!
(
:item
)
{
create
(
:ci_job_artifact
,
:archive
,
file_store:
start_store
)
}
it_behaves_like
'local and remote storage migration'
end
spec/lib/gitlab/local_and_remote_storage_migration/pages_deployment_migrater_spec.rb
0 → 100644
View file @
f3ffbc72
# frozen_string_literal: true
require
'spec_helper'
require
'support/shared_examples/lib/gitlab/local_and_remote_storage_migration_shared_examples'
RSpec
.
describe
Gitlab
::
LocalAndRemoteStorageMigration
::
PagesDeploymentMigrater
do
before
do
stub_pages_object_storage
(
::
Pages
::
DeploymentUploader
,
enabled:
true
)
end
let!
(
:item
)
{
create
(
:pages_deployment
,
file_store:
start_store
)
}
it_behaves_like
'local and remote storage migration'
end
spec/models/namespace_spec.rb
View file @
f3ffbc72
...
@@ -1010,7 +1010,7 @@ RSpec.describe Namespace do
...
@@ -1010,7 +1010,7 @@ RSpec.describe Namespace do
end
end
end
end
describe
'#all_projects'
do
shared_examples
'#all_projects'
do
context
'when namespace is a group'
do
context
'when namespace is a group'
do
let
(
:namespace
)
{
create
(
:group
)
}
let
(
:namespace
)
{
create
(
:group
)
}
let
(
:child
)
{
create
(
:group
,
parent:
namespace
)
}
let
(
:child
)
{
create
(
:group
,
parent:
namespace
)
}
...
@@ -1019,12 +1019,6 @@ RSpec.describe Namespace do
...
@@ -1019,12 +1019,6 @@ RSpec.describe Namespace do
it
{
expect
(
namespace
.
all_projects
.
to_a
).
to
match_array
([
project2
,
project1
])
}
it
{
expect
(
namespace
.
all_projects
.
to_a
).
to
match_array
([
project2
,
project1
])
}
it
{
expect
(
child
.
all_projects
.
to_a
).
to
match_array
([
project2
])
}
it
{
expect
(
child
.
all_projects
.
to_a
).
to
match_array
([
project2
])
}
it
'queries for the namespace and its descendants'
do
expect
(
Project
).
to
receive
(
:where
).
with
(
namespace:
[
namespace
,
child
])
namespace
.
all_projects
end
end
end
context
'when namespace is a user namespace'
do
context
'when namespace is a user namespace'
do
...
@@ -1033,12 +1027,20 @@ RSpec.describe Namespace do
...
@@ -1033,12 +1027,20 @@ RSpec.describe Namespace do
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
user_namespace
)
}
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
user_namespace
)
}
it
{
expect
(
user_namespace
.
all_projects
.
to_a
).
to
match_array
([
project
])
}
it
{
expect
(
user_namespace
.
all_projects
.
to_a
).
to
match_array
([
project
])
}
end
end
it
'only queries for the namespace itself'
do
describe
'#all_projects'
do
expect
(
Project
).
to
receive
(
:where
).
with
(
namespace:
user_namespace
)
context
'when recursive approach is enabled'
do
include_examples
'#all_projects'
end
user_namespace
.
all_projects
context
'when recursive approach is disabled'
do
before
do
stub_feature_flags
(
recursive_approach_for_all_projects:
false
)
end
end
include_examples
'#all_projects'
end
end
end
end
...
...
spec/support/shared_examples/lib/gitlab/local_and_remote_storage_migration_shared_examples.rb
0 → 100644
View file @
f3ffbc72
# frozen_string_literal: true
RSpec
.
shared_examples
'local and remote storage migration'
do
let
(
:logger
)
{
Logger
.
new
(
"/dev/null"
)
}
let
(
:migrater
)
{
described_class
.
new
(
logger
)
}
using
RSpec
::
Parameterized
::
TableSyntax
where
(
:start_store
,
:end_store
,
:method
)
do
ObjectStorage
::
Store
::
LOCAL
|
ObjectStorage
::
Store
::
REMOTE
|
:migrate_to_remote_storage
ObjectStorage
::
Store
::
REMOTE
|
ObjectStorage
::
Store
::
REMOTE
|
:migrate_to_remote_storage
# rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
ObjectStorage
::
Store
::
REMOTE
|
ObjectStorage
::
Store
::
LOCAL
|
:migrate_to_local_storage
ObjectStorage
::
Store
::
LOCAL
|
ObjectStorage
::
Store
::
LOCAL
|
:migrate_to_local_storage
# rubocop:disable Lint/BinaryOperatorWithIdenticalOperands
end
with_them
do
let
(
:storage_name
)
{
end_store
==
ObjectStorage
::
Store
::
REMOTE
?
'object'
:
'local'
}
it
'successfully migrates'
do
expect
(
logger
).
to
receive
(
:info
).
with
(
"Starting transfer to
#{
storage_name
}
storage"
)
if
start_store
!=
end_store
expect
(
logger
).
to
receive
(
:info
).
with
(
"Transferred
#{
item
.
class
.
name
}
ID
#{
item
.
id
}
with size
#{
item
.
size
}
to
#{
storage_name
}
storage"
)
end
expect
(
item
.
file_store
).
to
eq
(
start_store
)
migrater
.
send
(
method
)
expect
(
item
.
reload
.
file_store
).
to
eq
(
end_store
)
end
end
context
'when migration fails'
do
let
(
:start_store
)
{
ObjectStorage
::
Store
::
LOCAL
}
it
'prints error'
do
expect_next_instance_of
(
item
.
file
.
class
)
do
|
file
|
expect
(
file
).
to
receive
(
:migrate!
).
and_raise
(
"error message"
)
end
expect
(
logger
).
to
receive
(
:info
).
with
(
"Starting transfer to object storage"
)
expect
(
logger
).
to
receive
(
:warn
).
with
(
"Failed to transfer
#{
item
.
class
.
name
}
ID
#{
item
.
id
}
with error: error message"
)
expect
(
item
.
file_store
).
to
eq
(
start_store
)
migrater
.
migrate_to_remote_storage
expect
(
item
.
reload
.
file_store
).
to
eq
(
start_store
)
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