Pulp 3 Developer Notes » History » Sprint/Milestone 3
semyers, 04/12/2017 08:39 PM
virtualenv problems resolved with https://github.com/pulp/devel/pull/44
1 | 1 | semyers | # Pulp 3 Developer Notes |
---|---|---|---|
2 | |||
3 | This wiki page is intended for use during early development of Pulp 3. Over time, as our development practices become standard, the contents of this page should be moved into the [Pulp Contributing Guide](https://docs.pulpproject.org/en/3.0/nightly/contributing/index.html) |
||
4 | |||
5 | ## Migrations |
||
6 | |||
7 | In both platform and plugins, the data model is not complete. As a result, committing migrations to the 3.0-dev branch will result in merge/migration conflicts from pull request to pull request. The simplest solution for now is not to commit migrations to the repository. |
||
8 | |||
9 | Because User model depends on Django's auth app having been migrated, this means that you currently need to run `python manage.py migrate auth` before running a general `python manage.py migrate` to set up the pulp database. |
||
10 | |||
11 | ### Making migrations during development |
||
12 | |||
13 | Tests require migrations to run, so while we should not *commit* migrations to the repositories just yet, we do still need to *make* them. This can be done with the `python manage.py makemigrations` command. Apps that depend on the platform migrations existing (such as plugins) may cause errors when making migrations. To avoid these errors, platform migrations should be made prior to installing any plugins. |
||
14 | |||
15 | Once the initial migrations are created, and model changes made thereafter will require `python manage.py makemigrations` to be run again, following by @python manage.py migrate" so Django can apply the model changes to the database. |
||
16 | |||
17 | This is probably something we can do in the dev playbook; automating the process until we do start to commit migrations would help immensely with mitigating this annoyance. |
||
18 | |||
19 | ## Starting a Web Server |
||
20 | |||
21 | The Django development server can be started with `python manage.py runserver`. This will run a basic WSGI app that exposes the URLs routed in `urls.py`, allowing you to access the REST API. |
||
22 | |||
23 | If you're using the vagrant [hostmanager](https://rubygems.org/gems/vagrant-hostmanager) plugin, you can easily access the API from the host machine by explicitly binding the web server to all interfaces, e.g. `python manage.py runserver 0.0.0.0:8000`. This should make the API browseable at http://dev.example.com:8000/api/v3/ |
||
24 | |||
25 | ### Authentication |
||
26 | |||
27 | We currently enable Basic HTTP Authentication on the REST API. This can be temporarily disabled by commenting out the `DEFAULT_PERMISSION_CLASSES` line in the `REST_FRAMEWORK` section in `app/pulp/app/settings.py`. Note that this doesn't disable authentication, it just authorizes unauthenticated users to take any action. Basic Authentication should still work. |
||
28 | 2 | bizhang | |
29 | ## Starting Tasks |
||
30 | |||
31 | Currently the systemd service files are not copied over on the Pulp3 Vagrant environment, so celerybeat, resource manager, and workers have to be started manually. |
||
32 | |||
33 | ~~~ |
||
34 | sudo -u apache /usr/bin/celery beat --app=pulp.tasking.celery_app:celery --scheduler=pulp.tasking.services.scheduler.Scheduler -l=INFO --pidfile=/var/run/pulp/scheduler.pid |
||
35 | |||
36 | sudo -u apache /usr/bin/celery worker -A pulp.tasking.celery_app:celery -n resource_manager@%%h\ |
||
37 | -Q resource_manager -c 1 --events --umask 18 --pidfile=/var/run/pulp/resource_manager.pid\ |
||
38 | --heartbeat-interval=5 -l=INFO |
||
39 | |||
40 | sudo -u apache /usr/bin/celery worker -n reserved_resource_worker-123s@h\ |
||
41 | -A pulp.tasking.celery_app:celery -c 1 --events --umask 18\ |
||
42 | --pidfile=/var/run/pulp/reserved_resource_worker-123s.pid\ |
||
43 | --heartbeat-interval=5 -l=INFO |
||
44 | ~~~ |
||
45 | |||
46 | apply_async and apply_async_with_reservation tasks can be tested from a django shell `python manage.py shell_plus` I usually do the following to test tasks |
||
47 | |||
48 | ~~~ |
||
49 | from pulp.app.tasks import repository |
||
50 | from pulp.app.models import Repository |
||
51 | import uuid |
||
52 | repo_uuid=str(uuid.uuid4()) |
||
53 | repo=Repository(name=repo_uuid) |
||
54 | repo.save() |
||
55 | |||
56 | repository.delete.apply_async(kwargs={'repo_name':repo_uuid}) |
||
57 | repository.delete.apply_async_with_reservation("foo","bar",kwargs={'repo_name':repo_uuid}) |
||
58 | ~~~ |