Skip to content
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

Oryx doesn't create antenv and install requirements.txt - Python 3.7 Linux Web App #557

Closed
andrewholler opened this issue Apr 9, 2020 · 13 comments

Comments

@andrewholler
Copy link

andrewholler commented Apr 9, 2020

Feature Request

Time: 04/09/2020, Feature request UPDATE: 04/15/2020

Server: Azure Web Apps (Linux, PYTHON|3.7)

Repo: https://github.com/Azure-Samples/djangoapp

  • What happened?

Oryx is failing to create the virtual env "antenv" and run pip install -r requirements.txt

  • What did you expect or want to happen?

I want antenv to be created and to have the requirements in requirements.txt be installed so that the Django server can start.

  • How can we reproduce it?

Create a new linux web app of type, Python 3.7. Do a zip deployment of the sample application to the app service. Check the Docker logs and you will see it fail just as it does below.

  • Do you have log output? Please include between the backticks:
2020-04-09T20:16:14.871258627Z 
2020-04-09T20:16:14.871291627Z   _____                               
2020-04-09T20:16:14.871297627Z   /  _  \ __________ _________   ____  
2020-04-09T20:16:14.871301327Z  /  /_\  \___   /  |  \_  __ \_/ __ \ 
2020-04-09T20:16:14.871305227Z /    |    \/    /|  |  /|  | \/\  ___/ 
2020-04-09T20:16:14.871308827Z \____|__  /_____ \____/ |__|    \___  >
2020-04-09T20:16:14.871312527Z         \/      \/                  \/ 
2020-04-09T20:16:14.871316127Z 
2020-04-09T20:16:14.871319327Z A P P   S E R V I C E   O N   L I N U X
2020-04-09T20:16:14.871322827Z 
2020-04-09T20:16:14.871326127Z Documentation: http://aka.ms/webapp-linux
2020-04-09T20:16:14.871329527Z Python 3.7.5
2020-04-09T20:16:14.871332827Z Note: Any data outside '/home' is not persisted
2020-04-09T20:16:15.090901890Z Starting OpenBSD Secure Shell server: sshd.
2020-04-09T20:16:15.121500394Z App Command Line not configured, will attempt auto-detect
2020-04-09T20:16:15.122129998Z Launching oryx with: -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -bindPort 8000
2020-04-09T20:16:15.132623468Z Oryx Version: 0.2.20200114.13, Commit: 204922f30f8e8d41f5241b8c218425ef89106d1d, ReleaseTagName: 20200114.13
2020-04-09T20:16:15.133780576Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-04-09T20:16:15.140000817Z Could not find operation ID in manifest. Generating an operation id...
2020-04-09T20:16:15.140535921Z Build Operation ID: dce71382-f55a-4560-a0df-19fcb7664979
2020-04-09T20:16:15.750143382Z Detected an app based on Django
2020-04-09T20:16:15.750823386Z Generating `gunicorn` command for 'azuresite.wsgi'
2020-04-09T20:16:16.091053353Z Writing output script to '/opt/startup/startup.sh'
2020-04-09T20:16:16.669059704Z WARNING: Could not find virtual environment directory /home/site/wwwroot/antenv.
2020-04-09T20:16:16.669668408Z WARNING: Could not find package directory /home/site/wwwroot/__oryx_packages__.
2020-04-09T20:16:17.287573115Z [2020-04-09 20:16:17 +0000] [37] [INFO] Starting gunicorn 20.0.4
2020-04-09T20:16:17.288610522Z [2020-04-09 20:16:17 +0000] [37] [INFO] Listening at: http://0.0.0.0:8000 (37)
2020-04-09T20:16:17.289100725Z [2020-04-09 20:16:17 +0000] [37] [INFO] Using worker: sync
2020-04-09T20:16:17.298973590Z [2020-04-09 20:16:17 +0000] [40] [INFO] Booting worker with pid: 40
2020-04-09T20:16:17.331365802Z [2020-04-09 20:16:17 +0000] [40] [ERROR] Exception in worker process
2020-04-09T20:16:17.331383102Z Traceback (most recent call last):
2020-04-09T20:16:17.331388502Z   File "/opt/python/3.7.5/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-04-09T20:16:17.331392802Z     worker.init_process()
2020-04-09T20:16:17.331396602Z   File "/opt/python/3.7.5/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-04-09T20:16:17.331407903Z     self.load_wsgi()
2020-04-09T20:16:17.331412003Z   File "/opt/python/3.7.5/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-04-09T20:16:17.331416003Z     self.wsgi = self.app.wsgi()
2020-04-09T20:16:17.331419703Z   File "/opt/python/3.7.5/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-04-09T20:16:17.331423603Z     self.callable = self.load()
2020-04-09T20:16:17.331427303Z   File "/opt/python/3.7.5/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-04-09T20:16:17.331431203Z     return self.load_wsgiapp()
2020-04-09T20:16:17.331434903Z   File "/opt/python/3.7.5/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-04-09T20:16:17.331438903Z     return util.import_app(self.app_uri)
2020-04-09T20:16:17.331442603Z   File "/opt/python/3.7.5/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app
2020-04-09T20:16:17.331446503Z     mod = importlib.import_module(module)
2020-04-09T20:16:17.331450203Z   File "/opt/python/3.7.5/lib/python3.7/importlib/__init__.py", line 127, in import_module
2020-04-09T20:16:17.331454103Z     return _bootstrap._gcd_import(name[level:], package, level)
2020-04-09T20:16:17.331457903Z   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
2020-04-09T20:16:17.331462103Z   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
2020-04-09T20:16:17.331466003Z   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
2020-04-09T20:16:17.331469903Z   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
2020-04-09T20:16:17.331473803Z   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
2020-04-09T20:16:17.331477703Z   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-04-09T20:16:17.331481603Z   File "/home/site/wwwroot/azuresite/wsgi.py", line 12, in <module>
2020-04-09T20:16:17.331485803Z     from django.core.wsgi import get_wsgi_application
2020-04-09T20:16:17.331489703Z ModuleNotFoundError: No module named 'django'
2020-04-09T20:16:17.335610230Z [2020-04-09 20:16:17 +0000] [40] [INFO] Worker exiting (pid: 40)
2020-04-09T20:16:17.396768532Z [2020-04-09 20:16:17 +0000] [37] [INFO] Shutting down: Master
2020-04-09T20:16:17.397331535Z [2020-04-09 20:16:17 +0000] [37] [INFO] Reason: Worker failed to boot.
@RJFerguson
Copy link

