Ignore the registry migration columns from application settings
What does this MR do and why?
The container registry migration has been completed and we are now cleaning them up in #409873 (closed).
This MR is for Item
The application settings are also available via GET /application/settings
. And as suggested in #409873 (comment 1885602341), we should aim for backwards compatibility in terms of API changes as per the guide. So in this MR, we are ignoring the database columns but we are not removing the fields from the API -- we are just returning 0
for numerical fields and ''
for string fields.
MR acceptance checklist
How to set up and validate locally
Below we have two scenarios, (A) on master
and (B) on this branch. In both scenarios, we expect that the migration fields can be fetched and that they will successfully return a value.
For the API, the migration fields are only returned when Gitlab.com
is true
. For us to access the fields locally, we can add a || true
in L520 of app/helpers/application_settings_helper.rb
:
if Gitlab.com? || true
master
- before this MR's changes
A. On - Through the Rails console, we see that the fields are accessible and they return some value (a set one or the defaults):
Gitlab::CurrentSettings.current_application_settings.container_registry_import_max_tags_count
# => 100
Gitlab::CurrentSettings.current_application_settings.container_registry_import_max_retries
# => 3
Gitlab::CurrentSettings.current_application_settings.container_registry_import_start_max_retries
# => 50
Gitlab::CurrentSettings.current_application_settings.container_registry_import_max_step_duration
# => 300
Gitlab::CurrentSettings.current_application_settings.container_registry_pre_import_tags_rate
# => 0.5e0
Gitlab::CurrentSettings.current_application_settings.container_registry_pre_import_timeout
# => 1800
Gitlab::CurrentSettings.current_application_settings.container_registry_import_timeout
# => 600
Gitlab::CurrentSettings.current_application_settings.container_registry_import_target_plan
# => "free"
Gitlab::CurrentSettings.current_application_settings.container_registry_import_created_before
# => Sun, 23 Jan 2022 00:00:00.000000000 UTC +00:00
- When
curl
-ing the application settings API,
curl --header "PRIVATE-TOKEN: glpat--your-access-token-here" "http://gdk.test:3000/api/v4/application/settings"
You can also see the migration-related fields and the same values returned as in the Rails console:
{
...
"container_registry_import_max_tags_count":100,
"container_registry_import_max_retries":3,
"container_registry_import_start_max_retries":50,
"container_registry_import_max_step_duration":300,
"container_registry_pre_import_tags_rate":"0.5",
"container_registry_pre_import_timeout":1800,
"container_registry_import_timeout":600,
"container_registry_import_target_plan":"free",
"container_registry_import_created_before":"2022-01-23T00:00:00.000Z
...
}
B. On this branch - with this MR's changes
Make sure you have if Gitlab.com? || true
as above.
- Through the Rails console, we see that the fields are still accessible and
0
and''
are returned.
Gitlab::CurrentSettings.current_application_settings.container_registry_import_max_tags_count
# => 0
Gitlab::CurrentSettings.current_application_settings.container_registry_import_max_retries
# => 0
Gitlab::CurrentSettings.current_application_settings.container_registry_import_start_max_retries
# => 0
Gitlab::CurrentSettings.current_application_settings.container_registry_import_max_step_duration
# => 0
Gitlab::CurrentSettings.current_application_settings.container_registry_pre_import_tags_rate
# => 0
Gitlab::CurrentSettings.current_application_settings.container_registry_pre_import_timeout
# => 0
Gitlab::CurrentSettings.current_application_settings.container_registry_import_timeout
# => 0
Gitlab::CurrentSettings.current_application_settings.container_registry_import_target_plan
# => ""
Gitlab::CurrentSettings.current_application_settings.container_registry_import_created_before
# => ""
- When
curl
-ing the application settings API,
curl --header "PRIVATE-TOKEN: glpat--your-access-token-here" "http://gdk.test:3000/api/v4/application/settings"
You can also see the migration-related fields returned but with 0
and ''
{...
"container_registry_import_max_tags_count":0,
"container_registry_import_max_retries":0,
"container_registry_import_start_max_retries":0,
"container_registry_import_max_step_duration":0,
"container_registry_pre_import_tags_rate":0,
"container_registry_pre_import_timeout":0,
"container_registry_import_timeout":0,
"container_registry_import_target_plan":"",
"container_registry_import_created_before":"",
...}
Related to #409873 (closed)