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

Cannot deploy app with "paramiko" as dependency #3277

Open
ali-zakaria opened this issue May 11, 2024 · 5 comments
Open

Cannot deploy app with "paramiko" as dependency #3277

ali-zakaria opened this issue May 11, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@ali-zakaria
Copy link

Describe the bug
Cannot deploy app with "paramiko" as dependency.

Getting this error when running the application

2024-05-12 01:30:04.498689 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save_dict(pickler, obj) | None | None
2024-05-12 01:30:04.498689 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 971, in save_dict | None | None
2024-05-12 01:30:04.498690 Romance Daylight Time | rxh-prod-botmanagerwebapp |      self._batch_setitems(obj.items()) | None | None
2024-05-12 01:30:04.499024 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 997, in _batch_setitems | None | None
2024-05-12 01:30:04.499029 Romance Daylight Time | rxh-prod-botmanagerwebapp |      save(v) | None | None
2024-05-12 01:30:04.499032 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/home/reflexuser/venv/lib/python3.8/site-packages/dill/_dill.py", line 414, in save | None | None
2024-05-12 01:30:04.499033 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save(self, obj, save_persistent_id) | None | None
2024-05-12 01:30:04.499034 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 603, in save | None | None
2024-05-12 01:30:04.499035 Romance Daylight Time | rxh-prod-botmanagerwebapp |      self.save_reduce(obj=obj, *rv) | None | None
2024-05-12 01:30:04.499036 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 717, in save_reduce | None | None
2024-05-12 01:30:04.499036 Romance Daylight Time | rxh-prod-botmanagerwebapp |      save(state) | None | None
2024-05-12 01:30:04.499036 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/home/reflexuser/venv/lib/python3.8/site-packages/dill/_dill.py", line 414, in save | None | None
2024-05-12 01:30:04.499037 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save(self, obj, save_persistent_id) | None | None
2024-05-12 01:30:04.499037 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 560, in save | None | None
2024-05-12 01:30:04.499038 Romance Daylight Time | rxh-prod-botmanagerwebapp |      f(self, obj)  # Call unbound method with explicit self | None | None
2024-05-12 01:30:04.499038 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/home/reflexuser/venv/lib/python3.8/site-packages/dill/_dill.py", line 1217, in save_module_dict | None | None
2024-05-12 01:30:04.499039 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save_dict(pickler, obj) | None | None
2024-05-12 01:30:04.499039 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 971, in save_dict | None | None
2024-05-12 01:30:04.499040 Romance Daylight Time | rxh-prod-botmanagerwebapp |      self._batch_setitems(obj.items()) | None | None
2024-05-12 01:30:04.499040 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 997, in _batch_setitems | None | None
2024-05-12 01:30:04.499041 Romance Daylight Time | rxh-prod-botmanagerwebapp |      save(v) | None | None
2024-05-12 01:30:04.499041 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/home/reflexuser/venv/lib/python3.8/site-packages/dill/_dill.py", line 414, in save | None | None
2024-05-12 01:30:04.499042 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save(self, obj, save_persistent_id) | None | None
2024-05-12 01:30:04.499042 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 578, in save | None | None
2024-05-12 01:30:04.499043 Romance Daylight Time | rxh-prod-botmanagerwebapp |      rv = reduce(self.proto) | None | None
2024-05-12 01:30:04.499043 Romance Daylight Time | rxh-prod-botmanagerwebapp |  TypeError: cannot pickle 'cryptography.hazmat.bindings._rust.openssl.rsa.RSAPrivateKey' object | None | None

To Reproduce

Deploy application with this requirement.txt

reflex==0.4.9
cryptography==42.0.7
paramiko==3.4.0

Expected behavior
Application should run like in localhost:3000 mode

Specifics (please complete the following information):

  • Python Version: 3.8.10
  • Reflex Version: 0.4.9
  • OS: Windows 10
  • Browser (Optional): Chrome
@ali-zakaria
Copy link
Author

ali-zakaria commented May 12, 2024

Work-around: Use subprocess and native ssh instead of paramiko

        cmd = 'ssh -o StrictHostKeyChecking=accept-new -i "%s" %s@%s "%s"' % (ssh.server.pkeyPath, ssh.server.username, ssh.server.hostname, cmd_to_execute)
        p = subprocess.Popen(cmd,
                           shell=True,
                           stdout=subprocess.PIPE,
                           stderr=subprocess.PIPE)
        ssh_stdout, ssh_stderr = p.communicate()

@masenf
Copy link
Collaborator

masenf commented May 12, 2024

Are you keeping any ssh related objects in the State? That pickling error is coming from reflex trying to pickle the state for redis (prod mode)

@Lendemor Lendemor added the bug Something isn't working label May 13, 2024
@ali-zakaria
Copy link
Author

Yes I am reading a bench of ssh keys stored in text files and creating paramiko.RSAKey objects at initialization and keeping it in a dict

@masenf
Copy link
Collaborator

masenf commented May 20, 2024

Are the SSH keys per user of the app or are they shared among users of the app?

@ali-zakaria
Copy link
Author

The goal of the app is to manage ~100 servers. Each server RSA key is stored as plain text in App's server uploaded_files/ folder (self hosting)

Users (administrators of the servers) log to the app and choose the server they want to configure from a dropdown menu, at this point, the app reads the RSA key and opens an SSH connection to the chosen server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants