-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
Fix mac install #4145
Fix mac install #4145
Conversation
While I like the PR, this would make people develop on mac and not use docker dev env. I guess choice is good. The other thing is we had issues with eventlet monkey patching and OS X filesystem (case preserving but insensitive - cat CAT.txt and cat cat.txt are equivalent but you could create both the files IIRC). So OS X is a gray area. |
Basically, see if all unit tests pass and lanuchdev.sh works ok. That's a good starting point for sanity on OS X. |
@lakshmi-kannan You raise good points, but I think devs will switch to the docker dev env since that seems to consistently work better for coding. However, this is still useful for non-code dev work, like documentation fixes, on OS X. From #3934: LindsayHill:
tonybaloney:
|
3ffadb5
to
430f0cc
Compare
It seems to me that it would be fair to add a note during virtualenv-osx creation to let user know that OSX is not officially supported at that point and the results he'll get by running st2 in OSX may not represent of what he will get in linux (false positives\negatives in tests that will later are going to came during CI, problems related to default case-insensitive behavior of HFS+, outdated native dependencies and so on). I agree that user should be able to do some development on osx. I also believe that the problems with osx compatibility should be uncovered and eventually resolved even though our main focus continues to be in linux env. |
1d72967
to
51ea365
Compare
c955466
to
5462034
Compare
cbf3f91
to
cc9fd8d
Compare
@@ -0,0 +1,325 @@ | |||
# Copyright 2014 Koert van der Veer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of that, I assume this failed is based on logshipper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, how hard would it be / would it make sense to contribute those changes upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I copied and pasted that file out of logshipper. Both StackStorm and logshipper are licensed under the Apache 2.0 license though, so there shouldn't be a legal issue.
Upstream logshipper hasn't been updated in 3-4 years. The author hasn't responded to any issues or pull requests in that long, and the last commit was on Mar 23, 2015. I would be happy to upstream this if I thought it had a chance to get merged, but I don't think the original author is interested in the project anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, I would prefer to split out / re-organize the code so it's easy to see which code is original and which is our modifications.
I know that might not be possible though, or at least not easily.
98d3c64
to
7171608
Compare
@@ -81,8 +88,12 @@ configgen: requirements .configgen | |||
echo "" >> conf/st2.conf.sample | |||
. $(VIRTUALENV_DIR)/bin/activate; python ./tools/config_gen.py >> conf/st2.conf.sample; | |||
|
|||
.PHONY: .install-pika | |||
.install-pika: | |||
$(VIRTUALENV_DIR)/bin/pip install --upgrade pika |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we installing pika when we have kombu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tools/direct_queue_publisher.py
imports pika
, and that was messing up the pylint check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't even use that tool. Maybe switch that tool to use kombu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use it, but how is this a new problem? Should have been caught previously. Kombu installs pika as a dep. Should still work if venv is set up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't use that tool we should just remove it entirely. I'm also not entirely sure why any of my changes caused pylint to check (and then complain) about this file when it wasn't doing it before, but ¯\_(ツ)_/¯.
I added this quick hack because without it the Travis tests were failing due to pylint complaining that pika
wasn't installed.
On a brand new OS X, make requirements fails
|
# download anything | ||
@if [[ "$(OS)" == "Darwin" ]]; then \ | ||
if [[ ! -f $(VIRTUALENV_DIR)/bin/activate ]]; then \ | ||
virtualenv --python=$(PYTHON_VERSION) --no-site-packages --no-setuptools --never-download $(VIRTUALENV_DIR); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd install pip first and then virtualenv because stock OS X doesn't come with neither. We can also assume people have pip and virtualenv installed in which case you should just check if they exist and if not ask user to install those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The situation here is a little more complicated. This code actually does assume that the user has some version of virtualenv installed, and the most common way to install virtualenv is with pip, so if users have virtualenv, they probably also have a version of pip.
The issue with pip on OS X is that you might run into this issue, where you need a recent version of pip to install or upgrade anything including pip itself. So if you have a version of pip that is out of date, you cannot use it to do anything.
The problem is that you need to install a recent version of pip into the virtualenv, but you cannot use pip to do it. The method I use to install/upgrade pip here is pretty bulletproof (although it its a little scary from a security perspective) and is an official way to install pip.
tools/launchdev.sh
Outdated
else | ||
VIRTUALENV_DIR=virtualenv | ||
fi | ||
VENV=${ST2_REPO}/${VIRTUALENV_DIR} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you set ST2_REPO to ${PWD} if ST2_REPO is not set? Otherwise, I end up with
tools/launchdev.sh: line 223: /virtualenv-osx/bin/activate: No such file or directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Done (I think): https://github.com/StackStorm/st2/pull/4145/files#diff-b4e17371e9e3b263027f6a393d3bd772R9
Makefile
Outdated
@@ -1,7 +1,14 @@ | |||
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | |||
SHELL := /bin/bash | |||
TOX_DIR := .tox | |||
VIRTUALENV_DIR ?= virtualenv | |||
OS := $(shell uname) | |||
# We separate the OSX X and Linux virtualenvs so we can run in a Docker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is pretty simple and yet clever :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -81,8 +88,12 @@ configgen: requirements .configgen | |||
echo "" >> conf/st2.conf.sample | |||
. $(VIRTUALENV_DIR)/bin/activate; python ./tools/config_gen.py >> conf/st2.conf.sample; | |||
|
|||
.PHONY: .install-pika | |||
.install-pika: | |||
$(VIRTUALENV_DIR)/bin/pip install --upgrade pika |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't even use that tool. Maybe switch that tool to use kombu?
2367f4d
to
d05ef85
Compare
I tried checkout out this branch, recreating the virtualen environment to make sure requirements are up to date and starting the sensor, but I get the following error on Linux - https://gist.github.com/Kami/8972f8da8dfedb9eb1269f1612cca78f I would imagine it's probably related to eventlet select module monkey patch. I thought it's maybe related to code change in https://github.com/StackStorm/st2/pull/4118/files, but even if I remove those changes I get the same error locally. |
I could get it to work if I removed eventlet monkey patch (but only partially since it immediately crashed after the file was modified). To get this to work, we have a couple of options:
I'm personally not a big fan of 2) approach, we already have more hacks / workarounds than we would like to have. So with the pyinotify working out of the box, I wonder if those changes are still good idea if we can't get it to work with 1). |
Here is a list of two different changes with which I could get the sensor to start:
diff --git a/st2reactor/st2reactor/container/sensor_wrapper.py b/st2reactor/st2reactor/container/sensor_wrapper.py
index dfcc7ab2e..36bad6acf 100644
--- a/st2reactor/st2reactor/container/sensor_wrapper.py
+++ b/st2reactor/st2reactor/container/sensor_wrapper.py
@@ -46,8 +46,8 @@ __all__ = [
'SensorService'
]
-monkey_patch()
-use_select_poll_workaround(nose_only=False)
+#monkey_patch()
+#use_select_poll_workaround(nose_only=False)
class SensorService(object):
diff --git a/st2common/st2common/util/monkey_patch.py b/st2common/st2common/util/monkey_patch.py
index b83d74a4f..38435868d 100644
--- a/st2common/st2common/util/monkey_patch.py
+++ b/st2common/st2common/util/monkey_patch.py
@@ -77,7 +77,9 @@ def use_select_poll_workaround(nose_only=True):
if not nose_only or (nose_only and'nose' in sys.modules.keys()):
# Add back blocking poll() to eventlet monkeypatched select
original_poll = eventlet.patcher.original('select').poll
+ original_epoll = eventlet.patcher.original('select').epoll
select.poll = original_poll
+ select.epoll = original_epoll
sys.modules['select'] = select
subprocess.select = select As mentioned above, I'm not a huge fan of another workaround, especially because pyinotify code worked out of the box. My main question with those code changes is what do we gain over the previous approach if we still need to maintain a fork (this time the code is inside this repo and not inside another one, not any better, imo) and we need additional hacks / workarounds. |
Also, would it be possible to split file watch changes in a separate branch / PR? This way we could review OS X changes independently and hopefully get them merged faster. |
As far as mac changes go - can we also add some tests for that? Travis CI supports osx OS so we should add some checks tests / checks, if possible. |
Travis CI supports Python and it supports Mac, but it doesn't natively support Python on Mac. There are some ways to do it, but we don't support running ST2 itself or tests on OS X, so I don't know what that would buy us. |
As discussed in slack - I'm generally -1 on this change primarily because of two things. The additions to the Don't consider this comment a blocker, just me voicing my concern. I'm generally +1 to the linux tail change. |
ef44d7c
to
f0f295f
Compare
Fixes some things on Mac by creating a separate virtualenv in
virtualenv-osx
, so you can run stuff in a (Linux) docker container and still do stuff in OS X.I will try to include a fix for #3934 by implementing #3785 before this PR is ready.Done.Also (for now) includes the additional logging from #4141.Reviewers: please check the changes to the relative virtualenv path in
tools/launchdev.sh
, as I'm not 100% sure where that command is supposed to be run from. This PR changes the virtualenv to thevirtualenv
directory at the root of the repo, because that's what makes the most sense to me.Also, my implementation intail.py
works, but I'm not sure if it's the most optimal threading model.Fixed. It now useseventlet
greenthreads and a greenpool.Handled in #4191.