-
Notifications
You must be signed in to change notification settings - Fork 537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev-mode #22748
Conversation
94e00bb
to
ffa9bf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been trying to think through the scenarios but I'm a bit muddled around what determines a scenario when we're in DEV_MODE v.s DEBUG (mode). Things like fake fxa auth are definitely DEV_MODE; enabling debug_toolbar or retaining temporary files for debugging purposes ... 🤷 ?
I think it's easier to know what should be debug_toolbar is a dev dependency, only possible to use it if the target is not production, hence, DEV_MODE. Debug seems to make sense if you really think it through, as you've pointed out a few of my misses. If the feature is "useful" in a debug scenario, we can include it based on DEBUG. DEV_MODE is about what is mandatory or what is possible, DEBUG is about what is useful. I can run DEBUG in dev mode or prod mode, that's why it's independent. DEV_MODE is about enabling/disabling behaivours that are tightly coupled to the DOCKER_TARGET equaling production or not. |
140cdb1
to
8435e56
Compare
@eviljeff I've udpated the docs to hopefully clarify the use cases for DEBUG vs DEV_MODE and fixed all commented issues. |
to make sure I'm testing it correctly, can you state precisely the commands I should be running for the 4 combinations (and what I should expect a vanilla |
@eviljeff done. "vanilla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make up DEBUG= DOCKER_TARGET=production
resulted in the statics not working (html served without js and css).
Other than that, the other 3 scenarios worked, at least for my brief manual tests.
src/olympia/amo/utils.py
Outdated
@@ -1165,7 +1165,7 @@ def extract_colors_from_image(path): | |||
def use_fake_fxa(): | |||
"""Return whether or not to use a fake FxA server for authentication. | |||
Should always return False in production""" | |||
return settings.DEBUG and settings.USE_FAKE_FXA_AUTH | |||
return settings.DEV_MODE or settings.USE_FAKE_FXA_AUTH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't connected to the statics problem I found, was it? This change means you can't use real FxA auth in dev mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I just needed that for local testing.. I will drop that before merging. THough it does kind of suck. Without that it mneans you HAVE to use real FxA in prod mode, which kind of also sucks. I think the real fix is to only rely on the USE_FAKE_FXA_AUTH and just make sure we hardcode production and base settings to prefer real auth. Or maybe rely on the SITE_URL or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably out of scope for this PR, but we could rely on the client_id/secret being set to a real value - the default unless you've defined credentials in your local_settings
or env is .
. Otherwise, redirecting to real FxA just ends in an error page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea. Yeah should be a separate ticket but that makes a lot more sense, if you pass credentials, use em.
e2d9782
to
cfe4ba6
Compare
@eviljeff The issue is ultimately with the volume(s) we are using to load data in the nginx container. I resolved this by simplifying further the setup, removing the Now nginx will try to load files from the ./static directory loaded directly in nginx (no sharing the volume) or by proxying the request to olympia to return the file. Concurrently, the logic toggling whether we serve static assets from django is no longer based on either |
I just tried this now (with a fresh |
8218b4e
to
a7565c3
Compare
e80d1b8
to
17960d9
Compare
Ok, I found some more interesting nuggets of info.
It should be working now @eviljeff please lmk. |
Co-authored-by: Mathieu Pillard <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing results:
I expected to see django toolbar with make up DEBUG=True DOCKER_TARGET=production
(because DEBUG=True) but it was missing.
Couldn't see any other problems 🤷
We cannot show that in prod mode because it is a dev dependency. We could consider moving that to prod dependency but would be a follow up. |
I'm not sure it should be a prod dependency, but in "expectations" you wrote "if debug is true, expect debug toolbar" |
Relates to: mozilla/addons#15066
Relates to: mozilla/addons#15046 (removes one of the mounts that could cause race conditions)
Fixes: mozilla/addons#15058
Description
Adds a
DEV_MODE
boolean setting based on the value ofDOCKER_TARGET
being not equal toproduction
. This value is then used in the places that previously relied onDEBUG
bu that should instead rely specifically on if we are using a production image or not.Context
DEBUG
has largley been used to determine if we are in "dev" or "prod" mode. But we have a better value set during the docker buildDOCKER_TARGET
that actually controls which set of dependencies we have and how we setup our docker compose configuration and this value is much more suited to the task of making such a determination.This split also means you can now run prod mode in debug mode, great for debugging a production like environment.s
To put into context
Testing
There are 4 combinations of make up to run
DEBUG=True/False
andDOCKER_TARGET=development/production
Dev Mode
First run dev mode without debugging
This is running the development image, with debug false. You should expect to have development dependencies installed, but running the app will not load django debug toolbar.
Now rerun the same command but change
DEBUG=True
(it actually can be any value, just not literally empty)Prod Mode
Very much like above, except we are targeting the production image
Now expect dev dependencies to NOT be installed. You can test by running
pip show <dependency
for a dep in the dev.txt file.Rerun with debugging
Expect now to have debugging enabled. You are still running production mode, but debugging is now enabled.
Expectations
All four should work as expected.
make check
works.Checklist
#ISSUENUM
at the top of your PR to an existing open issue in the mozilla/addons repository.