I am encountering the same issue, my temporary work around was to create a custom startup script and explicitly install the requirements file.

pip install -r requirements.txt && gunicorn --bind=0.0.0.0 --workers=4 startup:app

(I have a flask app with pandas failing to install)

screencap below stating the same thing as aholler2

image

@arroyc
Copy link
Contributor

arroyc commented Apr 10, 2020

Thanks for reporting .. we will try to repro this and get back to you soon.

@andrewholler
Copy link
Author

@arroyc It's easiest to reproduce with a simple Azure Pipeline app service deployment task or deploying to web app via the VS Code app service extension. Both do a zip deployment and the antenv virtual environment is not being built before deployment as well (expect Oryx to do that).

@arroyc
Copy link
Contributor

arroyc commented Apr 10, 2020

@aholler2, for zip deployment .. oryx is not enabled by default . https://docs.microsoft.com/en-us/azure/app-service/deploy-zip , that means if you are using zip deployment, it's expected that you have all your dependencies including your virtual env inside your zip
@sanchitmehta , is there any way to enable oryx for zip deployment right now or it will be only in ant-88?

@arroyc
Copy link
Contributor

arroyc commented Apr 10, 2020

@RJFerguson can you please create separate issue for panda being failed .. hope you saw my answer for zip deployment .. but before you create that issue I would like you to try local git push for the flask-panda app and not using zip deployment

@sidbhat1979
Copy link

Hi Team, i am also facing a similar problem. In my git push it is saying 'could not find requirements.txt'. The following is the log of my git commit & git push. Let me know how it can be resolved. Without installing the packages my app will not work.

