Commit Graph

192 Commits

Author SHA1 Message Date
Lin Jen-Shin ba8321a52a Skip creating the merge request if repo is empty 2017-08-11 23:27:42 +08:00
Zeger-Jan van de Weg 5eb940da76 Replace invalid chars while seeding environments 2017-06-21 11:16:38 +00:00
Grzegorz Bizon 37dd19935b Merge branch 'instrument-infra' into 'master'
Add Prometheus metrics endpoint and basic infrastructure to meter code

See merge request !11553
2017-06-07 10:46:56 +00:00
Douglas Barbosa Alexandre 985d355467 Fix error while seeding projects in database 2017-06-06 17:00:44 -03:00
Pawel Chojnacki 4679107fdc Handle case where GITLAB_PROMETHEUS_METRICS_ENABLED is non boolean value by defaulting to false 2017-06-06 13:16:55 +02:00
Sean McGivern 3cc5e48668 Merge branch 'sidekiq-transaction' into 'master'
Forbid Sidekiq scheduling in transactions

Closes #27233

See merge request !9376
2017-06-05 09:34:05 +00:00
Sean McGivern 3b39cf4e0c Merge branch '30469-convdev-index' into 'master'
ConvDev Index

Closes #30469

See merge request !11377
2017-06-05 09:18:12 +00:00
Pawel Chojnacki 6a67148ed3 Make production settings fixture use Gitlab::CurrentSettings.current_application_settings
small code formatting changes
2017-06-02 19:46:29 +02:00
Pawel Chojnacki c86e1437eb Make fixture message more descriptive
+ use strip_heredoc to make the text in tests much more readable
2017-06-02 19:46:29 +02:00
Pawel Chojnacki e21b1501ff Allow enabling Prometheus metrics via ENV variable when db is seeded 2017-06-02 19:46:29 +02:00
Douwe Maan 103b5bf60b Fix keys seed 2017-06-02 12:37:57 -05:00
Lin Jen-Shin 4968f226a0 Make sure that environment was created before deploying 2017-06-02 21:34:31 +08:00
Lin Jen-Shin f62603286d Fix other use of CreateDeploymentService and make
it a bit more robust against missing options,
which we did guard on for some cases.
2017-06-02 02:46:34 +08:00
Taurie Davis, Simon Knox and Adam Niedzielski 26dde5f55f Add Conversational Development Index page to admin panel 2017-06-01 17:37:21 +02:00
Kamil Trzcinski 161af17c1b Introduce source to pipeline entity 2017-05-31 14:17:49 +02:00
Valery Sizov 387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Robert Speicher d33fc982f5 Move the nested groups seed behind an environment flag
This seed downloads 2.1 GB worth of repositories. Google can afford the
bandwidth, but if a person using the GDK is on a metered connection,
that's not so great.

Also the GDK test suite runs this seed, so every CI run for that project
had to download those as well. Needlessly wasteful.
2017-04-10 16:18:58 -04:00
Kamil Trzciński 828d81ee1f Optimise trace handling code to use streaming instead of full read 2017-04-06 16:20:27 +00:00
Kamil Trzciński 7f8e0bce5a Added mock deployment and monitoring service with environments fixtures 2017-04-05 11:04:34 +00:00
Rémy Coutable d7e3fadb42
Ensure we generate unique usernames otherwise validations fail
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-04 08:48:49 +02:00
Rémy Coutable 5388bb1cca Ensure the AbuseReport fixtures create unique reported users
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-03 18:54:48 +02:00
Rémy Coutable 58fe40fbd3 Don't use FFaker in factories, use sequences instead
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-03 18:54:48 +02:00
Rémy Coutable 5f7cb26394 Fix the AbuseReport seeder
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-03 18:54:48 +02:00
Rémy Coutable 53ef1de4fc
Fix production admin fixture to use the new `Users::CreateService`
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-03-30 10:41:45 +02:00
Rémy Coutable 04f62ac235
Remove useless options from db/fixtures/development/17_cycle_analytics.rb
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-03-20 14:47:50 +01:00
Eric Eastwood 96cbad2337 Fix up @DouweM review 2017-03-06 15:19:33 -06:00
Robert Speicher a0ab45d0c3 Fix the `Gitlab::Seeder` monkey patch to disable mail delivery 2017-03-02 20:29:30 -05:00
Dmitriy Zaporozhets 74faf4ca51
Add development fixtures for nested groups
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-02-27 17:28:53 +02:00
Douwe Maan faa2e2df8f Rename commit_file, commit_dir and remove_file and update specs 2017-02-24 09:55:01 -06:00
Douwe Maan 0625af3bcb Consistently create, update, and delete files, taking CRLF settings into account 2017-02-24 09:55:01 -06:00
Eric Eastwood 179ae4ab5b Seed abuse reports
```
rake db:seed_fu FILTER=abuse_reports
```

