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

Build/Debug Python fault scripts - requirements.txt to build infra_agent.tar.gz #104

Open
sneal opened this issue Mar 1, 2022 · 3 comments

Comments

@sneal
Copy link

sneal commented Mar 1, 2022

I'm attempting to use Mangle to inject faults into a BOSH managed VM and I need to debug and modify the Python scripts that are running on the remote VM. The Python fault injection scripts that are dumped onto the VM look to be compiled so I've attempted to clone the repo to the target VM and modify them from there, however that raises the following issues:

  1. The infra_agent.py script gets an error importing the mangleinfraagent module unless I move infra_agent.py to the parent folder so that mangleinfraagent is a subfolder relative to the script.
  2. There's no pip requirements.txt or dependency docs so cloning the repo and attempting to manually run the scripts requires a lot of fail, pip install, try again.
  3. How do I build a new infra_agent.tar.gz? I don't see a build script or manual docs on how to do this.

These appear to be the dependencies required to get the infra_agent to start.

  • psutil
  • distro
  • psycopg2
  • pymongo
  • cassandra-driver
@jayasankarr1990
Copy link

Create bundle for infra_agent using pyinstaller:

We use pyinstaller to bundle the application(https://pyinstaller.readthedocs.io/en/stable/)
Following python dependencies need to be installed on the linux machine where you create the bundle otherwise pyinstaller will throw error
:: psycopg2-binary,cassandra-driver,pymongo,psutil,distro

Steps:
1)Have mangle-infra-agent from mangle repo copied to a folder: .
2)cd to the folder where infra_agent.spec is present in mangle-infra-agent
2)Make changes to Analysis section for the directory paths in infra_agent.spec and infra_submit.spec files.
Run: pyinstaller --paths=/mangle-infra-agent --onedir infra_agent.spec :which creates agent_install bundle "infra_agent" in /dist
4)Create bundle by following the below steps for infra_submit if you have changes in infra_submit package in the project,
other wise follow from step5
a) cd to the folder where infra_submit.spec is present in mangle-infra-agent
run pyinstaller --onefile infra_submit.spec :infra_submit bundle will be created in /dist
b) Now we have infra_agent and infra_submit at different locations.Copy this infrasubmit(single file) to infra_agent bundle(which is a folder) and create a tar out of it.

@sneal
Copy link
Author

sneal commented Mar 3, 2022

I'll give that a try, thanks!

Is there a way to run/test the Python scripts without first running pyinstaller?

@jayasankarr1990
Copy link

jayasankarr1990 commented Mar 4, 2022

Yes.Each of faults present inside mangle/mangle-infra-agent can be run using the main method provided along with the arguements.

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

2 participants