Commit Graph

3696 Commits

Author SHA1 Message Date
Michael Kozono f635277228 Make DeleteConflictingRedirectRoutes no-op
Both the post-deploy and background migration.
2018-01-03 12:23:20 -08:00
Douglas Barbosa Alexandre 08de4746dc Refactoring Gitlab::BareRepositoryImport::Repository 2018-01-03 16:22:00 -02:00
Douglas Barbosa Alexandre 3f5403ab74 Remove unused variable from bare repository importer spec 2018-01-03 16:17:11 -02:00
Douglas Barbosa Alexandre 62ee2ccfcc Refactoring spec for Gitlab::BareRepositoryImport::Repository 2018-01-03 16:13:32 -02:00
Douglas Barbosa Alexandre 58c2f3b579 Fix Repository#processable? to allow .git repos in the root folder 2018-01-03 16:13:32 -02:00
Douglas Barbosa Alexandre 582678b5f5 Import directory tree created with hashed storage using import rake task 2018-01-03 16:13:32 -02:00
Robert Speicher 946a3634bc Merge branch 'sh-optimize-commit-stats' into 'master'
Speed up generation of commit stats by using Rugged native methods

See merge request gitlab-org/gitlab-ce!16186
2018-01-03 17:39:24 +00:00
Robert Speicher f7cb21930a Merge branch 'migrate-fork-repo-to-gitaly' into 'master'
Migrate repo forking to Gitaly

Closes gitaly#825

See merge request gitlab-org/gitlab-ce!16018
2018-01-03 17:35:32 +00:00
Douwe Maan 9a2186d31b Merge branch '41424-gitlab-rake-gitlab-import-repos-schedules-an-import' into 'master'
Resolve "gitlab-rake gitlab:import:repos schedules an import"

Closes #41424

See merge request gitlab-org/gitlab-ce!16115
2018-01-03 16:51:03 +00:00
Jacob Vosmaer 449b59ec69 Better English 2018-01-03 12:54:47 +01:00
Yorick Peterse 78d22fb20d
Use a background migration for issues.closed_at
In a previous attempt (rolled back in
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16021) we tried
to migrate `issues.closed_at` from timestamp to timestamptz using a
regular migration. This has a bad impact on GitLab.com and as such was
rolled back.

This commit re-implements the original migrations using generic
background migrations, allowing us to still migrate the data in a single
release but without a negative impact on availability.

To ensure the database schema is up to date the background migrations
are performed inline in development and test environments. We also make
sure to not migrate that that doesn't need migrating in the first place
or has already been migrated.
2018-01-03 12:28:00 +01:00
Jacob Vosmaer 8cf0ea4469 Handle Gitaly aborted merge due to branch update 2018-01-03 12:02:37 +01:00
Sean McGivern 5e3103678b Merge branch 'jprovazn-search-issues' into 'master'
Skip projects filter on issues search

See merge request gitlab-org/gitlab-ce!16117
2018-01-03 09:21:09 +00:00
Grzegorz Bizon 57906a5322 Merge branch 'gitaly-conflict-resolver' into 'master'
Gitaly conflict resolver

Closes gitaly#813

See merge request gitlab-org/gitlab-ce!15755
2018-01-03 08:39:16 +00:00
James Lopez f2d4b24a94 refactor code to use new import type 2018-01-03 09:10:43 +01:00
Stan Hu 25a868753b Speed up generation of commit stats by using Rugged native methods
The previous implementation iterated across the entire patch set
to determine the number of lines added, deleted, and changed. Rugged
has a native method `Rugged::Diff#stat` that does this already,
which appears to be a little faster and require less RAM than doing
this ourselves.

Improves performance in #41524
2018-01-02 23:48:19 -08:00
Oswaldo Ferreira bf8c20729b Cache merged and closed events data in merge_request_metrics table 2018-01-02 17:45:25 -02:00
Alejandro Rodríguez 65e3a1e9e9 Simplify conflict resolution interface and code
- Add a Gitlab::Git::Conflict::Resolution class to encapsulate
resolution data
- Simplify conflict file collection assembly
2018-01-02 16:22:02 -03:00
Ahmad Sherif 4b5b43383a Migrate repo forking to Gitaly
Closes gitaly#825
2018-01-02 17:20:01 +01:00
Douwe Maan 88e7378c8c Merge branch 'bvl-fork-public-project-to-private-namespace' into 'master'
Forking a project to a namespace with lower visibility

Closes #40022

See merge request gitlab-org/gitlab-ce!16050
2018-01-02 15:03:06 +00:00
Jan Provaznik 017c1297cd Skip projects filter on issues search
When searching for issues, an additional subquery
is added which filters only issues in a project. If global context is
used (no project is specified) this query filters all projects user has
access to.

In that case we can skip this filter because filtering only projects
user has access to is added anyway.

The filter is used only if a custom project context is specified

Related to #40540
2018-01-02 12:07:26 +01:00
James Lopez 54f00b7487 fix wiki check 2018-01-02 10:42:18 +01:00
James Lopez 9d0bceb3f0 add extra spec check 2018-01-02 10:42:18 +01:00
James Lopez 02276f7a70 Fix import scheduled on bare repo import 2018-01-02 10:42:18 +01:00
Zeger-Jan van de Weg 59e50e33b3
Reroute batch blobs to single blob RPC
Given the priorities shifted for the Gitaly team, this endpoint does not
get a dedicated endpoint yet. To make it work in a cloud native
environment the request needs to go to Gitaly, not rugged. This is
achieved by rerouting to the generic TreeEntry endpoint.
2018-01-02 10:00:24 +01:00
Grzegorz Bizon a3f2bd8a19 Merge branch 'gitaly-encoding-helpers' into 'master'
Move encoding methods to the more general EncodingHelper

Closes gitaly#847

See merge request gitlab-org/gitlab-ce!16137
2017-12-29 10:25:52 +00:00
Bob Van Landuyt 0618487906 Forking a project to a namespace with lower visibility.
In this case the project will get the minimum between both
visibilities.

If that visibility is restricted, then a lower level will be picked.
2017-12-29 11:15:26 +01:00
Alejandro Rodríguez 11247ac97c Move encoding methods to the more general EncodingHelper 2017-12-28 12:32:33 -03:00
Alejandro Rodríguez 0aa87bbe13 Incorporate ConflictsService.ResolveConflicts Gitaly RPC 2017-12-27 15:14:25 -03:00
Alejandro Rodríguez 351f205c05 Incorporate ConflictsService.ListConflictFiles Gitaly RPC 2017-12-27 15:12:30 -03:00
Ahmad Sherif 13932b0b12 Add support for max_count option to Git::Repository#count_commits 2017-12-27 14:16:24 +01:00
Lin Jen-Shin 8139895b43 Use `Gitlab::Utils::Override` over defined?(super) 2017-12-26 17:18:10 +08:00
Stan Hu b6c711fd38 Disable redirect messages for anonymous clones 2017-12-25 05:33:32 -08:00
Stan Hu a83c41f6c6 Fix Error 500s with anonymous clones for a project that has moved
Closes #41457
2017-12-25 05:28:51 -08:00
Dmitriy Zaporozhets 87bae6d42f Merge branch 'gitaly-remotes' into 'master'
Incorporate Gitaly's RemoteService RPCs

Closes gitaly#852

See merge request gitlab-org/gitlab-ce!16060
2017-12-25 10:43:04 +00:00
Matija Čupić 7b52a3482e
Add cache_index to list of safe Project attributes 2017-12-24 22:35:18 +01:00
Rémy Coutable 6c967c2b5b Merge branch '36782-replace-team-user-role-with-add_role-user-in-specs' into 'master'
Resolve "Replace '.team << [user, role]' with 'add_role(user)' in specs"

Closes #36782

See merge request gitlab-org/gitlab-ce!16069
2017-12-23 14:09:42 +00:00
Alejandro Rodríguez 2694355bb6 Incorporate Gitaly's RemoteService RPCs 2017-12-22 20:30:08 -03:00
Alejandro Rodríguez 7354c9f75d Remove unused method `remote_exists?` 2017-12-22 20:30:07 -03:00
Mayra Cabrera 0d4548026f Extend Cluster Applications to allow installation of Prometheus 2017-12-22 17:23:43 +00:00
blackst0ne 27c95364b5 Replace '.team << [user, role]' with 'add_role(user)' in specs 2017-12-22 19:18:28 +11:00
Yorick Peterse 563a801c6a Merge branch 'jprovazn-search' into 'master'
Skip projects filter on merge requests search

See merge request gitlab-org/gitlab-ce!15955
2017-12-21 17:54:35 +00:00
Douwe Maan 92e15071c1 Merge branch 'pawel/reduce_cardinality_of_prometheus_metrics' into 'master'
Reduce cardinality of some of GitLab's Prometheus metrics and fix observed duration reporting.

Closes #41045

See merge request gitlab-org/gitlab-ce!15881
2017-12-21 15:56:45 +00:00
Jan Provaznik d2f1d585e1 Skip projects filter on merge requests search
When searching for merge requests, an additional subquery
is added which by default filters only merge requests which belong
to source or target project user has permission for.

This filter is not needed because more restrictive filter
which checks if user has permission for target project
is used in the query.

So unless a custom projects filter is used by user, it's possible
to skip the default projects filter and speed up the final query.

Related to #40540
2017-12-21 15:43:14 +01:00
Pawel Chojnacki 040167f072 Use seconds where possible, and convert to milliseconds for Influxdb consumption 2017-12-21 00:39:52 +01:00
Zeger-Jan van de Weg 338f1eaf35
Migrate to Project#empty_repo? 2017-12-20 19:13:11 +01:00
Pawel Chojnacki 3c545133e8 Fix tests and formatting 2017-12-19 17:45:25 +01:00
Valery Sizov 8b13bdbe4d
[CE->EE] Fix spec/lib/gitlab/git/gitlab_projects_spec.rb 2017-12-19 14:54:45 +00:00
Kamil Trzciński 924e00496c Merge branch 'sh-add-schedule-pipeline-run-now' into 'master'
Add button to run scheduled pipeline immediately

Closes #38741

See merge request gitlab-org/gitlab-ce!15700
2017-12-18 13:08:51 +00:00
Robert Speicher b540b98764 Merge branch 'no-ivar-in-modules' into 'master'
Add cop to make sure we don't use ivar in a module

See merge request gitlab-org/gitlab-ce!12800
2017-12-15 19:56:15 +00:00
Robert Speicher 627a96875e Merge branch 'rc/use-factory_bot_rails' into 'master'
Replace factory_girl_rails with factory_bot_rails

See merge request gitlab-org/gitlab-ce!15919
2017-12-15 16:32:34 +00:00
Sean McGivern d39d968ba4 Merge branch 'dm-ldap-email-readonly' into 'master'
Make sure user email is read only when synced with LDAP

Closes #41033

See merge request gitlab-org/gitlab-ce!15915
2017-12-15 12:46:22 +00:00
Douwe Maan 481b8a71f8 Make sure user email is read only when synced with LDAP 2017-12-15 12:48:48 +01:00
Lin Jen-Shin 59ac184fcf Merge remote-tracking branch 'upstream/master' into no-ivar-in-modules
* upstream/master: (671 commits)
  Make rubocop happy
  Use guard clause
  Improve language
  Prettify
  Use temp branch
  Pass info about who started the job and which job triggered it
  Docs: add indexes for monitoring and performance monitoring
  clearer-documentation-on-inline-diffs
  Add docs for commit diff discussion in merge requests
  sorting for tags api
  Clear BatchLoader after each spec to prevent holding onto records longer than necessary
  Include project in BatchLoader key to prevent returning blobs for the wrong project
  moved lfs_blob_ids method into ExtractsPath module
  Converted JS modules into exported modules
  spec fixes
  Bump gitlab-shell version to 5.10.3
  Clear caches before updating MR diffs
  Use new Ruby version 2.4 in GitLab QA images
  moved lfs blob fetch from extractspath file
  Update GitLab QA dependencies
  ...