Thanks to @stanhu,
https://gitlab.com/gitlab-org/gitlab-ce/issues/28059#note_23325328
2017-02-15 16:55:07 -06:00
Adam Pahlevi a0586dbc16 replace `find_with_namespace` with `find_by_full_path`
add complete changelog for !8949
2017-02-03 07:14:04 +07:00
Yorick Peterse 88e627cf14
Fix race conditions for AuthorizedProjectsWorker
There were two cases that could be problematic:

1. Because sometimes AuthorizedProjectsWorker would be scheduled in a
   transaction it was possible for a job to run/complete before a
   COMMIT; resulting in it either producing an error, or producing no
   new data.

2. When scheduling jobs the code would not wait until completion. This
   could lead to a user creating a project and then immediately trying
   to push to it. Usually this will work fine, but given enough load it
   might take a few seconds before a user has access.

The first one is problematic, the second one is mostly just annoying
(but annoying enough to warrant a solution).

This commit changes two things to deal with this:

1. Sidekiq scheduling now takes places after a COMMIT, this is ensured
   by scheduling using Rails' after_commit hook instead of doing so in
   an arbitrary method.

2. When scheduling jobs the calling thread now waits for all jobs to
   complete.

Solution 2 requires tracking of job completions. Sidekiq provides a way
to find a job by its ID, but this involves scanning over the entire
queue; something that is very in-efficient for large queues. As such a
more efficient solution is necessary. There are two main Gems that can
do this in a more efficient manner:

* sidekiq-status
* sidekiq_status

No, this is not a joke. Both Gems do a similar thing (but slightly
different), and the only difference in their name is a dash vs an
underscore. Both Gems however provide far more than just checking if a
job has been completed, and both have their problems. sidekiq-status
does not appear to be actively maintained, with the last release being
in 2015. It also has some issues during testing as API calls are not
stubbed in any way. sidekiq_status on the other hand does not appear to
be very popular, and introduces a similar amount of code.

Because of this I opted to write a simple home grown solution. After
all, all we need is storing a job ID somewhere so we can efficiently
look it up; we don't need extra web UIs (as provided by sidekiq-status)
or complex APIs to update progress, etc.

This is where Gitlab::SidekiqStatus comes in handy. This namespace
contains some code used for tracking, removing, and looking up job IDs;
all without having to scan over an entire queue. Data is removed
explicitly, but also expires automatically just in case.

Using this API we can now schedule jobs in a fork-join like manner: we
schedule the jobs in Sidekiq, process them in parallel, then wait for
completion. By using Sidekiq we can leverage all the benefits such as
being able to scale across multiple cores and hosts, retrying failed
jobs, etc.

The one downside is that we need to make sure we can deal with
unexpected increases in job processing timings. To deal with this the
class Gitlab::JobWaiter (used for waiting for jobs to complete) will
only wait a number of seconds (30 by default). Once this timeout is
reached it will simply return.

For GitLab.com almost all AuthorizedProjectWorker jobs complete in
seconds, only very rarely do we spike to job timings of around a minute.
These in turn seem to be the result of external factors (e.g. deploys),
in which case a user is most likely not able to use the system anyway.

In short, this new solution should ensure that jobs are processed
properly and that in almost all cases a user has access to their
resources whenever they need to have access.
2017-01-25 13:22:15 +01:00
Kamil Trzcinski c1928f4fce
Merge remote-tracking branch 'origin/master' into improve-pipeline-fixtures 2016-12-18 23:43:13 +01:00
twonegatives 0a5427d7c2 Made Ci::Builds to have same ref as Ci::Pipeline in dev fixtures 2016-12-15 19:03:59 +03:00
DJ Mountney fb5f7733f1 Allow users to seed the initial runner registration token using an environment variable
This is useful for when runner is bundled with gitlab, like in a kubernetes stack, and we want the runner to be able to
register with gitlab as soon as they both come up.
2016-12-01 17:21:21 -08:00
Kamil Trzcinski 1e62a13968 Improve pipeline fixtures 2016-11-28 16:55:31 +01:00
Yorick Peterse 92b2c74ce1
Refresh project authorizations using a Redis lease
When I proposed using serializable transactions I was hoping we would be
able to refresh data of individual users concurrently. Unfortunately
upon closer inspection it was revealed this was not the case. This could
result in a lot of queries failing due to serialization errors,
overloading the database in the process (given enough workers trying to
update the target table).

