Commit Graph

85 Commits

Author SHA1 Message Date
Stan Hu 855b238361 Simplify setting of in_memory_application_settings 2018-09-10 15:04:27 -07:00
Rémy Coutable 3bf1cd5780
Ensure in-memory application settings are cleared before each test
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-09-10 11:48:09 +02:00
Lin Jen-Shin 4ee08b77bc Updates from `rubocop -a` 2018-07-09 21:13:08 +08:00
Rémy Coutable 6afe6fa6bc
Make Gitlab::CurrentSettings.current_application_settings return cached settings early if they exist without issuing any DB query
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-06-07 17:23:49 +02:00
Stan Hu 1bcdd25ce2
Avoid sequential scans loading schema_migrations table when loading application settings
This was causing significant performance problems in production, and this commit
reverts to the original behavior.
2018-06-07 17:23:49 +02:00
Rémy Coutable 2bdf6edefa
Simplify Gitlab::CurrentSettings now that the logic is in CacheableAttributes
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-05-23 16:14:43 +02:00
Stan Hu 272783be20 Cache table_exists?('application_settings') to reduce repeated schema reloads
Closes #43355
2018-03-15 13:13:00 -07:00
Mario de la Ossa eaada9d706 use Gitlab::UserSettings directly as a singleton instead of including/extending it 2018-02-02 18:39:55 +00:00
Lin Jen-Shin 07d3d44775 Move ModuleWithInstanceVariables to Gitlab namespace
And use .rubocop.yml to exclude paths we don't care,
rather than using the cop itself to exclude.
2017-11-22 17:06:57 +08:00
Lin Jen-Shin 9ac0c76b78 Use StrongMemoize and enable/disable cops properly 2017-11-18 01:01:53 +08:00
Lin Jen-Shin 9ae92b8caa Add cop to make sure we don't use ivar in a module 2017-09-18 21:23:45 +08:00
Sean McGivern 5883ce95ef `current_application_settings` belongs on `Gitlab::CurrentSettings`
The initializers including this were doing so at the top level, so every object
loaded after them had a `current_application_settings` method. However, if
someone had rack-attack enabled (which was loaded before these initializers), it
would try to load the API, and fail, because `Gitlab::CurrentSettings` didn't
have that method.

To fix this:

1. Don't include `Gitlab::CurrentSettings` at the top level. We do not need
   `Object.new.current_application_settings` to work.
2. Make `Gitlab::CurrentSettings` explicitly `extend self`, as we already use it
   like that in several places.
3. Change the initializers to use that new form.
2017-08-31 13:38:33 +01:00
Paul Charlton 65eca13f7b Repair Regression caused by - !11573
some changes introduced by 4daa6da540, 26b6e299e1, 17898ce021 were regressed during today's merge conflict resolution of !11573.

This commit serves to reapply those changes.

/cc: @rspeicher @stanhu @mikegreiling
2017-07-11 14:23:51 +08:00
Paul Charlton cb3b4a15e6 Support multiple Redis instances based on queue type 2017-07-11 03:35:47 +00:00
DJ Mountney e643c0db35 Merge branch 'master' into 'catch-redis-address-error'
# Conflicts:
#   lib/gitlab/current_settings.rb
2017-07-10 21:20:52 +00:00
Nick Thomas aeb2869f66 Prevent bad data being added to application settings when Redis is unavailable 2017-07-10 15:40:51 +01:00
DJ Mountney 353af927d2 Add additional error caching for redis when using a tcp address to
connect instead of a socket

This helps with compiling gitlab assets without a redis server (used
during omnibus build)
2017-06-27 21:50:23 -07:00
Stan Hu 03e538b721 Change references from ApplicationSetting to ::ApplicationSetting to make autoload happier
Closes #34047
2017-06-20 23:27:31 -07:00
Stan Hu 575dced5d7 If migrations are pending, make CurrentSettings use existing values and populate missing columns with defaults
master was failing because `ApplicationSetting.create_from_defaults` attempted
to write to a column that did not exist in the database. This occurred in a
`rake db:migrate` task, which was unable to perform the migration that would
have added the missing column in the first place.

