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
9d10ef96
Commit
9d10ef96
authored
Sep 14, 2021
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Database layer for deprecated API throttle settings
We need to track and set these settings in the DB
parent
75c06be4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
0 deletions
+66
-0
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+6
-0
app/models/application_setting.rb
app/models/application_setting.rb
+4
-0
app/models/application_setting_implementation.rb
app/models/application_setting_implementation.rb
+6
-0
db/migrate/20210914145810_add_throttle_deprecated_api_columns.rb
...ate/20210914145810_add_throttle_deprecated_api_columns.rb
+13
-0
db/schema_migrations/20210914145810
db/schema_migrations/20210914145810
+1
-0
db/structure.sql
db/structure.sql
+6
-0
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+4
-0
spec/services/application_settings/update_service_spec.rb
spec/services/application_settings/update_service_spec.rb
+26
-0
No files found.
app/helpers/application_settings_helper.rb
View file @
9d10ef96
...
...
@@ -333,6 +333,9 @@ module ApplicationSettingsHelper
:throttle_authenticated_files_api_enabled
,
:throttle_authenticated_files_api_period_in_seconds
,
:throttle_authenticated_files_api_requests_per_period
,
:throttle_authenticated_deprecated_api_enabled
,
:throttle_authenticated_deprecated_api_period_in_seconds
,
:throttle_authenticated_deprecated_api_requests_per_period
,
:throttle_unauthenticated_api_enabled
,
:throttle_unauthenticated_api_period_in_seconds
,
:throttle_unauthenticated_api_requests_per_period
,
...
...
@@ -345,6 +348,9 @@ module ApplicationSettingsHelper
:throttle_unauthenticated_files_api_enabled
,
:throttle_unauthenticated_files_api_period_in_seconds
,
:throttle_unauthenticated_files_api_requests_per_period
,
:throttle_unauthenticated_deprecated_api_enabled
,
:throttle_unauthenticated_deprecated_api_period_in_seconds
,
:throttle_unauthenticated_deprecated_api_requests_per_period
,
:throttle_protected_paths_enabled
,
:throttle_protected_paths_period_in_seconds
,
:throttle_protected_paths_requests_per_period
,
...
...
app/models/application_setting.rb
View file @
9d10ef96
...
...
@@ -479,6 +479,8 @@ class ApplicationSetting < ApplicationRecord
validates
:throttle_unauthenticated_packages_api_period_in_seconds
validates
:throttle_unauthenticated_files_api_requests_per_period
validates
:throttle_unauthenticated_files_api_period_in_seconds
validates
:throttle_unauthenticated_deprecated_api_requests_per_period
validates
:throttle_unauthenticated_deprecated_api_period_in_seconds
validates
:throttle_authenticated_api_requests_per_period
validates
:throttle_authenticated_api_period_in_seconds
validates
:throttle_authenticated_git_lfs_requests_per_period
...
...
@@ -489,6 +491,8 @@ class ApplicationSetting < ApplicationRecord
validates
:throttle_authenticated_packages_api_period_in_seconds
validates
:throttle_authenticated_files_api_requests_per_period
validates
:throttle_authenticated_files_api_period_in_seconds
validates
:throttle_authenticated_deprecated_api_requests_per_period
validates
:throttle_authenticated_deprecated_api_period_in_seconds
validates
:throttle_protected_paths_requests_per_period
validates
:throttle_protected_paths_period_in_seconds
end
...
...
app/models/application_setting_implementation.rb
View file @
9d10ef96
...
...
@@ -175,6 +175,9 @@ module ApplicationSettingImplementation
throttle_authenticated_files_api_enabled:
false
,
throttle_authenticated_files_api_period_in_seconds:
15
,
throttle_authenticated_files_api_requests_per_period:
500
,
throttle_authenticated_deprecated_api_enabled:
false
,
throttle_authenticated_deprecated_api_period_in_seconds:
3600
,
throttle_authenticated_deprecated_api_requests_per_period:
3600
,
throttle_incident_management_notification_enabled:
false
,
throttle_incident_management_notification_per_period:
3600
,
throttle_incident_management_notification_period_in_seconds:
3600
,
...
...
@@ -193,6 +196,9 @@ module ApplicationSettingImplementation
throttle_unauthenticated_files_api_enabled:
false
,
throttle_unauthenticated_files_api_period_in_seconds:
15
,
throttle_unauthenticated_files_api_requests_per_period:
125
,
throttle_unauthenticated_deprecated_api_enabled:
false
,
throttle_unauthenticated_deprecated_api_period_in_seconds:
3600
,
throttle_unauthenticated_deprecated_api_requests_per_period:
1800
,
time_tracking_limit_to_hours:
false
,
two_factor_grace_period:
48
,
unique_ips_limit_enabled:
false
,
...
...
db/migrate/20210914145810_add_throttle_deprecated_api_columns.rb
0 → 100644
View file @
9d10ef96
# frozen_string_literal: true
class
AddThrottleDeprecatedApiColumns
<
Gitlab
::
Database
::
Migration
[
1.0
]
def
change
add_column
:application_settings
,
:throttle_unauthenticated_deprecated_api_requests_per_period
,
:integer
,
default:
3600
,
null:
false
add_column
:application_settings
,
:throttle_unauthenticated_deprecated_api_period_in_seconds
,
:integer
,
default:
3600
,
null:
false
add_column
:application_settings
,
:throttle_unauthenticated_deprecated_api_enabled
,
:boolean
,
default:
false
,
null:
false
add_column
:application_settings
,
:throttle_authenticated_deprecated_api_requests_per_period
,
:integer
,
default:
3600
,
null:
false
add_column
:application_settings
,
:throttle_authenticated_deprecated_api_period_in_seconds
,
:integer
,
default:
1800
,
null:
false
add_column
:application_settings
,
:throttle_authenticated_deprecated_api_enabled
,
:boolean
,
default:
false
,
null:
false
end
end
db/schema_migrations/20210914145810
0 → 100644
View file @
9d10ef96
a30acb6d2a3772be29dfefc7d8cda2f2df94002556fa5de85483b7fca245be86
\ No newline at end of file
db/structure.sql
View file @
9d10ef96
...
...
@@ -10338,6 +10338,12 @@ CREATE TABLE application_settings (
sidekiq_job_limiter_compression_threshold_bytes integer DEFAULT 100000 NOT NULL,
sidekiq_job_limiter_limit_bytes integer DEFAULT 0 NOT NULL,
suggest_pipeline_enabled boolean DEFAULT true NOT NULL,
throttle_unauthenticated_deprecated_api_requests_per_period integer DEFAULT 1800 NOT NULL,
throttle_unauthenticated_deprecated_api_period_in_seconds integer DEFAULT 3600 NOT NULL,
throttle_unauthenticated_deprecated_api_enabled boolean DEFAULT false NOT NULL,
throttle_authenticated_deprecated_api_requests_per_period integer DEFAULT 3600 NOT NULL,
throttle_authenticated_deprecated_api_period_in_seconds integer DEFAULT 3600 NOT NULL,
throttle_authenticated_deprecated_api_enabled boolean DEFAULT false NOT NULL,
CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)),
CONSTRAINT app_settings_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)),
CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)),
spec/models/application_setting_spec.rb
View file @
9d10ef96
...
...
@@ -946,6 +946,10 @@ RSpec.describe ApplicationSetting do
throttle_unauthenticated_files_api_period_in_seconds
throttle_authenticated_files_api_requests_per_period
throttle_authenticated_files_api_period_in_seconds
throttle_unauthenticated_deprecated_api_requests_per_period
throttle_unauthenticated_deprecated_api_period_in_seconds
throttle_authenticated_deprecated_api_requests_per_period
throttle_authenticated_deprecated_api_period_in_seconds
throttle_authenticated_git_lfs_requests_per_period
throttle_authenticated_git_lfs_period_in_seconds
]
...
...
spec/services/application_settings/update_service_spec.rb
View file @
9d10ef96
...
...
@@ -413,6 +413,32 @@ RSpec.describe ApplicationSettings::UpdateService do
end
end
context
'when deprecated API rate limits are passed'
do
let
(
:params
)
do
{
throttle_unauthenticated_deprecated_api_enabled:
1
,
throttle_unauthenticated_deprecated_api_period_in_seconds:
500
,
throttle_unauthenticated_deprecated_api_requests_per_period:
20
,
throttle_authenticated_deprecated_api_enabled:
1
,
throttle_authenticated_deprecated_api_period_in_seconds:
600
,
throttle_authenticated_deprecated_api_requests_per_period:
10
}
end
it
'updates deprecated API throttle settings'
do
subject
.
execute
application_settings
.
reload
expect
(
application_settings
.
throttle_unauthenticated_deprecated_api_enabled
).
to
be_truthy
expect
(
application_settings
.
throttle_unauthenticated_deprecated_api_period_in_seconds
).
to
eq
(
500
)
expect
(
application_settings
.
throttle_unauthenticated_deprecated_api_requests_per_period
).
to
eq
(
20
)
expect
(
application_settings
.
throttle_authenticated_deprecated_api_enabled
).
to
be_truthy
expect
(
application_settings
.
throttle_authenticated_deprecated_api_period_in_seconds
).
to
eq
(
600
)
expect
(
application_settings
.
throttle_authenticated_deprecated_api_requests_per_period
).
to
eq
(
10
)
end
end
context
'when git lfs rate limits are passed'
do
let
(
:params
)
do
{
...
...
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