To work around this we're now using a Redis lease that is cancelled upon
completion. This ensures we can update the data of different users
concurrently without overloading the database.

The code will try to obtain the lease until it succeeds, waiting at
least 1 second between retries. This is necessary as we may otherwise
end up _not_ updating the data which is not an option.
2016-11-25 13:35:01 +01:00
Ahmad Sherif 2ea5ef0ba4 Update ProjectTeam#fetch_members to use project authorizations 2016-11-23 12:59:13 +02:00
Douwe Maan 130c8a5198 Merge branch 'feature/precalculate-authorized-projects' into 'master'
Precalculate authorized projects in database

## What does this MR do?
It caches user's authorized projects in database instead of using multiple unions, which should simplify and speed-up things since this operation (getting authorized projects) is used a lot.

## Are there points in the code the reviewer needs to double check?
Did we miss a scenario where we need to refresh the list of projects?

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~
- [ ] ~~API support added~~
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [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 it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?
#23150 

See merge request !6839
2016-11-18 19:42:17 +00:00
Ahmad Sherif fd05e26618 Precalculate user's authorized projects in database
Closes #23150
2016-11-18 20:25:45 +02:00
Douwe Maan 2343b83098 Merge branch 'feature/cycle-analytics-events' into 'master'
Cycle Analytics: Events per stage

Adds list of events to each stage:

- Issue: list of issues created in the last XX days, that have been labeled or added to a milestone.
- Plan: list of commits that reference for the fist time an issue from the last stage.
- Code: list of MR created in this stage
- Test: List of unique builds triggered by the commits.
- Review: List of MR merged
- Staging: List of deployed builds
- Production: list of issues with the time from idea to production

Fixes #23449 

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [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 it does - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !6859
2016-11-18 13:50:50 +00:00
James Lopez c76ef84781 run pipeline worker in cycle analytics dev setup 2016-11-18 10:50:47 +01:00
Semyon Pupkov 0fe3aa2d0b Remove empty db fixtures file 2016-11-17 10:24:57 +05:00
Kamil Trzcinski 6cdbb27ec3 Refactor code to use available and stopped statuses and refactor views to use separate renders 2016-10-17 12:45:31 +02:00
Kamil Trzcinski 0e1f39d8ce Allow to close environments 2016-10-06 14:16:03 +02:00
Grzegorz Bizon ebeee31100 Fix pipeline fixtures and calls to removed method 2016-10-04 14:43:24 +02:00
Rémy Coutable ec0061a95c Allow Member.add_user to handle access requesters
Changes include:

- Ensure Member.add_user is not called directly when not necessary
- New GroupMember.add_users_to_group to have the same abstraction level as for Project
- Refactor Member.add_user to take a source instead of an array of members
- Fix Rubocop offenses
- Always use Project#add_user instead of project.team.add_user
- Factorize users addition as members in Member.add_users_to_source
- Make access_level a keyword argument in GroupMember.add_users_to_group and ProjectMember.add_users_to_projects
- Destroy any requester before adding them as a member
- Improve the way we handle access requesters in Member.add_user
  Instead of removing the requester and creating a new member,
  we now simply accepts their access request. This way, they will
  receive a "access request granted" email.
- Fix error that was previously silently ignored
- Stop raising when access level is invalid in Member, let Rails validation do their work

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-09-28 09:43:00 +02:00
Grzegorz Bizon c2083b7997 Limit test environment size to one project in CI 2016-09-23 10:21:12 +02:00
Timothy Andrew 8957293d9b Implement review comments from @yorickpeterse
1. Change multiple updates to a single `update_all`

2. Use cascading deletes

3. Extract an average function for the database median.

4. Move database median to `lib/gitlab/database`

5. Use `delete_all` instead of `destroy_all`

6. Minor refactoring
2016-09-20 16:05:25 +05:30