Commit Graph

2338 Commits

Author SHA1 Message Date
Paco Guzman 330de255b7 RailsCache metrics now includes fetch_hit/fetch_miss and read_hit/read_miss info. 2016-07-05 12:28:06 +02:00
Paco Guzman e9a4d117f2 Instrument cache fetch hit and cache fetch misses 2016-07-05 12:28:06 +02:00
Rémy Coutable 06c7d6f3a8 Merge branch 'refactor/ci-config-move-global-entries' into 'master'
Move global ci entries handling from legacy to new config

## What does this MR do?

This MR moves responsibility of handling global CI config entries (like `image`, `services`), from legacy `GitlabCiYamlProcessor` to new CI Config

## Why was this MR needed?

This is the next iteration of CI configuration refactoring

## What are the relevant issue numbers?

#15060

## Does this MR meet the acceptance criteria?

- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)

See merge request !4820
2016-07-05 08:37:16 +00:00
Timothy Andrew eb16e1e3c2 Improve the error message displayed when branch creation fails.
Note: This feature was developed independently on master while this was
in review. I've removed the conflicting bits and left the relevant
additions, mainly a test for `Gitlab::Git::Hook`. The original commit
message follows:

1. `gitlab-shell` outputs errors to `stderr`, but we weren't using this
   information, prior to this commit. Now we capture the `stderr`, and
   display it in the flash message when branch creation fails.

2. This can be used to display better errors for other git operation
   failures with small tweaks.

3. The return value of `Gitlab::Git::Hook#trigger` is changed from a
   simple `true`/`false` to a tuple of `[status, errors]`. All usages
   and tests have been updated to reflect this change.

4. This is only relevant to branch creation _from the Web UI_, since SSH
   and HTTP pushes access `gitlab-shell` either directly or through
   `gitlab-workhorse`.

5. A few minor changes need to be made on the `gitlab-shell` end. Right
   now, the `stderr` message it outputs is prefixed by "GitLab: ", which
   shows up in our flash message. This is better removed.
2016-07-05 11:05:16 +05:30
Dmitriy Zaporozhets fd2b2dc1de Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq 2016-07-04 21:52:43 +03:00
Valery Sizov 926a8ab476 Handle custom Git hook result in GitLab UI 2016-07-04 20:16:55 +03:00
Grzegorz Bizon bfad4c61f1 Add minor improvements in readability in CI config 2016-07-04 18:36:06 +02:00
Valery Sizov bf218337ed Better message for git hooks and file locks 2016-07-04 15:31:49 +03:00
Grzegorz Bizon eb151e77ff Extract CI configuration entry node factory method 2016-07-04 11:29:59 +02:00
Tomasz Maczukin f1a85747ca
Merge branch 'master' into dev-master
* master: (98 commits)
  Enable Style/EmptyLines cop, remove redundant ones
  Update CHANGELOG
  Cache results from jQuery selectors to retrieve namespace name
  Fix import button when import fail due the namespace already been taken
  Fix snippets comments not displayed
  Fix emoji paths in relative root configurations
  Exclude requesters from Project#members, Group#members and User#members
  Upgrade Thin from 1.6.1 to 1.7.0.
  Many squashed commits
  Cache autocomplete results
  Upgrade Sidekiq from 4.1.2 to 4.1.4.
  Upgrade seed-fu from 2.3.5 to 2.3.6
  use has_many relationship with events
  Support creating a todo on issuables via API
  Expose target, filter by state as string
  Add todos API documentation and changelog
  Improve the request / withdraw access button
  Metrics for Rouge::Plugins::Redcarpet and Rouge::Formatters::HTMLGitlab
  Groundwork for Kerberos SPNEGO (EE feature)
  Update CHANGELOG 8.9.5 for runners related fixes
  ...
2016-07-02 22:58:21 +02:00
Grzegorz Bizon 9e211091a8 Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
Stan Hu 88dbc4d110 Merge branch 'fix-relative-root-emoji-support' into 'master'
Fix emoji paths in relative root configurations

## What does this MR do?

If a site specifies a relative URL root, emoji files would omit the path from the URL, leading to lots of 404s.

## Are there points in the code the reviewer needs to double check?

At first, I tried to use `ActionView::Helpers::AssetUrlHelper.asset_url` since this is what it's intended to do. But this helper function is extremely slow, and it took minutes to generate the URLs for the hundreds of links needed for each emoji.

## Why was this MR needed?

Because emojis were broken in relative URL installations

## What are the relevant issue numbers?

#15642

## Does this MR meet the acceptance criteria?

- [X] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [X] Added for this feature/bug
  - [x] All builds are passing
