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

deploy: import prod_* with absolute_import #287

Closed
wants to merge 1 commit into from

Conversation

tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Aug 7, 2021

so we are able to load the python modules located in the same directory
and be python2 compatible.

Fixes #286
Signed-off-by: Kefu Chai [email protected]

so we are able to load the python modules located in the same directory
and be python2 compatible.

Fixes ceph#286
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov tchaikov requested review from djgalloway and ktdreyer August 7, 2021 09:49
@hjwsm1989
Copy link

no luck, still failed with

TASK [common : ensure chacra is enabled and running] *****************************************************************************************************************************
task path: /opt/chacra/src/chacra/deploy/playbooks/roles/common/tasks/systemd.yml:33
fatal: [chacra1.xsky.com]: FAILED! => {"changed": false, "msg": "Unable to start service chacra: A dependency job for chacra.service failed. See 'journalctl -xe' for details.\n"}

journalctl -xe outputs

Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/__main__.py", line 54, in <module>
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     main()
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/__main__.py", line 30, in main
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     main()
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/bin/celery.py", line 81, in main
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     cmd.execute_from_commandline(argv)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/bin/celery.py", line 793, in execute_from_commandline
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     super(CeleryCommand, self).execute_from_commandline(argv)))
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/bin/base.py", line 309, in execute_from_commandline
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     argv = self.setup_app_from_commandline(argv)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/bin/base.py", line 469, in setup_app_from_commandline
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     self.app = self.find_app(app)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/bin/base.py", line 489, in find_app
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     return find_app(app, symbol_by_name=self.symbol_by_name)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/app/utils.py", line 235, in find_app
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     sym = symbol_by_name(app, imp=imp)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/bin/base.py", line 492, in symbol_by_name
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     return symbol_by_name(name, imp=imp)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/kombu/utils/__init__.py", line 100, in symbol_by_name
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     sys.exc_info()[2])
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/kombu/utils/__init__.py", line 96, in symbol_by_name
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     module = imp(module_name, package=package, **kwargs)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/celery/utils/imports.py", line 101, in import_from_cwd
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     return imp(module, package=package)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     __import__(name)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/src/chacra/chacra/async/__init__.py", line 74, in <module>
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     bootstrap_pecan(None, None)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/src/chacra/chacra/async/__init__.py", line 57, in bootstrap_pecan
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     pecan.configuration.set_config(config_path, overwrite=True)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/pecan/configuration.py", line 252, in set_config
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     config = conf_from_file(config)
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/lib/python2.7/site-packages/pecan/configuration.py", line 182, in conf_from_file
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     *imp.find_module(module_name, [basepath])
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:   File "/opt/chacra/src/chacra/prod.py", line 9, in <module>
Aug 07 13:54:05 chacra1.xsky.com celery[24548]:     from .prod_db import sqlalchemy
Aug 07 13:54:05 chacra1.xsky.com celery[24548]: ValueError: Couldn't import 'async': Attempted relative import in non-package
Aug 07 13:54:05 chacra1.xsky.com celery[24548]: celery multi v3.1.26.post2 (Cipater)

@tchaikov
Copy link
Contributor Author

tchaikov commented Aug 7, 2021

seems we always need to add the path to sys.path or to PYTHONPATH.

@tchaikov tchaikov closed this Aug 7, 2021
@tchaikov tchaikov deleted the wip-reploy-import branch August 7, 2021 14:41
@hjwsm1989
Copy link

yes, i tested

--- a/deploy/playbooks/roles/common/templates/prod.py.j2
+++ b/deploy/playbooks/roles/common/templates/prod.py.j2
@@ -1,4 +1,7 @@
 # {{ ansible_managed }}
+import sys
+sys.path.append("{{ app_home }}/src/{{ app_name }}")
+
 from pecan.hooks import TransactionHook
 from chacra import models
 from chacra import hooks

it passed and finally setup chacra service

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

Successfully merging this pull request may close these issues.

deploy chacra failed
2 participants