Commit Graph

241 Commits

Author SHA1 Message Date
James Lopez eef5135e08 Fix events error importing GitLab projects 2017-08-28 15:24:24 +02:00
Sean McGivern ce89c425fe Merge branch 'fix/import-fork-mr' into 'master'
Fix Import/Export issue to do with fork merge requests

Closes #36666

See merge request !13717
2017-08-22 11:57:06 +00:00
Gabriel Mazetto 9e6fa996ea New storage is now "Hashed" instead of "UUID" 2017-08-22 06:33:20 +02:00
James Lopez fb9bd552c9 Fix fork MRs importing issue 2017-08-21 16:39:28 +02:00
Felipe Artur 91035871d3 Fix project import to group when there are project milestones 2017-08-17 10:40:19 +00:00
Robert Speicher 142b9ec4a0 Fix two additional violations caused by previous changes 2017-08-15 15:53:16 -04:00
Robert Speicher 4edfad9678 Enable Layout/TrailingWhitespace cop and auto-correct offenses 2017-08-15 13:44:37 -04:00
Sean McGivern e80a893ff0 Merge branch 'split-events-into-push-events' into 'master'
Use a separate table for storing push events

See merge request !12463
2017-08-11 14:40:03 +00:00
James Edwards-Jones 334915d508 Merge branch 'import-symlinks-9-3' into 'security-9-3'
Fix file disclosure via hidden symlinks using the project import (9.3)

See merge request !2164
2017-08-10 20:42:01 +01:00
Yorick Peterse 0395c47193
Migrate events into a new format
This commit migrates events data in such a way that push events are
stored much more efficiently. This is done by creating a shadow table
called "events_for_migration", and a table called "push_event_payloads"
which is used for storing push data of push events. The background
migration in this commit will copy events from the "events" table into
the "events_for_migration" table, push events in will also have a row
created in "push_event_payloads".

This approach allows us to reclaim space in the next release by simply
swapping the "events" and "events_for_migration" tables, then dropping
the old events (now "events_for_migration") table.

The new table structure is also optimised for storage space, and does
not include the unused "title" column nor the "data" column (since this
data is moved to "push_event_payloads").

== Newly Created Events

Newly created events are inserted into both "events" and
"events_for_migration", both using the exact same primary key value. The
table "push_event_payloads" in turn has a foreign key to the _shadow_
table. This removes the need for recreating and validating the foreign
key after swapping the tables. Since the shadow table also has a foreign
key to "projects.id" we also don't have to worry about orphaned rows.

This approach however does require some additional storage as we're
duplicating a portion of the events data for at least 1 release. The
exact amount is hard to estimate, but for GitLab.com this is expected to
be between 10 and 20 GB at most. The background migration in this commit
deliberately does _not_ update the "events" table as doing so would put
a lot of pressure on PostgreSQL's auto vacuuming system.

== Supporting Both Old And New Events

Application code has also been adjusted to support push events using
both the old and new data formats. This is done by creating a PushEvent
class which extends the regular Event class. Using Rails' Single Table
Inheritance system we can ensure the right class is used for the right
data, which in this case is based on the value of `events.action`. To
support displaying old and new data at the same time the PushEvent class
re-defines a few methods of the Event class, falling back to their
original implementations for push events in the old format.

Once all existing events have been migrated the various push event
related methods can be removed from the Event model, and the calls to
`super` can be removed from the methods in the PushEvent model.

The UI and event atom feed have also been slightly changed to better
handle this new setup, fortunately only a few changes were necessary to
make this work.

== API Changes

The API only displays push data of events in the new format. Supporting
both formats in the API is a bit more difficult compared to the UI.
Since the old push data was not really well documented (apart from one
example that used an incorrect "action" nmae) I decided that supporting
both was not worth the effort, especially since events will be migrated
in a few days _and_ new events are created in the correct format.
2017-08-10 17:45:44 +02:00
Oswaldo Ferreira a0c22d1eda Exclude merge_jid on Import/Export attribute configuration 2017-08-07 20:04:16 -03:00
Gabriel Mazetto 07b574b41c Added some extra TODOs for the Legacy Storage refactor 2017-08-01 07:28:13 +02:00
Gabriel Mazetto c6dee99803 Rename path_with_namespace -> disk_path when dealing with the filesystem 2017-08-01 07:26:58 +02:00
Sean McGivern aff5c9f3e5 Add table for merge request commits
This is an ID-less table with just three columns: an association to the merge
request diff the commit belongs to, the relative order of the commit within the
merge request diff, and the commit SHA itself.

Previously we stored much more information about the commits, so that we could
display them even when they were deleted from the repo. Since 8.0, we ensure
that those commits are kept around for as long as the target repo itself is, so
we don't need to duplicate that data in the database.
2017-07-06 17:36:10 +01:00
Adam Niedzielski 0eb3d18c56 Store merge request ref_fetched status in the database
Closes #34052
2017-06-26 17:36:09 +02:00
Sean McGivern 9a73b634ab Add table for files in merge request diffs
This adds an ID-less table containing one row per file, per merge request
diff. It has a column for each attribute on Gitlab::Git::Diff that is serialised
currently, with the advantage that we can easily query the attributes of this
new table.

It does not migrate existing data, so we have fallback code when the legacy
st_diffs column is present instead. For a merge request diff to be valid, it
should have at most one of:

* Rows in this new table, with the correct merge_request_diff_id.
* A non-NULL st_diffs column.

It may have neither, if the diff is empty.
2017-06-16 18:30:01 +01:00
Grzegorz Bizon 3801a0df80 Export pipeline stages in import/export feature 2017-06-05 12:46:57 +02:00
James Lopez 1a5e84febe Merge branch 'fix/gl-project-id' into 'master'
Omit gl_project_id from Import/Export

Closes #29813

See merge request !11032
2017-05-08 06:52:01 +00:00
Zeger-Jan van de Weg 8df3997a92 Add Pipeline Schedules that supersedes experimental Trigger Schedule 2017-05-07 22:35:56 +00:00
Stan Hu 58166f03b9 Merge branch 'fix/fork-spec-mysql' into 'master'
Fix fork_spec failure to do with mySQL

Closes #31870

See merge request !11121
2017-05-06 02:02:42 +00:00
James Lopez cc826c0469 workaround spec failure for mySQL invalid date issue 2017-05-05 16:45:46 +02:00
blackst0ne cca09bbb18 Update Import/Export files 2017-05-05 16:39:26 +11:00
James Lopez cf3990cfbf Fix project tree saver and fork spec failures 2017-05-03 16:36:01 +00:00
James Lopez 2174e37845 Include missing project attributes to Import/Export 2017-05-03 10:12:32 +00:00
James Lopez 702b291f81 remove gl_project_id for I/E version update 2017-05-02 14:55:32 +02:00
blackst0ne 11aff97d88 Remove the User#is_admin? method 2017-04-09 13:20:57 +11:00
Kushal Pandya 8a5ca1121b Merge branch 'master' into '18471-restrict-tag-pushes-protected-tags'
# Conflicts:
#   spec/lib/gitlab/import_export/all_models.yml
2017-04-06 21:12:16 +00:00
James Edwards-Jones 7d17fcea84 Fix projected import failing on missing relations 2017-04-06 15:48:20 +01:00
Shinya Maeda a67aff6d39 Add Import/Export Setting for trigger_schedule. Remove ref validation. 2017-04-06 23:46:58 +09:00
Shinya Maeda 01cea0d59d Suppress Import/Export function warnings. Add comment for confirmation. 2017-04-06 23:46:58 +09:00
Kushal Pandya 18506d4b8b Merge branch 'master' into '18471-restrict-tag-pushes-protected-tags'
# Conflicts:
#   app/assets/javascripts/dispatcher.js
#   app/assets/stylesheets/pages/projects.scss
2017-04-06 09:46:50 +00:00
James Lopez 22d7ae8002 Fix issues importing forked projects 2017-04-04 16:34:19 +00:00
James Edwards-Jones 07d7d8e659 Renamed ProtectedTag push_access_levels to create_access_levels 2017-04-04 03:38:58 +01:00
James Edwards-Jones 3bb3a6886f Attempt to fix import/export of push_access_levels for protected tags 2017-04-04 02:19:04 +01:00
James Edwards-Jones 9f4b8dba80 Clean up non TODO rubocop errors 2017-04-03 20:06:06 +01:00
Kamil Trzciński 12dd5ac221 All CI offline migrations 2017-03-17 23:06:11 +00:00
Dmitriy Zaporozhets 5b52adcedb
Fix group members method for project import/export
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-03-09 13:40:57 +02:00
Sean McGivern 811e598f60 Enable and autocorrect the CustomErrorClass cop 2017-03-01 15:28:10 +00:00
Rémy Coutable d8752015b3 Merge branch 'fix/import-hooks' into 'master'
Fix import webhooks performance issue

Closes #27958

See merge request !9197
2017-02-16 15:00:40 +00:00
James Lopez b3fb5b4f26 Use gitlab shell import instead of manually creating the webhooks
Also update repo restorer to use project wiki method.
2017-02-16 10:02:26 +01:00
Dmitriy Zaporozhets 6676b4f0dd
Use Namespace#full_path instead of Namespace#path
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-02-14 18:38:20 +02:00
James Lopez 8409340b3b Add missing group members to export for I/E 2017-02-07 11:06:05 +01:00
James Lopez 8ea1dafe83 use destroy_all 2017-01-31 19:20:35 +01:00
James Lopez 918eaba0c3 remove old project members from project 2017-01-31 16:32:26 +01:00
James Lopez 017a5068f6 fix spec failure 2017-01-30 14:26:32 +01:00
James Lopez 1a2d13c821 programmatically remove encrypted attributes. Added relevant spec. 2017-01-30 12:34:32 +01:00
James Lopez eeb13c16d1 rename method and added note to export file spec about new encrypted attributes 2017-01-30 12:34:32 +01:00
James Lopez 6a2b976c66 fix typo 2017-01-30 12:34:32 +01:00
James Lopez e589c7e848 Ignore encrypted attributes in Import/Export
* Regenerates tokens for all models that have them
* Remove variables, since they are basically just storing encrypted data
* Bumped version up to 0.1.6
* Updated related docs
2017-01-30 12:34:32 +01:00
Rémy Coutable 4af1f18639 Merge branch 'fix/import-users' into 'master'
Fix import no longer mapping users as admin

Closes #25346

See merge request !8625
2017-01-20 16:03:44 +00:00