In 9.3 RC2, we also had a bug where password sign-ins were disabled because
there were many pending migrations. The problem occurred because
`fake_application_settings` was being returned with an OpenStruct that did not
include the predicate method `signup_enabled?`. As a result, the value would
erroneously return `nil` instead of `true`. This commit uses the values of the
defaults to mimic this behavior.

This commit also refactors some of the logic to be clearer.
2017-06-19 09:54:48 -07:00
Stan Hu 84cfb33fbb Revert "Merge branch 'rs-revert-11842' into 'master'"
This reverts commit ad521bde1b, reversing
changes made to 3a38e5f1ab.
2017-06-19 09:43:01 -07:00
Robert Speicher dbddd69295 Partially revert 1e8dbd46
See https://gitlab.com/gitlab-org/gitlab-ce/issues/33736#note_32561501
2017-06-16 15:13:09 -05:00
Paul Charlton d93352825a redesign caching of application settings 2017-06-06 16:48:10 +00:00
Nick Thomas 23db8409aa Skip loading application settings from the database when migrations are pending
Various Rails initializers (metrics, sentry, etc) are run before migrations,
which can lead to a mismatch between app/models/application_settings.rb and
schema.
2017-06-02 16:02:08 +01:00
Douwe Maan 75f5fa997d Enable Rails/Delegate 2017-02-23 09:32:42 -06:00
Rémy Coutable c446cfcbae Move ApplicationSetting DEFAULTS to `.defaults` instead
This will avoid autoloading issues in the long term.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-27 16:16:55 +01:00
Rémy Coutable 765d57d650
Rescue from ActiveRecord::UnknownAttributeError and fallback to fake settings
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-23 16:58:13 +01:00
Grzegorz Bizon 632c2939bb Revert "Merge branch 'revert-9cac0317' into 'master' "
This reverts commit c20934869f, reversing
changes made to 4b7ec44b91.
2017-01-23 16:35:24 +01:00
Grzegorz Bizon baeaa97ef4 Revert "Merge branch 'dont-persist-application-settings-in-test-env' into 'master'"
This reverts merge request !8573
2017-01-21 22:55:35 +00:00
Stan Hu 8dbac708dc Revert "Merge branch 'backport-fix-load-error' into 'master'"
This reverts merge request !8671
2017-01-21 00:37:04 +00:00
Rémy Coutable aaa986c0d2
Don't define ApplicationSetting defaults in a constant
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-20 20:10:15 +01:00
Rémy Coutable f6cc29ed83 Don't persist ApplicationSetting in test env
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-15 01:07:29 -05:00
Rémy Coutable b038c53073 Move default values to ApplicationSetting::DEFAULTS and use it in CurrentSettings
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-15 01:07:29 -05:00
Horacio Sanson f986b4c4e5 Add support for PlantUML diagrams in Asciidoc.
This MR enables rendering of PlantUML diagrams in Asciidoc documents. To add a
PlantUML diagram all we need is to include a plantuml block like:

```
[plantuml, id="myDiagram", width="100px", height="100px"]
--
bob -> alice : ping
alice -> bob : pong
--
```

The plantuml block is substituted by an HTML img element with *src* pointing to
an external PlantUML server.

This MR also add a PlantUML integration section to the Administrator -> Settings
page to configure the PlantUML rendering service and to enable/disable it.

Closes: #17603
2017-01-12 10:04:52 +00:00
Rémy Coutable 103114e3d7 Rename Gogs to Gitea, DRY the controller and improve views
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-19 17:35:51 +01:00
Kim "BKC" Carlbäcker 5d4531db25 Gogs Importer 2016-12-19 17:35:51 +01:00
Stan Hu 5a65d9d53b Only turn on Sidekiq throttling if application settings exists
If the database has not been migrated properly, the initializer for Sidekiq
will fail to start and cause the whole Rails server to crash. This change
checks the existence for the column and allows Rails to start even
if the setting has not been added as a database column.