2017-12-15 17:14:26 +08:00
Nick Thomas 4b785df27b
Import gitlab_projects.rb from gitlab-shell
By importing this Ruby code into gitlab-rails (and gitaly-ruby), we avoid
200ms of startup time for each gitlab_projects subprocess we are eliminating.

By not having a gitlab_projects subprocess between gitlab-rails / sidekiq and
any git subprocesses (e.g. for fork_project, fetch_remote, etc, calls), we can
also manage these git processes more cleanly, and avoid sending SIGKILL to them
2017-12-14 16:00:04 +00:00
Rémy Coutable 4af9d592c5 Replace factory_girl_rails with factory_bot_rails
I've followed the [upgrade guide](https://github.com/thoughtbot/factory_bot/blob/4-9-0-stable/UPGRADE_FROM_FACTORY_GIRL.md) and ran these two commands:

```
grep -e FactoryGirl **/*.rake **/*.rb -s -l | xargs sed -i "" "s|FactoryGirl|FactoryBot|"
grep -e factory_girl **/*.rake **/*.rb -s -l | xargs sed -i "" "s|factory_girl|factory_bot|"
```

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-12-14 15:01:55 +01:00
Sean McGivern 5478fe4288 Merge branch 'dm-dedicated-sidekiq-queues' into 'master'
Use a dedicated queue for each Sidekiq worker

See merge request gitlab-org/gitlab-ce!15882
2017-12-14 10:15:52 +00:00
Robert Speicher 83998c0a33 Merge branch 'pawel/cache_feature_check_for_5_minutes_for_method_call' into 'master'
Cache feature check for 1 minute for MethodCall instrumentation toggle

See merge request gitlab-org/gitlab-ce!15800
2017-12-13 18:46:40 +00:00
Pawel Chojnacki db9e5bf75e fix test case description 2017-12-13 18:43:08 +01:00
Rémy Coutable 4fe92b1de1 Merge branch 'add-tcp-check-rake-task' into 'master'
Add a gitlab:tcp_check rake task

See merge request gitlab-org/gitlab-ce!15759
2017-12-13 17:28:04 +00:00
Nick Thomas ab4fa64308
Add a gitlab:tcp_check rake task
This allows us to avoid relying on telnet / netcat being installed
2017-12-13 15:53:32 +00:00
Douwe Maan 58017e17cc Merge branch 'bvl-backport-migration-spec-changes-to-ce' into 'master'
Create models directly in migration specs

See merge request gitlab-org/gitlab-ce!15874
2017-12-13 14:16:22 +00:00
Stan Hu 4b0465f20d Address review comments with playing pipeline scheduler 2017-12-12 17:12:45 -08:00
Stan Hu 8b939bfab7 Add spec for ActionRateLimiter 2017-12-12 15:07:25 -08:00
Michael Kozono acde0e3f5c Fix spec by avoiding monkeypatching 2017-12-12 14:25:33 -08:00
Robert Speicher 2df1f4a515 Merge branch 'tmlee/gitlab-ce-28004-consider-refactoring-member-view-by-using-presenter' into 'master'
Refactor member view by using presenter

Closes #28004

See merge request gitlab-org/gitlab-ce!15715
2017-12-12 20:57:24 +00:00
Sean McGivern dc28ada006 Merge branch 'zj-memoization-mr-commits' into 'master'
Use memoization for commits on diffs

See merge request gitlab-org/gitlab-ce!15857
2017-12-12 18:29:41 +00:00
Pawel Chojnacki da19ce625b Expire feature flag cache after 1minute 2017-12-12 18:52:08 +01:00
Pawel Chojnacki fd0a516854 use class variables instead of CONSTANTs 2017-12-12 18:38:28 +01:00
Pawel Chojnacki 408208bc2b Use AtomicFixNum to implement CAS isolated cache update.
i.e.
Using compare and swap we update the expires_at value.
The thread that actually is able to update this value will also set
the cache holding method_call enabled state
2017-12-12 18:38:28 +01:00
Pawel Chojnacki 5904b033db Implemente measurement enabled cache using AtomicReference 2017-12-12 18:38:28 +01:00
Pawel Chojnacki b503e6ff42 Implement simple in memory cache that expires after 5 minutes 2017-12-12 18:38:28 +01:00
Pawel Chojnacki 53dc9e83c3 Cache feature check for 5 minutes for MethodCall instrumentation toggle 2017-12-12 18:38:28 +01:00
Rémy Coutable 50d7c356c2
Present member collection at the controller level
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-12-12 18:14:58 +01:00
Pawel Chojnacki a8ebed6016 Make `System.monotonic_time` retun seconds represented by float with microsecond precision 2017-12-12 18:12:49 +01:00
Zeger-Jan van de Weg 428c38a2b1
Fix rubocop offence 2017-12-12 17:40:54 +01:00
Douwe Maan b1849ee2e6 Use a dedicated queue for each worker 2017-12-12 17:36:20 +01:00
Zeger-Jan van de Weg 3ab026b7d6
Use memoization for commits on diffs
The Gitaly CommitService is being hammered by n + 1 calls, mostly when
finding commits. This leads to this gRPC being turned of on production:
https://gitlab.com/gitlab-org/gitaly/issues/514#note_48991378

Hunting down where it came from, most of them were due to
MergeRequest#show. To prove this, I set a script to request the
MergeRequest#show page 50 times. The GDK was being scraped by
Prometheus, where we have metrics on controller#action and their Gitaly
calls performed. On both occations I've restarted the full GDK so all
caches had to be rebuild.

Current master, 806a68a81f, needed 435 requests
After this commit, 154 requests
2017-12-12 16:28:26 +01:00
Sean McGivern 52d9ee6299 Merge branch 'jprovazn-description' into 'master'
Use message body for merge request description

Closes #40968

