typesafehub / conductr-cli

CLI for Lightbend ConductR
Other
16 stars 21 forks source link

Ensure PyInstaller path is cleaned up from ConductR Agent environment variables #458

Closed fsat closed 7 years ago

fsat commented 7 years ago

Remove PyInstaller path from PATH and LD_LIBRARY_PATH when starting ConductR Agent.

Failing to do this may cause incompatible version of .so being loaded when starting a bundle, causing bundle startup script to fail.

fsat commented 7 years ago

Fixes #457

fsat commented 7 years ago

Manual test is completed successfully.

Setup

Scenario: Sandbox run

Reboot the machine, then start the sandbox which completes successfully.

fsat@fsat-VirtualBox:~/workspace/cli-troubleshoot/ansible-compile$ ./sandbox run 2.1.0-alpha.4
|------------------------------------------------|
| Stopping ConductR                              |
|------------------------------------------------|
ConductR core pid 3099 stopped
ConductR agent pid 3178 stopped
ConductR has been successfully stopped
|------------------------------------------------|
| Starting ConductR                              |
|------------------------------------------------|
Retrieving https://dl.bintray.com/lightbend/generic/conductr-2.1.0-alpha.4-Linux-amd64.tgz
[#################################################] 100%
Retrieving https://dl.bintray.com/lightbend/generic/conductr-agent-2.1.0-alpha.4-Linux-amd64.tgz
[#################################################] 100%
Extracting ConductR core to /home/fsat/.conductr/images/core
Extracting ConductR agent to /home/fsat/.conductr/images/agent
Starting ConductR core instance on 192.168.10.1..
Waiting for ConductR to start..
Starting ConductR agent instance on 192.168.10.1..
|------------------------------------------------|
| Starting logging feature based on eslite       |
|------------------------------------------------|
Deploying bundle eslite..
Retrieving bundle..
Loading bundle from cache typesafe/bundle/eslite
Retrieving from cache /home/fsat/.conductr/cache/bundle/eslite-v1-7dc78f8c80474dc7ff4cabbdf5b5ce386cdebc3bd52693601bd2383dfb4e86be.zip
Loading bundle to ConductR..
[#################################################] 100%
Bundle 7dc78f8c80474dc7ff4cabbdf5b5ce38 is installed
Bundle loaded.
Bundle run request sent.
Bundle 7dc78f8c80474dc7ff4cabbdf5b5ce38 waiting to reach expected scale 1
Bundle 7dc78f8c80474dc7ff4cabbdf5b5ce38 has scale 0, expected 1...
Bundle 7dc78f8c80474dc7ff4cabbdf5b5ce38 expected scale 1 is met
|------------------------------------------------|
| Summary                                        |
|------------------------------------------------|
|- - - - - - - - - - - - - - - - - - - - - - - - |
| ConductR                                       |
|- - - - - - - - - - - - - - - - - - - - - - - - |
ConductR has been started:
  core instance on 192.168.10.1
  agent instance on 192.168.10.1
ConductR service locator has been started on:
  192.168.10.1:9008
|- - - - - - - - - - - - - - - - - - - - - - - - |
| Proxy                                          |
|- - - - - - - - - - - - - - - - - - - - - - - - |
HAProxy has not been started
To enable proxying ensure Docker is running and restart the sandbox
|- - - - - - - - - - - - - - - - - - - - - - - - |
| Bundles                                        |
|- - - - - - - - - - - - - - - - - - - - - - - - |
Check latest bundle status with:
  conduct info
Current bundle status:
UNLICENSED - please use "conduct load-license" to use more agents. Additional agents are freely available for registered users.
Licensed To: unknown
Max ConductR agents: 1
ConductR Version(s): 2.1.*
Grants: conductr, cinnamon, akka-sbr

ID       NAME    TAG  #REP  #STR  #RUN  ROLES
7dc78f8  eslite          1     0     1  elasticsearch

With this PR, the LD_LIBRARY_PATH which contains sys._MEIPASS by default is now removed. This would allow bundles to start as expected. Without the change in this PR (i.e. with the presence of LD_LIBRARY_PATH which contains sys._MEIPASS), even eslite bundle will fail to start.

fsat@fsat-VirtualBox:~/workspace/cli-troubleshoot/ansible-compile$ ps -ef | grep -i ConductRAgent
fsat      3579     1 14 13:51 ?        00:00:13 java -javaagent:/home/fsat/.conductr/images/agent/bin/../cinnamon/cinnamon-agent-2.3.1.jar -Djava.library.path=/home/fsat/.conductr/images/agent/lib/sigar -server -Xms105m -Xmx128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/home/fsat/.conductr/images/tmp -Dakka.loglevel=info -Dconductr.agent.ip=192.168.10.1 -Dcontrail.syslog.server.port=9200 -Dcontrail.syslog.server.elasticsearch.enabled=on -cp /home/fsat/.conductr/images/agent/lib/../conductr-agent-assembly-2.1.0-alpha.4.jar com.typesafe.conductr.agent.ConductrAgent --core-node 192.168.10.1:9004
fsat      3794  2134  0 13:52 pts/6    00:00:00 grep --color=auto -i ConductRAgent

fsat@fsat-VirtualBox:~/workspace/cli-troubleshoot/ansible-compile$ cat /proc/3579/environ
XDG_SESSION_ID=1SSL_CERT_FILE=/tmp/_MEIVPg24X/lib/cert.pemTERM=xterm-256colorSHELL=/bin/bashSSH_CLIENT=10.0.2.2 56607 22SSH_TTY=/dev/pts/6USER=fsatLS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:PATH=/home/fsat/.conductr/images/agent/bin:/home/fsat/bin:/home/fsat/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binMAIL=/var/mail/fsatQT_QPA_PLATFORMTHEME=appmenu-qt5PWD=/home/fsat/.conductr/images/agentLANG=en_AU.UTF-8HOME=/home/fsatSHLVL=1LANGUAGE=en_AU:enLOGNAME=fsatSSH_CONNECTION=10.0.2.2 56607 10.0.2.15 22LESSOPEN=| /usr/bin/lesspipe %sXDG_RUNTIME_DIR=/run/user/1000LESSCLOSE=/usr/bin/les

Scenario: Sandbox run with custom LD_LIBRARY_PATH

Start the sandbox with custom LD_LIBRARY_PATH specified on agent's environment variable.

The custom LD_LIBRARY_PATH points to /tmp/foo which is a non-existent path - this is harmless (i.e. as in has no effect) since no .so will be loaded.

fsat@fsat-VirtualBox:~/workspace/cli-troubleshoot/ansible-compile$ ./sandbox run 2.1.0-alpha.4 --env-agent "LD_LIBRARY_PATH=/tmp/foo"
|------------------------------------------------|
| Stopping ConductR                              |
|------------------------------------------------|
ConductR core pid 3500 stopped
ConductR agent pid 3579 stopped
ConductR has been successfully stopped
|------------------------------------------------|
| Starting ConductR                              |
|------------------------------------------------|
Extracting ConductR core to /home/fsat/.conductr/images/core
Extracting ConductR agent to /home/fsat/.conductr/images/agent
Starting ConductR core instance on 192.168.10.1..
Waiting for ConductR to start..
Starting ConductR agent instance on 192.168.10.1..
|------------------------------------------------|
| Starting logging feature based on eslite       |
|------------------------------------------------|
Deploying bundle eslite..
Retrieving bundle..
Loading bundle from cache typesafe/bundle/eslite
Retrieving from cache /home/fsat/.conductr/cache/bundle/eslite-v1-7dc78f8c80474dc7ff4cabbdf5b5ce386cdebc3bd52693601bd2383dfb4e86be.zip
Loading bundle to ConductR..
[#################################################] 100%
Bundle 7dc78f8c80474dc7ff4cabbdf5b5ce38 is installed
Bundle loaded.
Bundle run request sent.
Bundle 7dc78f8c80474dc7ff4cabbdf5b5ce38 waiting to reach expected scale 1
Bundle 7dc78f8c80474dc7ff4cabbdf5b5ce38 has scale 0, expected 1...
Bundle 7dc78f8c80474dc7ff4cabbdf5b5ce38 expected scale 1 is met
|------------------------------------------------|
| Summary                                        |
|------------------------------------------------|
|- - - - - - - - - - - - - - - - - - - - - - - - |
| ConductR                                       |
|- - - - - - - - - - - - - - - - - - - - - - - - |
ConductR has been started:
  core instance on 192.168.10.1
  agent instance on 192.168.10.1
ConductR service locator has been started on:
  192.168.10.1:9008
|- - - - - - - - - - - - - - - - - - - - - - - - |
| Proxy                                          |
|- - - - - - - - - - - - - - - - - - - - - - - - |
HAProxy has not been started
To enable proxying ensure Docker is running and restart the sandbox
|- - - - - - - - - - - - - - - - - - - - - - - - |
| Bundles                                        |
|- - - - - - - - - - - - - - - - - - - - - - - - |
Check latest bundle status with:
  conduct info
Current bundle status:
UNLICENSED - please use "conduct load-license" to use more agents. Additional agents are freely available for registered users.
Licensed To: unknown
Max ConductR agents: 1
ConductR Version(s): 2.1.*
Grants: conductr, cinnamon, akka-sbr

ID       NAME    TAG  #REP  #STR  #RUN  ROLES
7dc78f8  eslite          1     0     1  elasticsearch

The custom LD_LIBRARY_PATH is propagated to agent's process.

fsat@fsat-VirtualBox:~/workspace/cli-troubleshoot/ansible-compile$ ps -ef | grep -i ConductRAgent
fsat      3975     1 29 13:53 ?        00:00:12 java -javaagent:/home/fsat/.conductr/images/agent/bin/../cinnamon/cinnamon-agent-2.3.1.jar -Djava.library.path=/home/fsat/.conductr/images/agent/lib/sigar -server -Xms105m -Xmx128m -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/home/fsat/.conductr/images/tmp -Dakka.loglevel=info -Dconductr.agent.ip=192.168.10.1 -Dcontrail.syslog.server.port=9200 -Dcontrail.syslog.server.elasticsearch.enabled=on -cp /home/fsat/.conductr/images/agent/lib/../conductr-agent-assembly-2.1.0-alpha.4.jar com.typesafe.conductr.agent.ConductrAgent --core-node 192.168.10.1:9004
fsat      4148  2134  0 13:53 pts/6    00:00:00 grep --color=auto -i ConductRAgent

fsat@fsat-VirtualBox:~/workspace/cli-troubleshoot/ansible-compile$ cat /proc/3975/environ
XDG_SESSION_ID=1SSL_CERT_FILE=/tmp/_MEIFQb63o/lib/cert.pemTERM=xterm-256colorSHELL=/bin/bashSSH_CLIENT=10.0.2.2 56607 22SSH_TTY=/dev/pts/6USER=fsatLD_LIBRARY_PATH=/tmp/fooLS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:MAIL=/var/mail/fsatPATH=/home/fsat/.conductr/images/agent/bin:/home/fsat/bin:/home/fsat/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binQT_QPA_PLATFORMTHEME=appmenu-qt5PWD=/home/fsat/.conductr/images/agentLANG=en_AU.UTF-8SHLVL=1HOME=/home/fsatLANGUAGE=en_AU:enLOGNAME=fsatSSH_CONNECTION=10.0.2.2 56607 10.0.2.15 22LESSOPEN=| /usr/bin/lesspipe %sXDG_RUNTIME_DIR=/run/user/10
fsat commented 7 years ago

Add conductr_cli/test/test_pyinstaller_info.py which was missed by earlier commit.