<div dir="ltr"><div>I've filed this issue tracking the improvement which would allow users to run `flush` and not experience this problem.</div><div><br></div><div><a href="https://pulp.plan.io/issues/7710">https://pulp.plan.io/issues/7710</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 14, 2020 at 12:14 PM Tatiana Tereshchenko <<a href="mailto:ttereshc@redhat.com">ttereshc@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Adam,</div><div>I agree we lack documentation on resetting the environment and the database, probably because we never ask to wipe out the database for upgrades.</div><div>The instructions are usually provided with release and ask you basically to run the latest pulp_installer.<br></div><div><br></div><div>There is some data which is provided with migrations and which has to be present in the database, that's why dropping the database and applying migrations work and `flush` does not.</div><div>`flush` just removes data and keeps all the tables in place, so migrations are not re-applied. </div><div>So for now, please do not use `flush` if you want to start using pulp 3 db from scratch. We potentially can provide a separate command or find some other way to fill in the essential data back.</div><div>Please file an issue in our tracker if such feature/command is helpful for you. <a href="https://pulp.plan.io/projects/pulp/issues/new" target="_blank">https://pulp.plan.io/projects/pulp/issues/new</a></div><div><br></div><div>As a side note, if you are interested, reset_db command drops database. It's provided as a part of django-extensions package <a href="https://django-extensions.readthedocs.io/en/latest/command_extensions.html" target="_blank">https://django-extensions.readthedocs.io/en/latest/command_extensions.html</a><br></div><div><br></div><div>I'm glad that the migration  runs for you now,</div><div>Tanya</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 14, 2020 at 3:52 PM Winberg Adam <<a href="mailto:Adam.Winberg@smhi.se" target="_blank">Adam.Winberg@smhi.se</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div id="gmail-m_-7626224437629582313m_2939473240739069859gmail-m_-1273737047963046109divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Thanks for the reply!</p>
<p><br>
</p>
<p>I use 'flush' to clear the db, I don't have a 'reset_db' command. Otherwise that's pretty much my process. </p>
<p><br>
</p>
<p>The migrate command returns '<span>No migrations to apply'. </span></p>
<p><span>Running 'pulpcore-manager show-migrations' shows that all migrations, including 'guardian.0001/guardian.0002' has checkmarks ([X]). </span></p>
<p><span></span></p>
<div><span style="font-family:Consolas,Courier,monospace;font-size:8pt">guardian</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:8pt"> [X] 0001_initial</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:8pt"> [X] 0002_generic_permissions_index</span></div>
<div><br>
</div>
The creation of the migration plan works so I assume my admin user is ok. 
<p></p>
<p><span><br>
</span></p>
<p><span>I am using an rpm based installation on RHEL8, with</span></p>
<p><span></span></p>
<div>python3-pulp-2to3-migration-0.4.0-1.el8.noarch</div>
<div>python3-pulp-rpm-3.7.0-1.el8.noarch</div>
<div>python3-pulpcore-3.7.1-3.el8.noarch</div>
<div><br>
</div>

<p></p>
<div><br>
</div>
<div>I don't know what went wrong, but I surrendered and dropped my DB and redid the migrations from scratch - and now it works. </div>
<div>Is there a documented instruction on upgrading existing installations?</div>
<div><br>
</div>
<div>//Adam</div>
<div><br>
</div>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-7626224437629582313m_2939473240739069859gmail-m_-1273737047963046109divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Tatiana Tereshchenko <<a href="mailto:ttereshc@redhat.com" target="_blank">ttereshc@redhat.com</a>><br>
<b>Sent:</b> 14 October 2020 14:15<br>
<b>To:</b> Winberg Adam<br>
<b>Cc:</b> <a href="mailto:pulp-list@redhat.com" target="_blank">pulp-list@redhat.com</a><br>
<b>Subject:</b> Re: [Pulp-list] pulp2 migration: AccessPolicy matching query does not exist</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr"><br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Oct 14, 2020 at 2:12 PM Tatiana Tereshchenko <<a href="mailto:ttereshc@redhat.com" target="_blank">ttereshc@redhat.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">Hi Adam,
<div><br>
</div>
<div></div>
<div>My understanding is that you did the following:<br>
</div>
<div> * stop pulp services</div>
<div> * pulpcore-manager (or django-admin) reset_db<br>
</div>
<div> * pulpcore-manager migrate</div>
<div> * pulpcore-manager reset-admin-password --password password</div>
<div> * start services</div>
<div> * http POST :/pulp/api/v3/migration-plans/ < your_migraiton_plan.json</div>
<div> * http POST :/pulp/api/v3/migration-plans/48d03a72-96a1-4d36-9f8b-9a57e97846ef/run/</div>
</div>
</blockquote>
<div><br>
</div>
<div>Sent too early :)</div>
<div>I can't reproduce it so far, so any hints about what can be special about your environment or installation would be appreciated.</div>
<div>Make sure that you have at least one user which has admin privileges and that the guardian migrations ran indeed.</div>
<div>  Applying guardian.0001_initial... OK<br>
  Applying guardian.0002_generic_permissions_index... OK<br>
</div>
<div><br>
</div>
<div>Tanya</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Oct 14, 2020 at 8:02 AM Winberg Adam <<a href="mailto:Adam.Winberg@smhi.se" target="_blank">Adam.Winberg@smhi.se</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_-7626224437629582313m_2939473240739069859gmail-m_-1273737047963046109m_5891547773924260715gmail-m_-1762946298142522933gmail-m_1549989501993885658divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif">
<p>Hello,</p>
<p><br>
</p>
<p>so I updated my pulp3 installation from 3.4 to 3.7 and tried to rerun my pulp2 migration - but it errors out with "<span>AccessPolicy matching query does not exist". Anyone know why?</span></p>
<p><span><br>
</span></p>
<p><span>I flushed my db, reran the 'migrate' job, created a pulp2migration plan (which worked fine) and then tried to run it. Here's the complete error:</span></p>
<p><span><br>
</span></p>
<p><span></span></p>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]: pulp: django.request:ERROR: Internal Server Error: /pulp/api/v3/migration-plans/48d03a72-96a1-4d36-9f8b-9a57e97846ef/run/</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]: Traceback (most recent call last):</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner </span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     response = get_response(request)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     response = self.process_exception_by_middleware(e, request)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     return view_func(*args, **kwargs)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/rest_framework/viewsets.py", line 114, in view</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     return self.dispatch(request, *args, **kwargs)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/rest_framework/views.py", line 505, in dispatch</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     response = self.handle_exception(exc)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/rest_framework/views.py", line 465, in handle_exception</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     self.raise_uncaught_exception(exc)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     raise exc</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/rest_framework/views.py", line 502, in dispatch </span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     response = handler(request, *args, **kwargs)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/pulp_2to3_migration/app/viewsets.py", line 85, in run</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     'dry_run': dry_run</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/pulpcore/tasking/tasks.py", line 236, in enqueue_with_reservation</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     **parent_kwarg, </span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     return getattr(self.get_queryset(), name)(*args, **kwargs)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 422, in create</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     obj.save(force_insert=True, using=self.db)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django_lifecycle/mixins.py", line 132, in save</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     self._run_hooked_methods(AFTER_CREATE)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django_lifecycle/mixins.py", line 207, in _run_hooked_methods</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     method()</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django_lifecycle/decorators.py", line 69, in func</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     hooked_method(*args, **kwargs)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/pulpcore/app/models/access_policy.py", line 60, in add_perms </span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     access_policy = AccessPolicy.objects.get(viewset_name=self.ACCESS_POLICY_VIEWSET_NAME)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     return getattr(self.get_queryset(), name)(*args, **kwargs)</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:   File "/usr/lib/python3.6/site-packages/django/db/models/query.py", line 408, in get</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]:     self.model._meta.object_name</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:9pt">Oct 14 05:43:26  gunicorn[2150852]: pulpcore.app.models.access_policy.AccessPolicy.DoesNotExist: AccessPolicy matching query does not exist</span>.</div>
<br>
<p></p>
<p><span><br>
</span></p>
<p>Regards </p>
<p>//Adam</p>
</div>
</div>
_______________________________________________<br>
Pulp-list mailing list<br>
<a href="mailto:Pulp-list@redhat.com" target="_blank">Pulp-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-list" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-list</a></blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div></div>
_______________________________________________<br>
Pulp-list mailing list<br>
<a href="mailto:Pulp-list@redhat.com" target="_blank">Pulp-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-list" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-list</a></blockquote></div>