D:\MSLUIS\Weather-Chatbot-Using-Luis-master>git push weatherbot master -f
Enumerating objects: 37, done.
Counting objects: 100% (37/37), done.
Delta compression using up to 8 threads
Compressing objects: 100% (32/32), done.
Writing objects: 100% (37/37), 988.32 KiB | 649.00 KiB/s, done.
Total 37 (delta 0), reused 0 (delta 0)
remote: Deploy Async
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '4ef4746e4c'.
remote: Repository path is /home/site/repository
remote: Running oryx build...
remote: Build orchestrated by Microsoft Oryx, https://github.com/Microsoft/Oryx
remote: You can report issues at https://github.com/Microsoft/Oryx/issues
remote:
remote: Oryx Version : 0.2.20200114.13, Commit: 204922f, ReleaseTagName: 20200114.13
remote: Build Operation ID: |f7gvHEfyiSc=.493e0103_
remote: Repository Commit : 4ef4746e4cfc9642383b65ed790dc9b1f10410f2
remote:
remote: Using intermediate directory '/tmp/8d7e0f90d7ebf8a'.
remote:
remote: Copying files to the intermediate directory...
remote: Done in 0 sec(s).
remote:
remote: Source directory : /tmp/8d7e0f90d7ebf8a
remote: Destination directory: /home/site/wwwroot
remote:
remote: Python Version: /opt/python/3.7.5/bin/python3
remote: Python Virtual Environment: antenv
remote: Creating virtual environment ...
remote: .......
remote: Activating virtual environment ...
remote: Could not find requirements.txt; Not running pip install
remote: Done running pip install.
remote:
remote: Compressing existing 'antenv' folder...
remote: Done in 2 sec(s).
remote:
remote: Copying files to destination directory '/home/site/wwwroot'...
remote: Done in 1 sec(s).
remote:
remote: Removing existing manifest file
remote: Creating a manifest file...
remote: Manifest file created.
remote:
remote: Done in 14 sec(s).
remote: Running post deployment command(s)...
remote: Triggering recycle (preview mode disabled).
remote: Deployment successful.
remote: Deployment Logs : 'https://cityweatherbot.scm.azurewebsites.net/newui/jsonviewer?view_url=/api/deployments/4ef4746e4cfc9642383b65ed790dc9b1f10410f2/log'
To https://cityweatherbot.scm.azurewebsites.net:443/cityweatherbot.git

  • [new branch] master -> master

@andrewholler
Copy link
Author

@arroyc Thank you for that information. I eventually figured out that Oryx will only do the building with a local git deployment and that you have to do the environment building in the pipeline when you do a ZIP deployment. Maybe I can update this issue to a feature request that Oryx builds dependencies with ZIP deployments if the venv specified in the Oryx manifest does not exist?

@arroyc
Copy link
Contributor

arroyc commented Apr 15, 2020

@aholler2, thanks for responding … as far as I know there is a feature for that (what you are asking) already and is pending for deployed across app service region in their next update. @sanchitmehta can confirm …

@sidbhat1979 I already responded your issue .. if you don't mind I will close that one as it seems to be duplicate

Please let me know if I can close this issue now

@andrewholler
Copy link
Author

After reading the ZIP deployment documentation that you linked and some experimenting with deployments, you can get Oryx to do the dependency building by setting the app setting SCM_DO_BUILD_DURING_DEPLOYMENT=true. @arroyc Thank you for working through this with me.

@d1pankar
Copy link

d1pankar commented Jul 4, 2023

@aholler2 Adding SCM_DO_BUILD_DURING_DEPLOYMENT=true did not work for me.

I am getting didn't respond to HTTP pings on port: 8000, failing site start error under Application Logs.

The logs says
WARNING: Could not find virtual environment directory /home/site/wwwroot/antenv.
WARNING: Could not find package directory /home/site/wwwroot/__oryx_packages__.
/opt/startup/startup.sh: 23: startup.sh: not found

@sesa529917
Copy link

@aholler2 Adding SCM_DO_BUILD_DURING_DEPLOYMENT=true did not work for me.

I am getting didn't respond to HTTP pings on port: 8000, failing site start error under Application Logs.

The logs says WARNING: Could not find virtual environment directory /home/site/wwwroot/antenv. WARNING: Could not find package directory /home/site/wwwroot/__oryx_packages__. /opt/startup/startup.sh: 23: startup.sh: not found

I'm having exactly the same issue.
SCM_DO_BUILD_DURING_DEPLOYMENT=true seems to have no effect when deploying from a zip of a flask project.

@dhansmair
Copy link

We had the same problem and also the SCM_DO_BUILD_DURING_DEPLOYMENT=true did not help. We finally figured out that our app service is in a virtual network and that the outbound traffic for oryx is blocked. See this tiny paragraph here: https://github.com/microsoft/Oryx/blob/main/doc/hosts/appservice.md#network-dependencies. Also in this case, oryx failed silently and did not show a useful error message that helped us to find the error.

@xxxpsyduck
Copy link

@arroyc This problem still exists in November 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants