Project

Profile

Help

Story #5859

closed

As a user, I have a wrapper around django-admin that sets DJANGO_SETTINGS_MODULE=pulpcore.app.settings

Added by evgeni about 5 years ago. Updated almost 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
% Done:

100%

Estimated time:
Platform Release:
Groomed:
Yes
Sprint Candidate:
Yes
Tags:
Sprint:
Sprint 67
Quarter:

Description

Background

Users who want to apply migrations must configure their environment to specify DJANGO_SETTINGS_MODULE=pulpcore.app.settings. This is a hassle that affects all users.

Solution

1. Create a wrapper around django-admin called pulp-manage
2. Have it set DJANGO_SETTINGS_MODULE=pulpcore.app.settings
3. Document it

It should provide autocompletion.

Actions #2

Updated by bmbouter about 5 years ago

IIRC, we previously had a command like this and then we removed it because we determined it wasn't adding value. Unless we are creating new value on top of Django, we wanted users to use the Django facilities directly.

Let me recap my understanding of this issue. Is it specifically for Pulp2 system-wide installs with Pulp3 system-wide install on top of that? I think most installs won't have this issue because Pulp3 installations on top of Pulp2 are expected to install together without issue because the pulp3 will be in a different virtualenv thus avoiding the pathing conflict.

Is your Pulp3 being packaged into a virutalenv?

Actions #3

Updated by ehelms@redhat.com about 5 years ago

While I think the packaging conflict is a good reason, let me try to expand on where this can add value overall. For the record, Justin pointed this aspect out to me.

To run any django-admin command you have to specify two environment variables (DJANGO_SETTINGS_MODULE and PULP_SETTINGS) every time. This can be both easy to forgot and tedious to export everytime. The benefit of a pulpcore-admin would be setting this configuration values for the user making it easier to run different admin commands within pulpcore context for debugging or sysadmin purposes.

Actions #4

Updated by evgeni almost 5 years ago

bmbouter: yes, this is about system-pulp2 and system-pulp3 from RPMs, something you don't officially recommend, but what was the easiest path forward when it came to deploying pulp3 via rpm.

@ehelms: pulpcore already has a manage.py that will load the right settings, it's just not installed as a binary and not referenced anywhere in the documentation that only points to "django-admin"

I think one benefit I see here is: we'll definitely have to use something else than "django-admin" in Katello/RPM land, and having Pulp upstream having the same command documented, would be beneficial for consistency.

Oh, btw, I think the docs never mention you need to set DJANGO_SETTINGS_MODULE=pulpcore.app.settings (they only talk about PULP_SETTINGS), but w/o DJANGO_SETTINGS_MODULE, nothing will read PULP_SETTINGS?

Actions #5

Updated by dkliban@redhat.com almost 5 years ago

We used to provide a similar wrapper around django-admin to pulp 3. However, we removed it because it did not support tab completion - which is a nice feature of using django-admin directly. Is there a simple way to make that work?

Here is the original ticket to remove pulp-manager[0].

[0] https://pulp.plan.io/issues/4450

Actions #6

Updated by evgeni almost 5 years ago

Thanks for providing the old ticket.

Yeah, one should be able to teach bash/zsh that "pulp-manager"/"pulpcore-admin" should use the same tab completion helper as "django-admin".

If that's the only blocker you see to get that in, I can research that.

Actions #7

Updated by bmbouter almost 5 years ago

The blocker for me on this is that we're making a user change, but there isn't a user, use-case driving that change (outside of packaging). Packaging matters to me, so I don't mean to discount that. One option is to motivate the change via a use case for users, but since we didn't start there that seems unlikely. The other option is to apply a packaging workaround.

@evgeni I also value your experience as a packager, so I don't want to make that a frustrating experience either.

What packaging workaround options are possible in this situation?

Actions #8

Updated by evgeni almost 5 years ago

we currently rename django-admin to python3-django-admin (https://github.com/theforeman/foreman-packaging/blob/37558e583e65819adb125942a3683785922004f0/packages/pulpcore/python-django/python-django.spec#L49-L50) and we'll have to do that in any case (as long as we want co-installation with pulp2).

we also adjusted the foreman/katello installer to use that name too (https://github.com/theforeman/puppet-pulpcore/pull/48).

thus, if I look only at the katello experience, "we're done" ;)

but if I look at the broader community experience, we notice that katello users now cannot follow Pulp upstream docs, as those mention "django-admin" which would lead to pulp2's django, not pulp3's django in the katello world. and vice versa, pulpcore users won't be able to follow documentation (forum/blog posts, whatsoever) that is targeted at katello.

I think this is the only user use-case I can provide you (besides the "don't need to set DJANGO_SETTINGS" above, which is quite low, granted).

Actions #9

Updated by bmbouter almost 5 years ago

  • Tracker changed from Story to Issue
  • Subject changed from provide a simple "pulpcore-admin" CLI to Clarify where users and katello users should get their django-admin from in the docs
  • Description updated (diff)
  • Category deleted (24)
  • Severity set to 2. Medium
  • Triaged set to No

Rewriting description based on a convo w/ the OP

Actions #10

Updated by daviddavis almost 5 years ago

  • Groomed changed from No to Yes
  • Sprint set to Sprint 63
Actions #11

Updated by bmbouter almost 5 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to bmbouter
Actions #12

Updated by bmbouter almost 5 years ago

  • Status changed from ASSIGNED to POST
Actions #13

Updated by bmbouter almost 5 years ago

  • Tracker changed from Issue to Story
  • Subject changed from Clarify where users and katello users should get their django-admin from in the docs to As a user, I have a wrapper around django-admin that sets DJANGO_SETTINGS_MODULE=pulpcore.app.settings
  • Description updated (diff)
  • Status changed from POST to NEW
  • Sprint/Milestone set to 3.1.0
  • % Done set to 0
  • Sprint deleted (Sprint 63)
Actions #14

Updated by bmbouter almost 5 years ago

  • Assignee deleted (bmbouter)
Actions #15

Updated by bmbouter almost 5 years ago

What should we call it: pulp-django-admin or another name?

Actions #16

Updated by daviddavis almost 5 years ago

If we want users to know that the command is a wrapper for django-admin (and expose that implementation) then pulp-django-admin makes sense. Otherwise, we could use the name we had before, pulp-manage.

Also, do you plan to include auto-completion support with this ticket since users will otherwise lose that when we create the wrapper?

Actions #17

Updated by bmbouter almost 5 years ago

  • Description updated (diff)

+1 to pulp-manage I rewrote it to be that. Also I think we do want the auto completion. What do you think?

Actions #18

Updated by daviddavis almost 5 years ago

I do think we want auto-complete but I'm fine if we want to handle that later/separately.

Actions #19

Updated by evgeni almost 5 years ago

It's nice how this came back to my original proposal ;-)

How do you use/enable bash completion today? A mere `pip install django` does not install any completion for me.

As for naming: Pulp2 has pulp-manage-db, so maybe pulp-manage would be close/confusing? How about pulpcore-manage or pulpcore-admin?

Actions #20

Updated by evgeni almost 5 years ago

Installing Django's bash completion as documented in https://github.com/django/django/blob/stable/2.2.x/extras/django_bash_completion

and then doing a

complete -F _django_completion -o default pulpcore-admin

and having a valid PULP_SETTINGS makes the completion work for me :)

Actions #21

Updated by bmbouter almost 5 years ago

evgeni wrote:

Installing Django's bash completion as documented in https://github.com/django/django/blob/stable/2.2.x/extras/django_bash_completion

Sweet! Let's use that.

and then doing a [...] and having a valid PULP_SETTINGS makes the completion work for me :)

We still won't set PULP_SETTINGS in here, I wrote some about that in this comment here

Actions #22

Updated by evgeni almost 5 years ago

bmbouter, my question "how do you enable completion for django-admin" still stands, as this is not documented :)

Actions #23

Updated by bmbouter almost 5 years ago

  • Sprint Candidate changed from No to Yes
Actions #24

Updated by rchan almost 5 years ago

  • Sprint set to Sprint 64
Actions #25

Updated by rchan almost 5 years ago

  • Sprint changed from Sprint 64 to Sprint 65
Actions #26

Updated by CodeHeeler almost 5 years ago

The state of this issue and comments are rather confusing, so let me summarize what I'm seeing and check to see if we're all on the same page.

1) We do want to add a wrapper. What name do we prefer?
- pulp-manage (+1'd by several folks in the comments though not quite what we had before, -1'd as being too close to pulp-manage-db from pulp2 and potentially confusing)
- pulp-manager (what we had before)
- pulp-django-admin
- pulpcore-admin

2) We do want to provide autocomplete in this same ticket. Do we know how to do that?
- evgeni linked to django_bash_completion page in comment #20 but then in #22 says this functionality is not documented

Does evgeni's PR need to be reviewed/merged once we reach consensus on these final items?

Actions #27

Updated by evgeni almost 5 years ago

CodeHeeler, yeah, that is also my perception of the state:
1) we want a wrapper, but didn't decide on the name yet
2) having completion was raised as a PRO for not having an own wrapper, which I understand, but I also don't see completion working for users when they just follow the current docs.

as to my PR: it solves 1, minus the right naming, but fixing that is cheap as soon as we have agreed on one.

Actions #28

Updated by rchan almost 5 years ago

  • Sprint changed from Sprint 65 to Sprint 66
Actions #29

Updated by daviddavis almost 5 years ago

  • Sprint/Milestone changed from 3.1.0 to 3.2.0
Actions #30

Updated by ipanova@redhat.com almost 5 years ago

  • Description updated (diff)

+1 to pulp-manage or pulp-manager +1 to add auto-completion in this ticket.

Actions #31

Updated by daviddavis almost 5 years ago

+1 to pulp-manage or pulp-manager

I feel like auto-completion could be a separate ticket but I'm also happy if we add it now.

Actions #32

Updated by mdepaulo@redhat.com almost 5 years ago

+1 to this.

I just did some testing myself, by using a modified completions file:

[mdepaulo@mdepaulo ~]$ diff -u /usr/share/bash-completion/completions/django-admin ~/completions/pulp-django-admin 
--- /usr/share/bash-completion/completions/django-admin	2019-12-18 03:28:06.000000000 -0500
+++ /home/mdepaulo/completions/pulp-django-admin	2020-02-13 16:26:56.627202013 -0500
@@ -37,7 +37,7 @@
                    COMP_CWORD=$COMP_CWORD \
                    DJANGO_AUTO_COMPLETE=1 $1 ) )
 }
-complete -F _django_completion -o default django-admin.py manage.py django-admin
+complete -F _django_completion -o default django-admin.py manage.py pulp-django-admin
 
 _python_django_completion()
 {
Actions #33

Updated by evgeni almost 5 years ago

Where does your /usr/share/bash-completion/completions/django-admin come from? pip install django does not create that file.

On February 13, 2020 9:33:28 PM UTC, Pulp wrote:

--- Please write your response above this line ---

Issue #5859 has been updated by .

+1 to this.

I just did some testing myself, by using a modified completions file:

[mdepaulo@mdepaulo ~]$ diff -u /usr/share/bash-completion/completions/django-admin ~/completions/pulp-django-admin   
--- /usr/share/bash-completion/completions/django-admin	2019-12-18 03:28:06.000000000 -0500  
+++ /home/mdepaulo/completions/pulp-django-admin	2020-02-13 16:26:56.627202013 -0500  
@@ -37,7 +37,7 @@  
                   COMP_CWORD=$COMP_CWORD \  
                   DJANGO_AUTO_COMPLETE=1 $1 ) )  
}  
-complete -F _django_completion -o default django-admin.py manage.py django-admin  
+complete -F _django_completion -o default django-admin.py manage.py pulp-django-admin  
  
_python_django_completion()  
{  

Story #5859: As a user, I have a wrapper around django-admin that sets DJANGO_SETTINGS_MODULE=pulpcore.app.settings
https://pulp.plan.io/issues/5859?pn=1#change-53059

  • Author: evgeni
  • Status: NEW
  • Priority: Normal
  • Assignee:
  • Category:
  • Sprint/Milestone: 3.2.0
  • Platform Release:
  • Blocks Release:
  • Backwards Incompatible: No
  • Groomed: Yes
  • Sprint Candidate: Yes
  • Tags:
  • QA Contact:
  • Complexity:
  • Smash Test:
  • Verified: No
  • Verification Required: No
  • Sprint: Sprint 66

Background

Users who want to apply migrations must configure their environment to specify DJANGO_SETTINGS_MODULE=pulpcore.app.settings. This is a hassle that affects all users.

Solution

1. Create a wrapper around django-admin called pulp-manage
2. Have it set DJANGO_SETTINGS_MODULE=pulpcore.app.settings
3. Document it

It should provide autocompletion.

--
You have received this notification because you have either subscribed to or are involved in a project on Pulp Planio.
To change your notification preferences, please click here: https://pulp.plan.io/my/account?tour=mail_preferences

This notification was cheerfully delivered by https://plan.io
 

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Actions #35

Updated by evgeni almost 5 years ago

Oh, interesting.

This raises the following questions:

  1. This is currently only done on Fedora, shall we also provide that package as part of the RPMs we build for EL7 for Katello?
  2. Is the completion code universal enough to cross different Django versions? Fedora is up to Django 3 by now :)
  3. If the ansible installer is responsible for the completion, shall it also deploy the one for pulpcore-admin? Then we don't have to care about it in this redmine.

On February 15, 2020 3:00:52 PM UTC, Pulp wrote:

--- Please write your response above this line ---

Issue #5859 has been updated by daviddavis.

@evgeni, it's provided by this package:

https://github.com/pulp/ansible-pulp/blob/2ec2a7091358b5bcd5d1b912522279ab6ab959a9/roles/pulp-devel/tasks/install_basic_packages.yml#L57


Story #5859: As a user, I have a wrapper around django-admin that sets DJANGO_SETTINGS_MODULE=pulpcore.app.settings
https://pulp.plan.io/issues/5859?pn=1#change-53090

  • Author: evgeni
  • Status: NEW
  • Priority: Normal
  • Assignee:
  • Category:
  • Sprint/Milestone: 3.2.0
  • Platform Release:
  • Blocks Release:
  • Backwards Incompatible: No
  • Groomed: Yes
  • Sprint Candidate: Yes
  • Tags:
  • QA Contact:
  • Complexity:
  • Smash Test:
  • Verified: No
  • Verification Required: No
  • Sprint: Sprint 66

Background

Users who want to apply migrations must configure their environment to specify DJANGO_SETTINGS_MODULE=pulpcore.app.settings. This is a hassle that affects all users.

Solution

1. Create a wrapper around django-admin called pulp-manage
2. Have it set DJANGO_SETTINGS_MODULE=pulpcore.app.settings
3. Document it

It should provide autocompletion.

--
You have received this notification because you have either subscribed to or are involved in a project on Pulp Planio.
To change your notification preferences, please click here: https://pulp.plan.io/my/account?tour=mail_preferences

This notification was cheerfully delivered by https://plan.io
 

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Actions #36

Updated by rchan almost 5 years ago

  • Sprint changed from Sprint 66 to Sprint 67
Actions #37

Updated by bmbouter almost 5 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to bmbouter
Actions #38

Updated by bmbouter almost 5 years ago

  • Status changed from ASSIGNED to POST

Added by bmbouter almost 5 years ago

Revision bd7c8c7e | View on GitHub

Adds pulpcore-manager console command

This add the pulpcore-manager script which is an alias for manage.py only correctly configured to know where the Pulp settings app is already.

This change includes docs which recommend users apply migrations with pulpcore-manager instead of manage.py.

Originally inspired by this PR from @evgeni:

https://github.com/pulp/pulpcore/pull/445/files

https://pulp.plan.io/issues/5859 closes #5859

Actions #39

Updated by bmbouter almost 5 years ago

  • Status changed from POST to MODIFIED
  • % Done changed from 0 to 100
Actions #40

Updated by daviddavis almost 5 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF