PermissionError when running C binary that reads and writes files
See original GitHub issueI have create an Azure Python Function that uses PuLP to solve linear problems. This library creates a problem file in /tmp and then calls a C binary (included in the PuLP package in site-packages) to solve the problem. This binary writes a file to /tmp with the result. The C binary throws a permission error, and I believe it has to do with writing the result file.
It works locally on my Windows PC, and I was also able to run the code on the docker image mcr.microsoft.com/azure-functions/python:2.0 (with root access). When I publish to Azure Functions and run the function, I receive a PermissionError:
Request was invalid: Traceback (most recent call last):
File "/home/site/wwwroot/func_solve/__init__.py", line 19, in main
solution = solve(goal, variables, constraints)
File "/home/site/wwwroot/library/solver.py", line 43, in solve
problem.solve()
File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/pulp.py", line 1671, in solve
status = solver.actualSolve(self, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solvers.py", line 1367, in actualSolve
return self.solve_CBC(lp, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solvers.py", line 1427, in solve_CBC
cbc = subprocess.Popen(args, stdout = pipe, stderr = pipe)
File "/usr/local/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solverdir/cbc/linux/64/cbc'Request was invalid: Traceback (most recent call last):
File "/home/site/wwwroot/func_solve/__init__.py", line 19, in main
solution = solve(goal, variables, constraints)
File "/home/site/wwwroot/library/solver.py", line 43, in solve
problem.solve()
File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/pulp.py", line 1671, in solve
status = solver.actualSolve(self, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solvers.py", line 1367, in actualSolve
return self.solve_CBC(lp, **kwargs)
File "/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solvers.py", line 1427, in solve_CBC
cbc = subprocess.Popen(args, stdout = pipe, stderr = pipe)
File "/usr/local/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/home/site/wwwroot/.python_packages/lib/python3.6/site-packages/pulp/solverdir/cbc/linux/64/cbc'
I have verified that there is execution permission to the binary.
Does the binary have restricted permissions? Is it not valid to write files to the disk?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top GitHub Comments
I am having the same issue, so I tried to use custom image instead, based on this article https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image
This did solve the issue and I were able to use PuLP on both premium plan and dedicated plan.
But I did not do any real changes to the image except install dependencies and create a http endpoint. Should this not behave the same way as the image used in the consumption plan ?
As pointed out, the workaround is to use custom container. Please reopen if you feel the issue is not yet solved