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
ece44622
Commit
ece44622
authored
Jul 30, 2020
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature flag resetting ci usage for all namespaces
parent
9c3b16b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
6 deletions
+12
-6
app/models/project_statistics.rb
app/models/project_statistics.rb
+1
-0
ee/app/models/namespace_statistics.rb
ee/app/models/namespace_statistics.rb
+1
-0
ee/app/services/ci/minutes/batch_reset_service.rb
ee/app/services/ci/minutes/batch_reset_service.rb
+6
-6
lib/gitlab/ci/features.rb
lib/gitlab/ci/features.rb
+4
-0
No files found.
app/models/project_statistics.rb
View file @
ece44622
...
@@ -18,6 +18,7 @@ class ProjectStatistics < ApplicationRecord
...
@@ -18,6 +18,7 @@ class ProjectStatistics < ApplicationRecord
scope
:for_project_ids
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
)
}
scope
:for_project_ids
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
)
}
scope
:for_namespaces
,
->
(
namespaces
)
{
where
(
namespace:
namespaces
)
}
scope
:for_namespaces
,
->
(
namespaces
)
{
where
(
namespace:
namespaces
)
}
scope
:with_any_ci_minutes_used
,
->
{
where
.
not
(
shared_runners_seconds:
0
)
}
def
total_repository_size
def
total_repository_size
repository_size
+
lfs_objects_size
repository_size
+
lfs_objects_size
...
...
ee/app/models/namespace_statistics.rb
View file @
ece44622
...
@@ -6,6 +6,7 @@ class NamespaceStatistics < ApplicationRecord
...
@@ -6,6 +6,7 @@ class NamespaceStatistics < ApplicationRecord
validates
:namespace
,
presence:
true
validates
:namespace
,
presence:
true
scope
:for_namespaces
,
->
(
namespaces
)
{
where
(
namespace:
namespaces
)
}
scope
:for_namespaces
,
->
(
namespaces
)
{
where
(
namespace:
namespaces
)
}
scope
:with_any_ci_minutes_used
,
->
{
where
.
not
(
shared_runners_seconds:
0
)
}
def
shared_runners_minutes
(
include_extra:
true
)
def
shared_runners_minutes
(
include_extra:
true
)
minutes
=
shared_runners_seconds
.
to_i
/
60
minutes
=
shared_runners_seconds
.
to_i
/
60
...
...
ee/app/services/ci/minutes/batch_reset_service.rb
View file @
ece44622
...
@@ -80,13 +80,13 @@ module Ci
...
@@ -80,13 +80,13 @@ module Ci
end
end
def
reset_shared_runners_seconds!
(
namespaces
)
def
reset_shared_runners_seconds!
(
namespaces
)
NamespaceStatistics
namespace_relation
=
NamespaceStatistics
.
for_namespaces
(
namespaces
)
.
for_namespaces
(
namespaces
)
namespace_relation
=
namespace_relation
.
with_any_ci_minutes_used
unless
::
Gitlab
::
Ci
::
Features
.
reset_ci_minutes_for_all_namespaces?
.
update_all
(
shared_runners_seconds:
0
,
shared_runners_seconds_last_reset:
Time
.
current
)
namespace_relation
.
update_all
(
shared_runners_seconds:
0
,
shared_runners_seconds_last_reset:
Time
.
current
)
::
ProjectStatistics
project_relation
=
::
ProjectStatistics
.
for_namespaces
(
namespaces
)
.
for_namespaces
(
namespaces
)
project_relation
=
project_relation
.
with_any_ci_minutes_used
unless
::
Gitlab
::
Ci
::
Features
.
reset_ci_minutes_for_all_namespaces?
.
update_all
(
shared_runners_seconds:
0
,
shared_runners_seconds_last_reset:
Time
.
current
)
project_relation
.
update_all
(
shared_runners_seconds:
0
,
shared_runners_seconds_last_reset:
Time
.
current
)
end
end
def
reset_ci_minutes_notifications!
(
namespaces
)
def
reset_ci_minutes_notifications!
(
namespaces
)
...
...
lib/gitlab/ci/features.rb
View file @
ece44622
...
@@ -85,6 +85,10 @@ module Gitlab
...
@@ -85,6 +85,10 @@ module Gitlab
def
self
.
job_entry_matches_all_keys?
def
self
.
job_entry_matches_all_keys?
::
Feature
.
enabled?
(
:ci_job_entry_matches_all_keys
)
::
Feature
.
enabled?
(
:ci_job_entry_matches_all_keys
)
end
end
def
self
.
reset_ci_minutes_for_all_namespaces?
::
Feature
.
enabled?
(
:reset_ci_minutes_for_all_namespaces
,
default_enabled:
false
)
end
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