See merge request gitlab-org/gitlab-ce!15839
2017-12-12 12:51:35 +00:00
Bob Van Landuyt 5ac98f9315 Create models directly in migration specs
Instead of using the factories. Since the factories might be using
columns that aren't available in the schema at version the particular
spec is running in.
2017-12-12 09:44:21 +01:00
Robert Speicher 6930fa3102 Merge branch 'gitaly-mirroring-prep' into 'master'
Gitaly mirroring migration prep

Closes gitaly#816

See merge request gitlab-org/gitlab-ce!15775
2017-12-11 20:50:07 +00:00
Yorick Peterse 3daa733139 Merge branch 'sh-remove-allocation-tracking-influxdb' into 'master'
Remove allocation tracking code from InfluxDB sampler for performance

Closes gitlab-com/infrastructure#3250

See merge request gitlab-org/gitlab-ce!15834
2017-12-11 15:57:17 +00:00
Stan Hu 10f5446c33 Remove RubySampler#sample_objects for performance as well 2017-12-11 06:55:59 -08:00
Jan Provaznik b39b5524f2 Use message body for merge request description
When a merge request is created from email, use message body
as merge request description. If message body is empty then
merge request description is still created from the source
branch commit (if there is only single commit in the merge
request).

If message body is empty and there are multiple commits in
the source branch, then merge request description is left empty.

Closes #40968
2017-12-11 11:46:21 +01:00
Stan Hu f1eaab7bf1 Remove the need for destroy and add a comment in the spec 2017-12-10 23:41:28 -08:00
Stan Hu 86661a3a0b Use build instead of create in importer spec 2017-12-10 23:38:55 -08:00
Stan Hu e1a8e5a509 Remove allocation tracking code from InfluxDB sampler for performance
On GitLab.com, InfluxSampler#sample_objects appears to take 1.2 s or so to
iterate through 1059 objects. This had led to delays of a couple hundred
milliseconds in processing in the main thread. Remove this code since it's not
really being used.

Closes gitlab-com/infrastructure#3250
2017-12-10 21:53:28 -08:00
Stan Hu e8cced8077 Fix failing importer test case on MySQL due to missing trailing slash in root path 2017-12-08 16:48:24 -08:00
Stan Hu 78f7c3c8a2 Fix gitlab:import:repos Rake task moving repositories into the wrong location
If the source import directory were different from the destination directory,
GitLab would first create a blank repository and then erroneously move the
original one into a subdirectory. Adding an import type prevents this the project
from being initialized in the first place. It was accidentally removed in
1f917cbd49.

Closes #40765
2017-12-08 14:56:43 -08:00
Mayra Cabrera 562fb460b8 Allow git pull/push on project redirects 2017-12-08 17:42:43 +00:00
Sean McGivern 1fb49ccd7b Merge branch 'jprovazn-ignore-anchors' into 'master'
Use prefix for TableOfContents filter hrefs

Closes #38473

See merge request gitlab-org/gitlab-ce!15806
2017-12-08 14:20:31 +00:00
Douwe Maan 103269b9a6 Merge branch 'fix/gb/fix-pipeline-build-chain-tag-evaluation' into 'master'
Fix invalid pipeline build chain tag evaluation

Closes #40944

See merge request gitlab-org/gitlab-ce!15805
2017-12-08 14:15:33 +00:00
Jan Provaznik 3e83d9f73a Use prefix for TableOfContents filter hrefs
TableOfContents filter generates hrefs for each header in markdown,
if the header text consists from digits and redacted symbols only,
e.g. "123" or "1.0 then the auto-generated href has the same format
as issue references.

If the generated id contains only digits, then 'anchor-' prefix is
prepended to the id.

Closes #38473
2017-12-08 14:13:18 +01:00
Kamil Trzcinski 99101f9484 Fix Rubocop 2017-12-08 13:00:09 +01:00
Kamil Trzcinski b5f6a5f91f Add Chain::Command specs 2017-12-08 12:01:15 +01:00
Kamil Trzcinski ad3be46b9f Implement and use Gitlab::Ci::Pipeline::Chain::Command 2017-12-08 12:01:15 +01:00
Grzegorz Bizon b30e0e0691 Fix invalid pipeline build chain tag evaluation 2017-12-08 10:50:10 +01:00
Bob Van Landuyt f1ae1e39ce Move the circuitbreaker check out in a separate process
Moving the check out of the general requests, makes sure we don't have
any slowdown in the regular requests.

To keep the process performing this checks small, the check is still
performed inside a unicorn. But that is called from a process running
on the same server.

Because the checks are now done outside normal request, we can have a
simpler failure strategy:

The check is now performed in the background every
`circuitbreaker_check_interval`. Failures are logged in redis. The
failures are reset when the check succeeds. Per check we will try
`circuitbreaker_access_retries` times within
`circuitbreaker_storage_timeout` seconds.

When the number of failures exceeds
`circuitbreaker_failure_count_threshold`, we will block access to the
storage.

After `failure_reset_time` of no checks, we will clear the stored
failures. This could happen when the process that performs the checks
is not running.
2017-12-08 09:11:39 +01:00
Stan Hu eea671a2a6 Merge branch 'jprovazn-testfix2' into 'master'
Clean test path between merge request handler tests

Closes #40900

See merge request gitlab-org/gitlab-ce!15792
2017-12-08 06:30:21 +00:00
Sean McGivern 7838317a14 Merge branch 'fix_39233' into 'master'
fix #39233 - 500 in merge request

Closes #39233

See merge request gitlab-org/gitlab-ce!15774
2017-12-07 20:35:39 +00:00
Jan Provaznik b2e0f609b4 Clean test path between merge request handler tests
create_merge_request_handler_spec needs a repository for some tests but
this repository lasts on disk by default which causes failures of other
tests. TestEnv.clean_test_path is used to get rid of the repository
after each test.

Closes #40900
2017-12-07 20:20:41 +01:00
Martin Nowak b7a5125f02 fix #39233 - 500 in merge request
- handle unchanged empty lines in inline diff
2017-12-07 20:19:37 +01:00
Douwe Maan 9dffd0ab6b Merge branch 'dm-commit-diff-discussions-in-mr-context' into 'master'
Allow commenting on individual commits inside an MR

Closes #31847

See merge request gitlab-org/gitlab-ce!12148
2017-12-07 16:49:04 +00:00
Zeger-Jan van de Weg 03ac8d5d0b Remove Rugged::Repository#empty? 2017-12-07 15:33:30 +00:00
micael.bergeron cb6f51ec9b add support for the commit reference filter 2017-12-07 09:01:37 -05:00
Sean McGivern 0054e1567b Merge branch 'ce-backport-3615' into 'master'
Refactor banzai to support referencing from group context

See merge request gitlab-org/gitlab-ce!15766
2017-12-07 12:47:46 +00:00
Stan Hu 29e39e55c3 Merge branch 'mk-add-old-attachments-to-uploads-table' into 'master'
Add old files to uploads table

See merge request gitlab-org/gitlab-ce!15270
2017-12-07 02:34:58 +00:00
Alejandro Rodríguez 885a4da208 Add feature flag to use gitaly-ssh mirroring when cloning internal repos
This also allows us to simplify the naming since we can make some
fetching methods private.
2017-12-06 18:41:45 -03:00
Michael Kozono 24c348f0d1 Fix specs for MySQL 2017-12-06 12:20:28 -08:00
Jarka Kadlecova 0c2fdb1c34 Refactor banzai to support referencing from group context 2017-12-06 19:16:22 +01:00
Michael Kozono 03cba8c0f1 Fix specs after rebase
Later migrations added fields to the EE DB which were used by factories which were used in these specs.

And in CE on MySQL, a single appearance row is enforced.

The migration and migration specs should not depend on the codebase staying the same.
2017-12-06 09:34:25 -08:00
Michael Kozono 869d08b581 Process normal paths in batch containing bad paths 2017-12-05 14:57:58 -08:00
Michael Kozono 77be7efcf5 Guarantee all IDs are included 2017-12-05 11:19:23 -08:00
Robert Speicher 8c77ae2d9e Merge branch 'gitaly-764-commit-filter-shas-with-signature' into 'master'
Migrate Gitlab::Git::Commit.shas_with_signature

Closes gitaly#764

See merge request gitlab-org/gitlab-ce!15621
2017-12-05 18:34:38 +00:00
Brett Walker 02d97d4621 add Gitlab::Database.replication_slots_supported? 2017-12-05 16:43:47 +00:00
Kim "BKC" Carlbäcker 49dd62ada1 Migrate Gitlab::Git::Commit.shas_with_signatures
- Added tests for Git::Commit.shas_with_signatures
2017-12-05 14:43:46 +01:00
Sean McGivern 29be9c1acc Merge branch 'dm-application-worker' into 'master'
Add ApplicationWorker and make every worker include it

See merge request gitlab-org/gitlab-ce!15632
2017-12-05 13:06:22 +00:00
Douwe Maan 1e6ca3c41e Consistently schedule Sidekiq jobs 2017-12-05 11:59:39 +01:00
Douwe Maan 0b15570e49 Add ApplicationWorker and make every worker include it 2017-12-05 11:59:39 +01:00
Jan Provaznik 8cce70730c Create merge request from email
* new merge request can be created by sending an email to the specific
email address (similar to creating issues by email)
* for the first iteration, source branch must be specified in the mail
subject, other merge request parameters can not be set yet
* user should enable "Receive notifications about your own activity" in
user settings to receive a notification about created merge request

Part of #32878
2017-12-05 08:41:58 +01:00
Douwe Maan 50eb125282 Merge branch '40711-fix-forking-hashed-projects' into 'master'
Fix the fork project functionality for projects with hashed storage

Closes #40711

See merge request gitlab-org/gitlab-ce!15671
2017-12-04 11:31:15 +00:00
Nick Thomas 327a9898a2
Fix the fork project functionality for projects with hashed storage
Note the dependency on gitlab-shell v5.10.0
2017-12-04 09:42:14 +00:00
Michael Kozono 71d2704418 Add tests for disable_quote option 2017-12-01 15:26:42 -08:00
Michael Kozono dd4b35f864 Fix test for MySQL 2017-12-01 15:26:42 -08:00
Michael Kozono 473ddfb453 Don’t recreate deleted uploads 2017-12-01 15:26:42 -08:00
Michael Kozono 908aacddda Filter existing uploads with one query 2017-12-01 15:26:42 -08:00
Michael Kozono 7549d17f72 Refactor 2017-12-01 15:26:41 -08:00
Michael Kozono 67b58ffdc3 Get rid of tracked field
It makes a debugging slightly easier, but is not necessary, and is a waste of resources.
2017-12-01 15:26:41 -08:00
Michael Kozono edb5cac46c Use bulk inserts 2017-12-01 15:26:41 -08:00
Michael Kozono f5fa398724 Attempt to fix spec in CI 2017-12-01 15:26:41 -08:00
Michael Kozono 87529ce582 Move temp table creation into the prepare job
* Hopefully fixes spec failures in which the table doesn’t exist
* Decouples the background migration from the post-deploy migration, e.g. we could easily run it again even though the table is dropped when finished.
2017-12-01 15:26:41 -08:00
Michael Kozono 7fd2643419 Fix Rubocop offenses 2017-12-01 15:26:41 -08:00
Michael Kozono dd8680a7ae Drop temporary tracking table when finished 2017-12-01 15:26:41 -08:00
Michael Kozono d530085685 Refactor specs 2017-12-01 15:26:41 -08:00
Michael Kozono 3dc0b118ec Store paths relative to CarrierWave.root
So the path on source installs cannot be too long for our column.

And fix the column length test since Route.path is limited to 255 chars, it doesn’t matter how many nested groups there are.
2017-12-01 15:26:41 -08:00
Michael Kozono 1ba4d417fe Clean up after test 2017-12-01 15:26:41 -08:00
Michael Kozono c77a353dca Remove unnecessary clearing
Since duplicate inserts are now ignored.
2017-12-01 15:26:41 -08:00
Michael Kozono 1807bc1646 Reword test 2017-12-01 15:26:41 -08:00
Michael Kozono a210cb6b82 Rename table to untracked_files_for_uploads 2017-12-01 15:26:41 -08:00
Michael Kozono 2ab3031bd3 Refactor, no change in behavior 2017-12-01 15:26:41 -08:00
Michael Kozono ffbaf19fe8 Fix Rubocop offenses 2017-12-01 15:26:41 -08:00
Michael Kozono 13e0ee3735 Test batch processing 2017-12-01 15:26:40 -08:00
Michael Kozono 1bae010b63 Calculate checksums
by copy-pasting in the whole `Upload` class.

Also, fix `Namespace` `model_type` (it should not be `Group`).
2017-12-01 15:26:40 -08:00
Michael Kozono 3a0ad99d59 Add untracked files to uploads 2017-12-01 15:26:40 -08:00
Michael Kozono 8315c66a56 Kick off follow up background migration jobs
To process the unhashed_upload_files table.
2017-12-01 15:26:40 -08:00
Michael Kozono b6ea41d130 Find and store unhashed upload file paths 2017-12-01 15:26:40 -08:00
Michael Kozono ab814e4dd3 Backport `which` from EE 2017-12-01 15:26:40 -08:00
Bob Van Landuyt b72d243872 Keep track of all storage keys in a set
That way we don't need the to scan the entire keyspace to get all
known keys
2017-12-01 17:50:43 +01:00
Kamil Trzciński cadf378f29 Merge branch 'backstage/gb/build-pipeline-in-a-separate-class' into 'master'
Extract class responsible for building a pipeline

Closes #38460

See merge request gitlab-org/gitlab-ce!14762
2017-12-01 12:02:04 +00:00
Rémy Coutable 3e78b5ae8f Merge branch 'sh-fix-root-ref-repository' into 'master'
Gracefully handle case when repository's root ref does not exist

Closes #40615

See merge request gitlab-org/gitlab-ce!15678
2017-12-01 11:02:32 +00:00
Stan Hu 66127221fe Gracefully handle case when repository's root ref does not exist
This was failing regularly with an Error 500 when the API branches endpoint
was used.

Closes #40615
2017-11-30 23:21:44 -08:00
Grzegorz Bizon 5df4ba0a93 Merge branch 'master' into backstage/gb/build-pipeline-in-a-separate-class
* master: (1794 commits)
2017-11-30 12:52:04 +01:00
Grzegorz Bizon feece77132 Merge branch '38668-revert-copied-kubernetesservice-logic' into 'master'
Copy `KubernetesService` logic in `Clusters::Platforms::Kubernetes` to make it interchangeable. And implement a selector.

See merge request gitlab-org/gitlab-ce!15515
2017-11-30 11:01:14 +00:00
haseeb 869877ab26 fix for special charecter in file names 2017-11-30 09:57:58 +00:00
Lin Jen-Shin 85be6d83be Merge remote-tracking branch 'upstream/master' into no-ivar-in-modules
* upstream/master: (170 commits)
  support ordering of project notes in notes api
  Redirect to an already forked project if it exists
  Reschedule the migration to populate fork networks
  Create fork networks for forks for which the source was deleted.
  Fix item name and namespace text overflow in Projects dropdown
  Minor backport from EE
  fix link that was linking to `html` instead of `md`
  Backport epic tasklist
  Add timeouts for Gitaly calls
  SSHUploadPack over Gitaly is now OptOut
  fix icon colors in commit list
  Fix star icon color/stroke
  Backport border inline edit
  Add checkboxes to automatically run AutoDevops pipeline
  BE for automatic pipeline when enabling Auto DevOps
  I am certainly weary of debugging sidekiq but I don't think that's what was meant
  Ensure MRs always use branch refs for comparison
  Fix issue comment submit button disabled on GFM paste
  Lock seed-fu at the correct version in Gemfile.lock
  Improve indexes on merge_request_diffs
  ...
2017-11-30 15:20:00 +08:00
Yorick Peterse 124fa93a8a Merge branch 'remove-mr-diff-serialised-columns' into 'master'
Remove serialised diff and commit columns

Closes #39533

See merge request gitlab-org/gitlab-ce!15582
2017-11-29 13:33:06 +00:00
Bob Van Landuyt 4c4109e1b9 Create fork networks for forks for which the source was deleted.
That way we can join forks-of-forks into the same network even if
their original source was deleted.

Consider the following:

  `awesome-oss/badger` is forked to `coolstuff/badger`, which is
  forked to `user-a/badger` which in turn is forked to
  `user-b/badger`.

  When `awesome-oss/badger` is deleted, we will now create a fork
  network with `coolstuff/badger` as the root. The `user-a/badger`
  and `user-b/badger` projects will be added to the network.
2017-11-29 12:11:48 +01:00
Andrew Newdigate 64e5f996fa Add timeouts for Gitaly calls 2017-11-29 09:12:12 +00:00
Sean McGivern a4f8dddc21 Merge branch 'dm-search-pattern' into 'master'
Use fuzzy search with minimum length of 3 characters where appropriate

Closes #40512

See merge request gitlab-org/gitlab-ce!15592
2017-11-29 09:10:43 +00:00
Sean McGivern 3c6a4d6363 Ensure MRs always use branch refs for comparison
If a merge request was created with a branch name that also matched a tag name,
we'd generate a comparison to or from the tag respectively, rather than the
branch. Merging would still use the branch, of course.

To avoid this, ensure that when we get the branch heads, we prepend the
reference prefix for branches, which will ensure that we generate the correct
comparison.
2017-11-28 17:01:38 +00:00
Sean McGivern 4ebbfe5d3e Remove serialised diff and commit columns
The st_commits and st_diffs columns on merge_request_diffs historically held the
YAML-serialised data for a merge request diff, in a variety of formats.

Since 9.5, these have been migrated in the background to two new tables:
merge_request_diff_commits and merge_request_diff_files. That has the advantage
that we can actually query the data (for instance, to find out how many commits
we've stored), and that it can't be in a variety of formats, but must match the
new schema.

This is the final step of that journey, where we drop those columns and remove
all references to them. This is a breaking change to the importer, because we
can no longer import diffs created in the old format, and we cannot guarantee
the export will be in the new format unless it was generated after this commit.
2017-11-28 16:13:40 +00:00
Shinya Maeda c36d7842da Aling shared_exmaples to "same behavior between KubernetesService and Platform::Kubernetes" 2017-11-28 20:47:59 +09:00
Shinya Maeda 1d7e3ef1a5 Duplicate spec for Platform::Kubernetes with kubernetes_project 2017-11-28 20:47:59 +09:00
Shinya Maeda 45f2d0af41 Add test suit for platform::kubernetes 2017-11-28 20:47:59 +09:00
Douwe Maan d4eea27531 Modify fuzzy_arel_match to search for equality when a term shorter than 3 characters is provided 2017-11-27 11:29:40 +01:00
Douwe Maan b2c5363da1 Rename to_fuzzy_arel to fuzzy_arel_match 2017-11-24 17:28:50 +01:00
Sean McGivern 89c9d2ad6b Merge branch 'dm-fix-registry-with-sudo-token' into 'master'
Fix pulling and pushing using a personal access token with the sudo scope

Closes #40466

See merge request gitlab-org/gitlab-ce!15571
2017-11-24 09:09:38 +00:00
Douwe Maan fad4ab7d56 Merge branch 'pawel/update_prometheus_gem_to_well_tested_version' into 'master'
Update Prometheus Gem version and disable Prometheus method call instrumentation by default.

Closes gitlab-ee#4139 and #40457

See merge request gitlab-org/gitlab-ce!15558
2017-11-24 09:01:12 +00:00
Pawel Chojnacki 46cd2d93bb Use feature flag instead of application settigns to control if method calls should be instrumented 2017-11-23 23:39:10 +01:00
Pawel Chojnacki 0051b5fbcc Use only real duration to measure method call performance via Prometheus 2017-11-23 23:33:01 +01:00
Pawel Chojnacki efe4cab92b check method timing threshold when observing method performance 2017-11-23 23:33:01 +01:00
James Lopez fdd7a4cb1b Fix hashed storage for attachments bugs 2017-11-23 17:04:35 +00:00
Sean McGivern dd11f0e053 Merge branch 'dm-cleanup-fetch-and-mirror-methods' into 'master'
Clean up repository fetch and mirror methods

See merge request gitlab-org/gitlab-ce!15424
2017-11-23 17:01:47 +00:00
Douwe Maan 7a1e93d35b Rename fetch_refs to refmap 2017-11-23 16:59:58 +01:00
Douwe Maan 0e6beaf50c Clean up repository fetch and mirror methods 2017-11-23 16:59:50 +01:00
Douwe Maan 453b178093 Fix pulling and pushing using a personal access token with the sudo scope 2017-11-23 16:32:08 +01:00
Douwe Maan dbf97574dc Merge branch '39887-move-identical-check-to-merged-branches' into 'master'
Move identical merged branch check to merged_branch_names

Closes #39887

See merge request gitlab-org/gitlab-ce!15464
2017-11-23 15:16:37 +00:00
Douwe Maan ad70fb7bdc Merge branch 'use-merge-requests-diff-id-column' into 'master'
Use foreign key to get latest MR diff

Closes #37631

See merge request gitlab-org/gitlab-ce!15126
2017-11-23 15:01:30 +00:00
Markus Koller 257fd57134 Allow password authentication to be disabled entirely 2017-11-23 13:16:14 +00:00
Sean McGivern 991bf24ec8 Use latest_merge_request_diff association
Compared to the merge_request_diff association:

1. It's simpler to query. The query uses a foreign key to the
   merge_request_diffs table, so no ordering is necessary.
2. It's faster for preloading. The merge_request_diff association has to load
   every diff for the MRs in the set, then discard all but the most recent for
   each. This association means that Rails can just query for N diffs from N
   MRs.
3. It's more complicated to update. This is a bidirectional foreign key, so we
   need to update two tables when adding a diff record. This also means we need
   to handle this as a special case when importing a GitLab project.

There is some juggling with this association in the merge request model:

* `MergeRequest#latest_merge_request_diff` is _always_ the latest diff.
* `MergeRequest#merge_request_diff` reuses
  `MergeRequest#latest_merge_request_diff` unless:
    * Arguments are passed. These are typically to force-reload the association.
    * It doesn't exist. That means we might be trying to implicitly create a
      diff. This only seems to happen in specs.
    * The association is already loaded. This is important for the reasons
      explained in the comment, which I'll reiterate here: if we a) load a
      non-latest diff, then b) get its `merge_request`, then c) get that MR's
      `merge_request_diff`, we should get the diff we loaded in c), even though
      that's not the latest diff.

Basically, `MergeRequest#merge_request_diff` is the latest diff in most cases,
but not quite all.
2017-11-23 12:14:56 +00:00
Jacob Vosmaer (GitLab) 4cfcc97544 Fix encoding bugs in Gitlab::Git::User 2017-11-23 10:48:57 +00:00
Lin Jen-Shin 5951320075 Make sure repository is restored 2017-11-23 18:26:41 +08:00
Lin Jen-Shin 7df1cb528e Move identical merged branch check to merged_branch_names 2017-11-23 18:26:41 +08:00
Lin Jen-Shin 663593e87e Merge remote-tracking branch 'upstream/master' into no-ivar-in-modules
* upstream/master: (126 commits)
  Update VERSION to 10.3.0-pre
  Update CHANGELOG.md for 10.2.0
  default fill color for SVGs
  ignore hashed repos (for now) when using `rake gitlab:cleanup:repos`
  Use Redis cache for branch existence checks
  Update CONTRIBUTING.md: Link definition of done to criteria
  Use `make install` for Gitaly setups in non-test environments
  FileUploader should check for hashed_storage?(:attachments) to use disk_path
  Set the default gitlab-shell timeout to 3 hours
  Update composite pipelines index to include "id"
  Use arrays in Pipeline#latest_builds_with_artifacts
  Fix blank states using old css
  Skip confirmation user api
  Custom issue tracker
  Revert "check for `read_only?` first before seeing if request is disallowed"
  add `#with_metadata` scope to remove a N+1 from the notes' API
  Fix promoting milestone updating all issuables without milestone
  Batchload blobs for diff generation
  check for `read_only?` first before seeing if request is disallowed
  use `Gitlab::Routing.url_helpers` instead of `Rails.application.routes.url_helpers`
  ...
