Closed csplinter closed 8 years ago
There are certain cases where os.path.join('~','fab','dse')
would't work. One case that I can think of is if such a path is passed to the JVM as a parameter. What if we instead use the $HOME variable?
Using $HOME fails here
[testcluster-01] run: ln -sfn ~/fab/dse_builds/dse-5.0.0 $HOME/fab/dse
[testcluster-01] download: <file obj> <- /home/cstar/$HOME/fab/dse/resources/cassandra/conf/cassandra.yaml
Fatal error: get() encountered an exception while downloading '/home/cstar/$HOME/fab/dse/resources/cassandra/conf/cassandra.yaml'
Underlying exception:
No such file
Aborting.
This issue with using environment variables in the path appears to be specific to using the fab.get and fab.put commands
I chose to add a local option to our get_dse_path and get_cassandra_path
fab_cassandra.py
def get_cassandra_path(local=True):
return os.path.expanduser('~/fab/cassandra') if local else os.path.join(fab.run('pwd'), 'fab', 'cassandra')
def get_bin_path(local=True):
return os.path.join(get_cassandra_path(local=local), 'bin')
fab_dse.py
def get_dse_path(local=True):
return os.path.expanduser("~/fab/dse") if local else os.path.join(fab.run('pwd'), 'fab', 'dse')
def get_dse_conf_path(local=True):
return os.path.join(get_dse_path(local=local), 'resources', 'dse', 'conf')
def get_cassandra_path(local=True):
return os.path.join(get_dse_path(local=local), 'resources', 'cassandra')
The behavior here with the fabric.operations.get function
download: <file obj> <- /home/cstar/$HOME/fab/dse/resources/cassandra/conf/cassandra.yaml
Is caused by the fact that they are joining home = ftp.normalize('.')
with the remote_path
. In our case, the home is /home/cstar
and the remote path is $HOME/fab/dse/resources/cassandra/conf/cassandra.yaml
. See the fabric source, we hit that case because the fabric code is first checking for os.path.isabs(remote_path) and on Unix, that means it begins with a slash. I do not see a way to work around this using $HOME in get_dse_path
without modifying this path in each call to fab.get or fab.put.
Regarding the first solution of using os.path.join('~','fab','dse')
and the case of using such a path as a JVM parameter, could we do something similar to what we do here? At this point I am having trouble finding an easier solution
Regarding the first solution of using
os.path.join('~','fab','dse')
and the case of using such a path as a JVM parameter, could we do something similar to what we do here?
The approach from https://github.com/datastax/cstar_perf/blob/master/tool/cstar_perf/tool/fab_dse.py/#L190-L191 sounds like a reasonable workaround
@nastra this is ready for another review
get_dse_path
changed to use os.path.join('$HOME','fab','dse')
.replace('$HOME','~')
if using get_dse_path
. This includes calls to product.get_cassandra_path
which calls get_dse_path
when the product = dse.replace('$HOME','~')
for the fab.get and fab.put callsfab_cassandra.get_cassandra_path
as I do not anticipate the Tech Cert team will test open source Cassandra and this fix is specific to our scenario. If it is requested later, we can always add it to the Cassandra code as well.+1
Sometimes the cstar_perf tool host is not using the same linux user as the server under test host. This causes the DSE bootstrap process to fail because it tries to create the cstar_perf tool host home on the server under test host.
In order to solve this, we only use
os.path.expanduser
to get thedse_build_local
location. This PR usesos.path.join('~','fab','dse')
as thedse_build_remote
location. This allows the path to properly expand when the given commands are run on the server under test host.Tested: