{"action":"closed","issue":{"url":"https://api.github.com/repos/StackStorm/st2/issues/4181","repository_url":"https://api.github.com/repos/StackStorm/st2","labels_url":"https://api.github.com/repos/StackStorm/st2/issues/4181/labels{/name}","comments_url":"https://api.github.com/repos/StackStorm/st2/issues/4181/comments","events_url":"https://api.github.com/repos/StackStorm/st2/issues/4181/events","html_url":"https://github.com/StackStorm/st2/issues/4181","id":333709576,"node_id":"MDU6SXNzdWUzMzM3MDk1NzY=","number":4181,"title":"Packs.setup_virtualenv edge case when a sensor is running already.","user":{"login":"NikosVlagoidis","id":10330520,"node_id":"MDQ6VXNlcjEwMzMwNTIw","avatar_url":"https://avatars1.githubusercontent.com/u/10330520?v=4","gravatar_id":"","url":"https://api.github.com/users/NikosVlagoidis","html_url":"https://github.com/NikosVlagoidis","followers_url":"https://api.github.com/users/NikosVlagoidis/followers","following_url":"https://api.github.com/users/NikosVlagoidis/following{/other_user}","gists_url":"https://api.github.com/users/NikosVlagoidis/gists{/gist_id}","starred_url":"https://api.github.com/users/NikosVlagoidis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NikosVlagoidis/subscriptions","organizations_url":"https://api.github.com/users/NikosVlagoidis/orgs","repos_url":"https://api.github.com/users/NikosVlagoidis/repos","events_url":"https://api.github.com/users/NikosVlagoidis/events{/privacy}","received_events_url":"https://api.github.com/users/NikosVlagoidis/received_events","type":"User","site_admin":false},"labels":[{"id":412096124,"node_id":"MDU6TGFiZWw0MTIwOTYxMjQ=","url":"https://api.github.com/repos/StackStorm/st2/labels/status:need%20more%20info","name":"status:need more info","color":"7b5804","default":false},{"id":300968911,"node_id":"MDU6TGFiZWwzMDA5Njg5MTE=","url":"https://api.github.com/repos/StackStorm/st2/labels/status:to%20be%20verified","name":"status:to be verified","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-06-19T14:55:31Z","updated_at":"2018-06-22T19:35:23Z","closed_at":"2018-06-22T19:35:23Z","author_association":"CONTRIBUTOR","body":"##### SUMMARY\r\n\r\nThere is an edge case when you use packs.setup_virtualenv and a sensor from the pack is running and using a file from the virtualenv. \r\nI know this is not the use of setup_virtualenv action but I guess the action should check if a sensor is running and prevent the partial deletion of the virtualenv.\r\nAlso I found that you can use packs.update_virtualenv in the first place. \r\n\r\n##### ISSUE TYPE\r\nPick one below and delete the rest:\r\n - Bug Report *\r\n - Feature Idea\r\n - Other\r\n\r\n##### STACKSTORM VERSION\r\nPaste the output of `st2 --version`:\r\nst2 2.7.2, on Python 2.7\r\n\r\n##### OS / ENVIRONMENT / INSTALL METHOD\r\n\r\nDocker \r\n\r\n##### STEPS TO REPRODUCE\r\n\r\n\r\n1. Have a sensor from a pack called pack_name running using a python package from the virtualenv.\r\n2. Try running `st2  run packs.setup_virtualenv pack_name`\r\n3. Try to run an action from this pack\r\n\r\n\r\n##### EXPECTED RESULTS\r\n\r\nThe action should prevent from deleting half the virtualenv.\r\n\r\n##### ACTUAL RESULTS\r\n\r\nStack trace from setup_virtualenv:\r\n```\r\nst2.actions.python.SetupVirtualEnvironmentAction: DEBUG    Setting up virtualenv for pack \"pack_name\" (/opt/stackstorm/packs.dev/pack_name)\r\nst2.actions.python.SetupVirtualEnvironmentAction: DEBUG    Removing virtualenv in \"/opt/stackstorm/virtualenvs/pack_name\"\r\nst2.actions.python.SetupVirtualEnvironmentAction: ERROR    Error while removing virtualenv at \"/opt/stackstorm/virtualenvs/pack_name\": \"[Errno 39] Directory not empty: '/opt/stackstorm/virtualenvs/pack_name/bin'\"Traceback (most recent call last):\r\n  File \"/opt/stackstorm/runners/python_runner/python_runner/python_action_wrapper.py\", line 320, in <module>\r\n    obj.run()\r\n  File \"/opt/stackstorm/runners/python_runner/python_runner/python_action_wrapper.py\", line 179, in run\r\n    output = action.run(**self._parameters)\r\n  File \"/opt/stackstorm/packs/packs/actions/pack_mgmt/setup_virtualenv.py\", line 89, in run\r\n    no_download=no_download)\r\n  File \"/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/util/virtualenvs.py\", line 88, in setup_pack_virtualenv\r\n    remove_virtualenv(virtualenv_path=virtualenv_path, logger=logger)\r\n  File \"/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/util/virtualenvs.py\", line 215, in remove_virtualenv\r\n    raise e\r\nOSError: [Errno 39] Directory not empty: '/opt/stackstorm/virtualenvs/pack_name/bin'\r\n```\r\n\r\nStack trace from running an action from the pack after the previous action:\r\n\r\n```\r\n[Errno 2] No such file or directory\r\n  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2actions/container/base.py\", line 119, in _do_run\r\n    (status, result, context) = runner.run(action_params)\r\n  File \"/opt/stackstorm/runners/python_runner/python_runner/python_runner.py\", line 263, in run\r\n    stdin_value=stdin_params)\r\n  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/util/green/shell.py\", line 109, in run_command\r\n    env=env, cwd=cwd, shell=shell, preexec_fn=preexec_func)\r\n  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/eventlet/green/subprocess.py\", line 58, in __init__\r\n    subprocess_orig.Popen.__init__(self, args, 0, *argss, **kwds)\r\n  File \"/usr/lib/python2.7/subprocess.py\", line 710, in __init__\r\n    errread, errwrite)\r\n  File \"/usr/lib/python2.7/subprocess.py\", line 1327, in _execute_child\r\n    raise child_exception\r\n\r\n```"}}
{"actor":{"display_login":"LindsayHill"}}