Closes #24452
2016-11-12 16:00:21 -08:00
Patricio Cano b95216aaba Allow the Sidekiq queues to throttle and the factor by which to throttle them to be configurable 2016-11-10 11:38:11 -06:00
Patricio Cano 9e2964c15a Allow certain Sidekiq jobs to be throttled 2016-11-10 11:38:10 -06:00
Grzegorz Bizon cee66810f8 Remove use of `USE_DB` environment variable in code 2016-09-23 10:50:46 +02:00
Grzegorz Bizon 52e897dd14 Update `CurrentSettings` class that uses ENV 2016-09-22 17:25:52 +02:00
Z.J. van de Weg 4c8e9a8d27 Remove gitorious 2016-08-25 10:10:10 +01:00
Gokmen Goksel a927a9bf6b Support integration with Koding (online IDE)
Koding: #index: landing page for Koding integration

If enabled it will provide a link to open remote Koding instance url
for now we are also providing the sneak preview video for how
integration works in detail.

Repository: check whether .koding.yml file exists on repository

Projects: landing page: show Run in IDE (Koding) button if repo has stack file

Projects: MR: show Run in IDE Koding button if repo has stack file on active branch

ProjectHelpers: add_koding_stack: stack generator for provided project

With this helper we will auto-generate the required stack template
for a given project. For the feature we can request this base template
from the running Koding instance on integration.

Currently this will provide users to create a t2.nano instance on aws
and it'll automatically configures the instance for basic requirements.

Projects: empty state and landing page provide shortcuts to create stack

projects_helper: use branch on checkout and provide an entry point

This ${var.koding_queryString_branch} will be replaced with the branch
provided in query string which will allow us to use same stack template
for different branches of the same repository.

ref: b8c0e43c4c

projects_helper: provide sha info in query string to use existing vms

With this change we'll be able to query existing vms on Koding side
based on the commit id that they've created.

ref: 1d630fadf3

Integration: Docs: Koding documentation added

Disable /koding route if integration is disabled

Use application settings to enable Koding

Projects_helper: better indentation with strip_heredoc usage

Projects_helper: return koding_url as is if there is no project provided

current_settings: set koding_enabled: false by default

Koding_Controller: to render not_found once integration is disabled

Dashboard_specs: update spec for Koding enabled case

Projects_Helper: make repo dynamic

ref: 4d615242f4

Updated documentation to have right format
2016-08-19 12:10:58 -07:00
Patricio Cano c71e658cca Refactor and rename `restricted_signup_domains` to `domain_whitelist` to better conform to its behavior and newly introduced behavior. 2016-07-18 17:53:43 -05:00
Dravere a0a9494e4e Added setting to set new users by default as external
As requested by the issue #14508 this adds an option in the application
settings to set newly registered users by default as external. The
default setting is set to false to stay backward compatible.
2016-07-07 19:21:18 +02:00
Stan Hu d10642a4b8 Handle case when Redis cache returns an empty setting 2016-06-29 14:28:41 -07:00
Stan Hu c600cf8348 Fix database migrations when Redis is not running
If Redis were not running or USE_DB were set to false, the
application settings retrieval would fail completely. This
change only attempts to use the cache if the system actually
wants to connect to the DB and rescues any failures in talking to
Redis.

Closes #17557
2016-06-29 14:04:59 -07:00
James Lopez 2d4556c5d2 a few changes based on MR feedback 2016-06-17 15:47:00 +02:00
James Lopez e83fc684a5 Merge branches 'feature/project-export-ui-experimental' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export-ui-experimental
# Conflicts:
#	Gemfile.lock
#	app/helpers/todos_helper.rb
#	app/models/todo.rb
#	app/views/projects/edit.html.haml
#	lib/gitlab/import_export/import_service.rb
2016-06-13 14:00:19 +02:00
Sean McGivern 40b6d9064a Allow custom text on 'almost there' page
Add a new application setting, after_sign_up_text. This is text to be
rendered as Markdown and shown on the 'almost there' page after a user
signs up, but before they've confirmed their account.

Tweak the styles for that page so that centered lists look reasonable.
2016-06-08 19:08:53 +01:00
Douwe Maan 4a50e1f051 Merge branch 'current-settings-use-request-store-during-request' 2016-06-01 12:55:00 +02:00