- [X] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [X] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [X] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5027
2016-07-01 16:51:03 +00:00
Stan Hu 4bfe10d5f9 Fix emoji paths in relative root configurations
If a site specifies a relative URL root, emoji files would omit the path from
the URL, leading to lots of 404s.

Closes #15642
2016-07-01 09:10:12 -07:00
James Lopez f29c30475e use has_many relationship with events 2016-07-01 15:34:10 +02:00
James Lopez d6d0a35598 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/import-export-events 2016-07-01 14:52:38 +02:00
Eric K Idema 12aa1f898d Import from Github using Personal Access Tokens.
This stands as an alternative to using OAuth to access a user's Github
repositories.  This is setup in such a way that it can be used without OAuth
configuration.

From a UI perspective, the how to import modal has been replaced by a full
page, which includes a form for posting a personal access token back to the
Import::GithubController.

If the user has logged in via GitHub, skip the Personal Access Token and go
directly to Github for an access token via OAuth.
2016-06-30 18:48:17 +02:00
Douwe Maan 5e6342b7ac Merge branch '19312-confidential-issue' into 'master'
Fix privilege escalation issue with OAuth external users

Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/19312

This MR fixes a privilege escalation issue, where manually set external users would be reverted back to internal users if they logged in via OAuth and that provider was not in the `external_providers` list.

/cc @douwe 

See merge request !1975
2016-06-30 15:42:15 +00:00
James Lopez ef5713546b few more changes from suggestions 2016-06-30 17:22:56 +02:00
Robert Speicher 443d584253 Merge branch 'rubocop/enable-unneeded-capital-w-cop' into 'master'
Enable Style/UnneededCapitalW Rubocop cop

## What does this MR do?

This MR enables Rubocop cop that checks if `%W[]`, which supports interpolation, is needed.

## What are the relevant issue numbers?

#17478 

See merge request !5010
2016-06-30 15:21:53 +00:00
James Lopez 67f59ebd50 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/import-url-validator
# Conflicts:
#	spec/models/project_spec.rb
2016-06-30 14:37:48 +02:00
James Lopez 545b92af06 use class method 2016-06-30 14:30:07 +02:00
Grzegorz Bizon efd70c1878 Enable Style/UnneededCapitalW Rubocop cop 2016-06-30 13:31:52 +02:00
James Lopez 5b893d603d few changes based on feedback 2016-06-30 13:17:37 +02:00
Grzegorz Bizon b4f03e8b1e Improve description of CI types node and in specs 2016-06-30 12:59:17 +02:00
Alejandro Rodríguez 20b9bb2029 Create (if necessary) and link the gitlab-shell secret file on the rake install task 2016-06-29 22:30:33 -04:00
Alejandro Rodríguez 86359ec854 Refactor repository paths handling to allow multiple git mount points 2016-06-29 22:30:31 -04: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
Connor Shea f31f78cea3
Add emoji.rb in lib/gitlab instead of using the gitlab_emoji gem.
No reason to split it into a separate gem when the gem barely did anything. We can use gemojione directly, making updating gemojione that much easier.

Also fix the Rake task and update gemojione to 2.6.1. This adds the EmojiOne Spring update.

Changelog: https://github.com/jonathanwiesel/gemojione/blob/master/CHANGELOG.md
2016-06-29 14:53:09 -06:00
Patricio Cano 10444f61f8 Fixed privilege escalation issue where manually set external users would be reverted back to internal users if they logged in via OAuth and that provider was not in the `external_providers` list. 2016-06-29 10:37:54 -05:00
Grzegorz Bizon 28bafd5354 Enable Style/SpaceAfterComma Rubocop cop 2016-06-29 15:23:44 +02:00
Grzegorz Bizon 7ef11ce3de Explicitly define entry node class in new CI config 2016-06-29 12:20:45 +02:00
Grzegorz Bizon c8c930f3ff Add CI config entry validator for allowed keys 2016-06-29 11:01:26 +02:00
James Lopez 5cd3d7c40a bump version - as old exports wont be compatible 2016-06-29 10:49:31 +02:00
James Lopez 3d2a736679 fixing events for import/export 2016-06-29 10:35:26 +02:00
Grzegorz Bizon b85d4969a9 Return compound value if CI config node is composite 2016-06-29 10:02:02 +02:00
Grzegorz Bizon 7759242ae5 Move global CI cache configuration to new CI classes 2016-06-29 09:49:46 +02:00
Grzegorz Bizon f4421817de Add global cache config entry to new CI config 2016-06-29 09:48:52 +02:00
Grzegorz Bizon 92312786f1 Add CI config entry location info to error message
This CI config entry location in configuration Hash.
2016-06-29 09:17:42 +02:00
Grzegorz Bizon 7c511c2f55 Make it possible to set parent in CI config node 2016-06-29 09:05:14 +02:00
Robert Speicher 5423e6e2d5 Merge branch 'zj-workhorse-format-patch' into 'master'
Workhorse to serve email diffs

See merge request !4590
2016-06-29 02:26:38 +00:00
Z.J. van de Weg db0a6c10ed Bump workhorse version 2016-06-28 22:10:53 +02:00
Yorick Peterse d7b4f36a3c
Use clock_gettime for all performance timestamps
Process.clock_gettime allows getting the real time in nanoseconds as
well as allowing one to get a monotonic timestamp. This offers greater
accuracy without the overhead of having to allocate a Time instance. In
general using Time.now/Time.new is about 2x slower than using
Process.clock_gettime(). For example:

    require 'benchmark/ips'

    Benchmark.ips do |bench|
      bench.report 'Time.now' do
        Time.now.to_f
      end

      bench.report 'clock_gettime' do
        Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
      end

      bench.compare!
    end

Running this benchmark gives:

    Calculating -------------------------------------
                Time.now   108.052k i/100ms
           clock_gettime   125.984k i/100ms
    -------------------------------------------------
                Time.now      2.343M (± 7.1%) i/s -     11.670M
           clock_gettime      4.979M (± 0.8%) i/s -     24.945M

    Comparison:
           clock_gettime:  4979393.8 i/s
                Time.now:  2342986.8 i/s - 2.13x slower

Another benefit of using Process.clock_gettime() is that we can simplify
the code a bit since it can give timestamps in nanoseconds out of the
box.
2016-06-28 17:51:25 +02:00
Paco Guzman b5fa56eb3f Unused got variable with very bad performance
In any case if just want the value which is always ‘gitlab’

require 'benchmark/ips'

Project.first # To load database things
GitlabIssueTrackerService.first # To load database things

Benchmark.ips do |x|
  x.config(:time => 5, :warmup => 2)

  x.report("current") do
    Project.new.default_issue_tracker.to_param
  end

  x.report("") do
    'gitlab'
  end

  x.compare!
end

Calculating -------------------------------------
             current     4.000  i/100ms
                        30.938k i/100ms
-------------------------------------------------
             current     47.298  (±10.6%) i/s -    232.000 
                          4.366M (±20.9%) i/s -     17.202M

Comparison:
                    :  4366456.0 i/s
             current:       47.3 i/s - 92318.26x slower
2016-06-28 17:01:37 +02:00
Grzegorz Bizon 2846f95d2a Merge branch 'master' into refactor/ci-config-move-global-entries
* master: (352 commits)
  Display last commit of deleted branch in push events (!4699)
  add changelog
  add missing attribute to attr_encrypted so it is fully backwards-compatible
  Add "GitLab team members only" to diagram link
  doc: note that .gitattributes uses default branch
  use the conf lexer so we have highlighted comments
  first draft of docs
  support cgi style options, such as erb?parent=json
  move the path alias to a more appropriate location
  make #custom_language private
  appease rubocop
  add an alias for Snippet#path
  appease rubocop
  check the tag so that an instance will pass too
  fix the spec, using project.change_head
  Revert "bump the master sha for gitlab-test!9"
  bump the master sha for gitlab-test!9
  add custom highlighting via .gitattributes
  Rename Licenses API to License Templates API
  Check for conflict with wiki projects when creating a new project.
  ...
2016-06-28 14:38:05 +02:00
Z.J. van de Weg c31f876a27 Workhorse to serve email diffs
Depends on the changes in Workhorse (gitlab-org/gitlab-workhorse!48).
2016-06-28 14:26:38 +02:00
http://jneen.net/ 66b37149eb support cgi style options, such as erb?parent=json 2016-06-27 14:17:49 -07:00
http://jneen.net/ e08ff468e8 make #custom_language private 2016-06-27 14:17:49 -07:00
http://jneen.net/ c8b52761bc appease rubocop 2016-06-27 14:17:49 -07:00
http://jneen.net/ f8b80f7fae add custom highlighting via .gitattributes
paired with @stanhu
2016-06-27 14:17:49 -07:00
James Lopez e69af6d251 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/sidekiq-mem-killer-debug 2016-06-27 17:17:11 +02:00
Grzegorz Bizon c019585cb8 Validate interface only with CI node validator 2016-06-27 14:16:57 +02:00
Grzegorz Bizon 56e88b8c28 Add new ci config entry that handles cache config 2016-06-27 14:01:12 +02:00
James Lopez a7b1b51226 better debugging for memory killer middleware 2016-06-27 12:11:01 +02:00
Rémy Coutable a9dbd394a6 Merge branch 'refactor/ci-config-add-entry-error' into 'master'
Improve validations and error handling in new CI config entries

## What does this MR do?

This MR improves validation in new CI config.

## Why was this MR needed?

With that it will be easier to handle errors during validation and post-processing.

## What are the relevant issue numbers?

This is a continuation of #15060

See merge request !4560
2016-06-27 08:24:17 +00:00
James Lopez 46b89a270f Fix tmp file being deleted after the request plus some cleanup and improved erroring for this situation 2016-06-24 10:50:23 +02:00
Grzegorz Bizon ce4478ed86 Add ci config entry that represents array of paths 2016-06-24 09:54:52 +02:00
Grzegorz Bizon e017e1b629 Add ci config class that represents a boolean value 2016-06-24 09:49:54 +02:00
Grzegorz Bizon 04ece6664a Add ci config class that represents a key value 2016-06-24 08:58:09 +02:00
Rémy Coutable 6f6dcc366b Merge branch 'fix/import-export-gitlab-errors' into 'master'
Fix errors found on importing GitLab CE repo

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/18968

See merge request !4855
2016-06-23 14:13:17 +00:00
Grzegorz Bizon 1f320edb77 Minor refactorings in new CI configuration classes 2016-06-23 13:51:34 +02:00
Grzegorz Bizon 29b96d92c1 Move CI stages configuration to new CI config 2016-06-23 13:51:07 +02:00
Paco Guzman 9101915cb7 Add Sidekiq queue duration to transaction metrics. 2016-06-23 13:09:52 +02:00
James Lopez 8c25399749 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/import-export-gitlab-errors 2016-06-23 10:47:09 +02:00
Grzegorz Bizon 2240807c1a Assume that unspecified CI config is undefined
We assume that when someone adds a key for the configuration entry, but
does not provide a valid value, which causes entry to be `nil`, then
entry should be considered as the undefined one. We also assume this is
semantically correct, this is also backwards compatible with legacy CI
config processor.

See issue #18775 for more details.
2016-06-23 10:22:41 +02:00
Robert Speicher cef021917f Merge branch 'fix_saml_signin' into 'master'
Fix subsequent SAML sign ins

Fixes a bug when `auto_link_ldap_user` is `true` that causes SAML users to be unable to sign in a second time.

Fix the problem for https://gitlab.zendesk.com/agent/tickets/22546

See merge request !4718
2016-06-22 22:12:09 +00:00
Drew Blessing 938f2b9979 Fix subsequent SAML sign ins 2016-06-22 16:10:55 -05:00
Grzegorz Bizon bc2348f2e4 Return default config value when entry is undefined 2016-06-22 14:26:33 +02:00
James Lopez 16ed545e7c fix utc error 2016-06-22 14:12:50 +02:00
Grzegorz Bizon 05ce8a1187 Handle CI environment variables in a new CI config 2016-06-22 11:22:53 +02:00
Grzegorz Bizon 04ecfca386 Rename CI config null node entry to undefined node 2016-06-22 10:44:33 +02:00
Douwe Maan c11006ac6c Merge branch '18755-fix-destroy-project-causes-post_decline_request-to-be-executed' into 'master'
Resolve "Destroying a project causes post_decline_request to be executed"

## What does this MR do?

Ensure we don't send "access request declined" to access requesters when a project is deleted.

## Are there points in the code the reviewer needs to double check?

I've created a service to decouple the notification sending from the AR model.

## Why was this MR needed?

Because there was an issue.

## What are the relevant issue numbers?

Fixes #18755, #18750.

## Does this MR meet the acceptance criteria?

- [x] No CHANGELOG needed.
- [x] Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !4744
2016-06-22 01:15:29 +00:00
Rémy Coutable ed519c161b Merge branch 'ci-lfs-fetch' into 'master'
Allow to fetch LFS from CI

## What does this MR do?

This adds support for fetching LFS object from CI jobs (mostly it's made for supporting GitLab CI).

## What is left?

- [x] Write tests covering a new authorization mechanism

cc @grzesiek @marin

See merge request !4465
2016-06-21 13:05:35 +00:00
Grzegorz Bizon 97ec24f0b0 Return CI entry config as value by default 2016-06-21 13:12:58 +02:00
Grzegorz Bizon d399128955 Handle after script CI config in new classes
This also makes Script to return an array of commands instead of
concatented command, which is our current direction.
2016-06-21 13:02:14 +02:00
Grzegorz Bizon fc00c545b2 Handle CI services config in new CI config classes 2016-06-21 12:40:52 +02:00
Grzegorz Bizon cd6a2afbbb Move CI image configuration entry to new CI config 2016-06-21 12:10:13 +02:00
Grzegorz Bizon 8b550db33e Add image configuration entry to new ci config 2016-06-21 11:47:05 +02:00
Grzegorz Bizon c91298d554 Use generic type validator in new ci configuration 2016-06-21 11:43:32 +02:00
Kamil Trzcinski 6bc22d95b8 Add test coverage to LFS fetching 2016-06-21 11:26:44 +02:00
Kamil Trzcinski 2f545a15c0 Merge remote-tracking branch 'origin/master' into ci-lfs-fetch 2016-06-21 10:11:14 +02:00
Z.J. van de Weg bbfd62bc34 fixup! override content method 2016-06-20 14:48:28 -05:00
Z.J. van de Weg 483dc62eaa Incorporate review 2016-06-20 14:48:28 -05:00
Z.J. van de Weg 8039856d80 Add changelog item, fix rubocop issue 2016-06-20 14:48:28 -05:00
Z.J. van de Weg 620d014aef Implement backend gitlab ci dropdown
This commit builds on the groundwork in
ee008e300b1ec0abcc90e6a30816ec0754cea0dd, which refactored the backend
so the same code could be used for new dropdowns. In this commit its
used for templates for the `.gitlab-ci.yml` files.
2016-06-20 14:48:28 -05:00
ZJ van de Weg 27bf7ae59e Refactor Gitlab::Gitignores 2016-06-20 14:48:28 -05:00
Robert Speicher 160499b525 Merge branch 'limit-email-diff-size' into 'master'
Limit push email diff size

Restrict the size of diffs in push emails to 30 lines / 150 KB (whichever is smaller),
following https://gitlab.com/gitlab-org/gitlab_git/merge_requests/85.

Emails on push can get very large if they contain a lot of files that sneak under the single-file limit.

https://gitlab.com/gitlab-org/gitlab-ee/issues/490

See merge request !4566
2016-06-20 13:26:16 +00:00
Grzegorz Bizon 9510d31b4d Merge branch 'master' into refactor/ci-config-add-entry-error
* master: (345 commits)
  use rails root join
  fixed a couple of errors spotted in production
  Fix RangeError exceptions when referring to issues or merge requests outside of max database values
  Fix bug in `WikiLinkFilter`.
  Small frontend code fixes and restore 8a2d88f commit
  Warn about admin privilege to disable GitHub Webhooks
  Listing GH Webhooks doesn't stop import process for non GH admin users
  fixup! updated docs for api endpoint award emoji
  Update CHANGELOG
  Ensure Todos counters doesn't count Todos for projects pending delete
  Add endpoints for award emoji on notes
  Sort API endpoints and implement feedback
  Add endpoints for Award Emoji
  Fixed issue with assignee dropdown not selecting correctly
  Removed update method Re-structured controller spec Renamed issuable param to issuable_id
  Fix clibpoard buttons on "Check out branch" modal.
  Track method call times/counts as a single metric
  Cache todo counters (pending/done)
  Fix a 'wrong number of arguments' error
  Added missing mount point for Sidekiq Metrics API, after it got lost on rebase.
  ...
2016-06-20 10:38:46 +02:00
James Lopez d5b3a266e8 use rails root join 2016-06-20 09:17:07 +02:00
James Lopez cee2a2dc66 fixed a couple of errors spotted in production 2016-06-20 08:58:43 +02:00
Stan Hu 7c9eba8919 Fix RangeError exceptions when referring to issues or merge requests outside of max database values
When using #XYZ in Markdown text, if XYZ exceeds the maximum value of a signed 32-bit integer, we
get an exception when the Markdown render attempts to run `where(iids: XYZ)`. Introduce a method
that will throw out out-of-bounds values.

Closes #18777
2016-06-18 13:07:38 -07:00
Rémy Coutable 654565c9dc Raise a new Gitlab::Access::AccessDeniedError when permission is not enough to destroy a member
This is a try for a new approach to put the access checks at the service level.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-18 06:06:34 +02:00
Douglas Barbosa Alexandre 7a34c7997b Listing GH Webhooks doesn't stop import process for non GH admin users 2016-06-17 18:17:34 -03:00
Yorick Peterse be3b878443 Track method call times/counts as a single metric
Previously we'd create a separate Metric instance for every method call
that would exceed the method call threshold. This is problematic because
it doesn't provide us with information to accurately get the _total_
execution time of a particular method. For example, if the method
"Foo#bar" was called 4 times with a runtime of ~10 milliseconds we'd end
up with 4 different Metric instances. If we were to then get the
average/95th percentile/etc of the timings this would be roughly 10
milliseconds. However, the _actual_ total time spent in this method
would be around 40 milliseconds.

To solve this problem we now create a single Metric instance per method.
This Metric instance contains the _total_ real/CPU time and the call
count for every instrumented method.
2016-06-17 13:09:55 -04:00
Yorick Peterse ed5f17cc73 Merge branch 'secure-request-uris' into 'master'
Filter out sensitive parameters of metrics data

See merge request !4748
2016-06-17 16:43:14 +00:00
Robert Speicher 8dccfb4a9c Merge branch 'update-column-in-batches-where' into 'master'
Allow customising of queries used for `update_column_in_batches`

This MR makes two changes to `add_column_with_default` and `update_column_in_batches`:

1. `add_column_with_default` no longer wraps the entire set of updates in a single transaction, preventing any locks from sticking around for the duration of the entire transaction
2. `update_column_in_batches` now takes a block which can be used to customise the queries. This uses Arel as messing with raw SQL strings is a total pain

In !4381 there's a need for updating existing rows/columns in a table in batches using a custom `WHERE` condition. Without the changes in this MR this would not be possible.

See merge request !4680
2016-06-17 16:36:22 +00:00
Paco Guzman 2e552c6bf0 Filter out sensitive parameters of metrics data 2016-06-17 18:14:25 +02:00
Yorick Peterse c1e756c242
Fix update_column_in_batches to update all rows
This changes update_column_in_batches to ensure it always updates all
rows now. These changes also allow for an extra SELECT query to be
removed, nor does it use the row count for determining offsets and the
likes; instead it's only used to determine the batch size.
2016-06-17 17:50:38 +02:00
Douwe Maan 9b7fd74805 Merge branch 'feature/project-export' into 'master'
Export project functionality

This is a MR for the export functionality of https://gitlab.com/gitlab-org/gitlab-ce/issues/3050, which adds the ability to export single projects.

- [x] members
- DB data
  - [x] issues
  - [x] issue comments
  - [x] merge requests
  - [x] merge request diff
  - [x] merge request comments
  - [x] labels
  - [x] milestones
  - [x] snippets
  - [x] releases
  - [x] events
  - [x] commit statuses
  - [x] CI builds
- File system data
  - [x] Git repository
  - [x] wiki
  - [x] uploads
  - [ ] ~~CI build traces~~
  - [ ] ~~CI build artifacts~~
  - [ ] ~~LFS objects~~
- DB configuration
  - [x] services
  - [x] web hooks
  - [x] protected branches
  - [x] deploy keys
  - [x] CI variables
  - [x] CI triggers

See merge request !3114
2016-06-17 15:35:27 +00:00
James Lopez 2d4556c5d2 a few changes based on MR feedback 2016-06-17 15:47:00 +02:00
Grzegorz Bizon 44b00a1ebb Extract CI entry config hash validation to validator 2016-06-17 15:02:39 +02:00
Grzegorz Bizon 2a87a55f87 Merge branch 'master' into refactor/ci-config-add-entry-error
* master: (189 commits)
  Update CHANGELOG for !4659
  Center the header logo for all Devise emails
  Add previews for all customized Devise emails
  Customize the Devise `unlock_instructions` email
  Customize the Devise `reset_password_instructions` email
  Customize the Devise `password_change` emails
  Use gitlab-git 10.2.0
  Use Git cached counters on project show page
  Fix indentation scss-lint errors
  Added title attribute to enties in tree view Closes #18353
  Banzai::Filter::ExternalLinkFilter use XPath
  Reduce queries in IssueReferenceFilter
  Use gitlab_git 10.1.4
  Fixed ordering in Project.find_with_namespace
  Fix images in emails
  Banzai::Filter::UploadLinkFilter use XPath
  Turn Group#owners into a has_many association
  Make project_id nullable
  ...
2016-06-17 12:25:43 +02:00
Grzegorz Bizon d9ca84015c Add first custom validator for new ci config
This follows a standard `ActiveModel` pattern of creating a custom
validators. We use `ActiveModel::EachValidator` here that reuses methods
provided by `LegacyValidationHelpers`.

We will remove `LegacyValidationHelpers` on some point in the future, at
the later stages of CI configuration refactoring. It may be possible
to rewrite custom validators to use format like:

`validates :config, array_of: String`
2016-06-17 12:06:48 +02:00
Grzegorz Bizon a9bd16bd0a Rename legacy validation helpers for new ci config 2016-06-17 11:55:55 +02:00
Kamil Trzcinski aef6214c42 Validate only and except regexp
Currently the RegexpError can be raised when processing next stage which leads to 500 in different places of code base.
This adds early check that regexps used in only and except are valid.
2016-06-17 11:52:22 +02:00
Grzegorz Bizon 002e6ed1f0 Improve CI config entries validations prototype 2016-06-17 11:23:16 +02:00
Sean McGivern 1022a1678b Limit push email diff size
Limit push email diff size to 30 files or 150 KB, whichever comes first.
2016-06-17 08:55:05 +01:00
Grzegorz Bizon 95520dfc72 Add prototype of CI config node validator
This makes use of `ActiveModel::Validations` encapsulated in a separate
class that is accessible from a node object.
2016-06-16 15:46:03 +02:00
James Lopez b3a0a1c315 fixed merge conflicts on UI branch 2016-06-16 15:01:27 +02:00
James Lopez 2a747d386d fixed merge conflicts 2016-06-16 14:07:49 +02:00
James Lopez 778d72664f Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export
# Conflicts:
#	app/models/ci/pipeline.rb
2016-06-16 13:04:00 +02:00
James Lopez 452c076a34 Revert "squashed merge and fixed conflicts"
This reverts commit 13e37a3ee5.
2016-06-16 12:59:07 +02:00
James Lopez 13e37a3ee5 squashed merge and fixed conflicts 2016-06-16 12:12:28 +02:00
James Lopez 1b8a107325 fix wiki stuff 2016-06-16 10:59:36 +02:00
James Lopez 5087e10fe9 fix specs 2016-06-16 09:01:09 +02:00
Douwe Maan af493ccf36 Merge branch 'remove-shell-env' into 'master'
Get rid of Gitlab::ShellEnv

Remove obsolete code we once needed for Grack and satellites.

See merge request !4673
2016-06-15 16:41:13 +00:00
James Lopez 4bde59341f lots of refactoring again based on feedback. Changed the UI slightly and also fixed a small bug 2016-06-15 17:31:00 +02:00
Yorick Peterse 816c453558
Don't update columns in batches in a transaction
This ensures that whatever locks are acquired aren't held onto until the
end of the transaction (= after _all_ rows have been updated). Timing
wise there's also no difference between using a transaction and not
using one.
2016-06-15 17:04:07 +02:00
Yorick Peterse 8966263e0c
Customizing of update_column_in_batches queries
By passing a block to update_column_in_batches() one can now customize
the queries executed. This in turn can be used to only update a specific
set of rows instead of simply all the rows in the table.
2016-06-15 16:44:44 +02:00
Rémy Coutable be09845914 Merge branch 'environments-and-deployments' into 'master'
Add environments and deployments

This MR is a continuation of https://gitlab.com/gitlab-org/gitlab-ce/issues/17009.

The current implementation is as follow:
1. We have two new tables: `environments` and `deployments`.
2. We have a new tab: `Environments` under `Pipelines` where you can see all you environments and add a new one.
3. We add a new option to `.gitlab-ci.yml` to track where we should create a deployment for environment.
4. If environment in `.gitlab-ci.yml` is specified it will create a deployment. **If environment does not exist it will be created.** (this got changed)
5. The deployment is always successful and shows the time of the action, in that case a build that presumably should do deployment. In the future we could extend deployment with statuses: success, failure. We could extend deployments with information that this is partial or full deployment.
6. User have to create environments that he will track first.
7. User can remove environments.
8. User can retry/rollback past deployment (in that case we retry past build). The new build when succeeds it will create a new deployment.
9. Currently environment have only one parameter: `name`. In the future it should have: `variables`, `credentials` and possibly `runners` and maybe other resources.
10. Currently deployment have this parameters: `sha`, `ref`, `deployable (in this case a build)`, `user (who triggered a deployment)`, `created_at`.

The `.gitlab-ci.yml`:
```
deploy to production:
  stage: deploy
  script: dpl travis...
  environment: production
```

What needs to be done:
- [x] Write initial implementation
- [x] Improve implementation (@ayufan)
- [x] Write tests (@ayufan)
- [x] Improve UX of the forms (cc @markpundsack) - reviewed by @markpundsack
- [x] Improve implementation of the views (cc @jschatz1) - done by @iamphill 
- [x] Write .gitlab-ci.yml documentation for `environments` - done by @ayufan
- [ ] Write user documentation (@ayufan and @markpundsack)

See merge request !4605
2016-06-15 13:48:09 +00:00
Jacob Vosmaer c32e61251e Get rid of Gitlab::ShellEnv 2016-06-15 14:59:37 +02:00
Grzegorz Bizon 76aea978c6 Add class that encapsulates error in new Ci config 2016-06-15 14:09:21 +02:00
Z.J. van de Weg b2df118561 Random selection now also works for MySQL 2016-06-15 12:10:41 +02:00
James Lopez fc5f6943f8 yay finally importing working with the new services structure 2016-06-14 21:41:40 +02:00
James Lopez ff44198e17 few fixes after refactoring the whole UI stuff 2016-06-14 21:03:14 +02:00
James Lopez b53ed84843 adapted current services stuff to use new project import, plus fixes a few issues, updated routes, etc... 2016-06-14 20:32:19 +02:00
Yorick Peterse ab91f1226f
Filter out classes without names in the sampler
We can't do a lot with classes without names as we can't filter by them,
have no idea where they come from, etc. As such it's best to just ignore
these.
2016-06-14 18:09:06 +02:00
James Lopez 1d4243f5dd Merge branches 'feature/project-export-ui-experimental' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export-ui-experimental 2016-06-14 16:40:13 +02:00
James Lopez 862b359b9a fix merge issue 2016-06-14 16:37:41 +02:00
James Lopez 9ecebaaea1 adding notifications stuff and more refactoring for exporting projects 2016-06-14 16:31:03 +02:00
Yorick Peterse 0ca7b3ba37 Merge branch '18449-instrument-grape-endpoints' into 'master'
Instrument Grape API endpoints

See merge request !4587
2016-06-14 14:29:55 +00:00
Yorick Peterse f558bf0de4 Merge branch '18527-instrument-private-methods' into 'master'
Instrument private methods and instance private methods

See merge request !4639
2016-06-14 14:28:40 +00:00
Kamil Trzcinski 006b650988 Merge remote-tracking branch 'origin/master' into environments-and-deployments
# Conflicts:
#	db/schema.rb
2016-06-14 16:19:29 +02:00
Paco Guzman dadc531353 Instrument private/protected methods
By default instrumentation will instrument public,
protected and private methods, because usually
heavy work is done on private method or at least
that’s what facts is showing
2016-06-14 15:17:51 +02:00
Kamil Trzcinski 975e388751 Merge remote-tracking branch 'origin/master' into environments-and-deployments
# Conflicts:
#	lib/ci/gitlab_ci_yaml_processor.rb
2016-06-14 14:53:10 +02:00
Kamil Trzcinski 3f5819fb7a Merge remote-tracking branch 'origin/master' into artifacts-expire-date 2016-06-14 14:49:59 +02:00
James Lopez fe370b1c39 new export stuff and view 2016-06-14 14:28:30 +02:00
Yorick Peterse 4b964011cf Merge branch '18528-cpu-time-instrumentation' into 'master'
Measure CPU time for instrumented methods

See merge request !4640
2016-06-14 11:39:19 +00:00
Paco Guzman 509082bafb Instrument Grape Endpoint with Metrics::RackMiddleware
Generating the following tags

Grape#GET /projects/:id/archive

from Grape::Route objects like

{ :path => /:version/projects/:id/archive(.:format)
  :version => “v3”,
  :method => “GET” }

Use an instance variable to cache raw_path transformations.
This variable is only going to growth to the number of 
endpoints of the API, not with exact different requests

We can store this cache as an instance variable because 
middleware are initialised only once
2016-06-14 13:06:46 +02:00
Kamil Trzcinski e8f09f02bf Validate environment name with regex 2016-06-14 13:04:21 +02:00
Rémy Coutable 47cdb69921 Merge branch 'refactor/ci-config-add-global-entry' into 'master'
Add global entry with before script to new CI config

## What does this MR do?

This MR adds a new entries to a new CI config class. It is next refactoring step after !4462.

See #15060

See merge request !4482
2016-06-14 10:53:26 +00:00
Paco Guzman 120fbbd487 Measure CPU time for instrumented methods 2016-06-14 12:49:31 +02:00
James Lopez 3f7ed55011 lots of refactoring to reuse import service 2016-06-14 12:47:07 +02:00
Grzegorz Bizon 30e946ce8a Validate ci config entry value before processing nodes 2016-06-14 11:28:20 +02:00
James Lopez 1ea44ee750 Merge branches 'feature/project-export-ui-experimental' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export-ui-experimental 2016-06-14 11:06:22 +02:00
James Lopez 279412f90a updated relation_factory based on MR feedback 2016-06-14 10:55:24 +02:00
Grzegorz Bizon 59eeec3ff8 Make method that composes ci config entry private 2016-06-14 10:48:51 +02:00
James Lopez 7779457907 fix merge 2016-06-14 10:20:47 +02:00
James Lopez 9ff1990422 Merge branches 'feature/project-export' and 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-import 2016-06-14 10:18:03 +02:00
James Lopez f6ed7c8ff8 missed line break 2016-06-14 10:15:20 +02:00