2017-11-22 17:07:01 +08:00
Lin Jen-Shin 0b6d01ed77 Just define allowed_ids and override it with empty value
if not needed for those sub-classes.
2017-11-22 17:06:57 +08:00
Douwe Maan 6c33981654 Merge branch 'sh-optimize-read-only-check' into 'master'
Optimize read-only middleware so that it does not consume as much CPU

Closes #40185 and gitlab-com/infrastructure#3240

See merge request gitlab-org/gitlab-ce!15504
2017-11-21 16:10:47 +00:00
Zeger-Jan van de Weg f9565e3039
Batchload blobs for diff generation
After installing a new gem, batch-loader, a construct can be used to
queue data to be fetched in bulk. The gem was also introduced in both
gitlab-org/gitlab-ce!14680 and gitlab-org/gitlab-ce!14846, but those mrs
are not merged yet.

For the generation of diffs, both the old blob and the new blob need to
be loaded. This for every file in the diff, too. Now we collect all
these so we do 1 fetch. Three `.allow_n_plus_1_calls` have been removed,
which I expect to be valid, but this needs to be confirmed by a full CI
run.

Possibly closes:
- https://gitlab.com/gitlab-org/gitlab-ce/issues/37445
- https://gitlab.com/gitlab-org/gitlab-ce/issues/37599
- https://gitlab.com/gitlab-org/gitlab-ce/issues/37431
2017-11-21 13:53:26 +01:00
digitalMoksha cba68d338b use `Gitlab::Routing.url_helpers` instead of `Rails.application.routes.url_helpers`
since `Rails.application.routes.url_helpers` creates a new anonymous module every time it's called
2017-11-21 13:29:57 +01:00
Stan Hu 3c52e2f06e Optimize read-only middleware so that it does not consume as much CPU
In !15082, we changed the behavior of the middleware to call
`Rails.application.routes.recognize_path` whenever a new route arrived.
However, this can be a CPU-intensive task because Rails needs to allocate
memory and compile 850+ different regular expressions, which are complicated
in GitLab.

As a short-term fix, we can do a lightweight string match before
we do the heavier comparison.

Closes #40185, gitlab-com/infrastructure#3240
2017-11-20 15:27:52 -08:00
Douwe Maan c043ba67c2 Merge branch '40292-bitbucket-import-hashed-storage' into 'master'
Fix bitbucket wiki import with hashed storage enabled

Closes #40292

See merge request gitlab-org/gitlab-ce!15490
2017-11-20 18:08:36 +00:00
Nick Thomas f2977c63a8
Fix bitbucket wiki import with hashed storage enabled 2017-11-20 16:14:41 +00:00
Douwe Maan 4b78f70fc4 Merge branch 'gitaly-delete-refs' into 'master'
Incorporate Gitaly's RefService.DeleteRefs RPC

Closes gitaly#740

See merge request gitlab-org/gitlab-ce!15460
2017-11-20 15:20:40 +00:00
Douwe Maan bd026b6a28 Merge branch 'bvl-dont-move-projects-using-hashed-storage' into 'master'
Don't move project repository/attachments when using hashed storage

Closes #40289

See merge request gitlab-org/gitlab-ce!15479
2017-11-20 13:48:20 +00:00
Bob Van Landuyt fa39e8a09c Don't move project repository/attachments when using hashed storage
When a project is using hashed storage, the repositories and
attachments wouldn't be saved on disk using the `full_path`. So the
migration would not do anything.

However: best to just skip moving when hashed storage is enabled.
2017-11-20 13:46:53 +01:00
Yorick Peterse 936e9e8950
Clean up schema of the "merge_requests" table
This adds various foreign keys and indexes to the "merge_requests" table
as outlined in https://gitlab.com/gitlab-org/gitlab-ce/issues/31825.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/31825
2017-11-20 12:45:33 +01:00
Douwe Maan 202ab62874 Merge branch 'fix-conflict-highlighting' into 'master'
Fix conflict highlighting

See merge request gitlab-org/gitlab-ce!15463
2017-11-20 10:17:43 +00:00
Rémy Coutable 4f09d099e9 Merge branch '18040-rubocop-line-break-after-guard-clause' into 'master'
Adds Rubocop rule for line break after guard clause

Closes #18040

See merge request gitlab-org/gitlab-ce!15188
2017-11-20 09:22:14 +00:00
Alejandro Rodríguez 3f0c9e9708 Fix Gitlab::Git::Repository#remote_tags using unexisting variable 2017-11-20 09:08:09 +00:00
Alejandro Rodríguez 38730a2d07 Incorporate Gitaly's RefService.DeleteRefs RPC 2017-11-17 18:08:50 -03:00
Sean McGivern 64a9e53bd1 Fix conflict highlighting
Conflicts used to take a `Repository` and pass that to
`Gitlab::Highlight.highlight`, which would call `#gitattribute` on the
repository. Now they use a `Gitlab::Git::Repository`, which didn't have that
method defined - but defining it on `Gitlab::Git::Repository` does make it
available on `Repository` through `method_missing`, so we can do that and both
cases will work.
2017-11-17 17:57:48 +00:00