Skip to content

Commit

Permalink
Fix relocatable to use install.sh (fixes #169)
Browse files Browse the repository at this point in the history
  • Loading branch information
fruch committed Sep 5, 2019
1 parent 10b56f0 commit 196404a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 29 deletions.
12 changes: 9 additions & 3 deletions ccmlib/cmds/cluster_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,21 @@ def get_parser(self):
Examples of using relocatable packages:
# create cluster from version uploaded to s3 (of the daily/nightly as example)
ccm create fruch --scylla --version unstable/master:239
ccm create scylla-reloc-1 -n 1 --scylla --version unstable/master:380
# create cluster with own versions of each package
ccm create fruch --scylla --version temp \\
--scylla-package-uri=../scylla/temp.tar.gz \\
ccm create scylla-reloc-1 -n 1 --scylla --version temp \\
--scylla-core-package-uri=../scylla/build/release/scylla-package.tar.gz \\
--scylla-java-tools-package-uri=../scylla-tools-java/temp.tar.gz \\
--scylla-jmx-package-uri=../scylla-jmx/temp.tar.gz
# create cluster with overwriting only one package
ccm create scylla-reloc-1 -n 1 --scylla --version unstable/master:380 \\
--scylla-core-package-uri=../scylla/build/dev/scylla-package.tar.gz
"""


return parser

def validate(self, parser, options, args):
Expand Down
2 changes: 1 addition & 1 deletion ccmlib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def scylla_extract_install_dir_and_mode(install_dir):
elif install_dir.endswith('build/release') or install_dir.endswith('build/release/'):
scylla_mode = 'release'
install_dir = str(os.path.join(install_dir, os.pardir, os.pardir))
elif os.path.exists(os.path.join(install_dir, 'libreloc')):
elif os.path.exists(os.path.join(install_dir, 'scylla-core-package', 'SCYLLA-RELOCATABLE-FILE')):
scylla_mode = 'reloc'
return install_dir, scylla_mode

Expand Down
16 changes: 2 additions & 14 deletions ccmlib/scylla_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,6 @@ def import_dse_config_files(self):
def copy_config_files_dse(self):
raise NotImplementedError('ScyllaNode.copy_config_files_dse')

def hard_link_or_copy_dir(self, src_dir, dst_dir):
os.makedirs(dst_dir)
for f in os.listdir(src_dir):
self.hard_link_or_copy(os.path.join(src_dir, f), os.path.join(dst_dir, f))

def hard_link_or_copy(self, src, dst):
try:
os.link(src, dst)
Expand Down Expand Up @@ -607,23 +602,16 @@ def import_bin_files(self):
relative_repos_root = '../..'
self.hard_link_or_copy(os.path.join(self.get_install_dir(), 'bin', 'scylla'),
os.path.join(self.get_bin_dir(), 'scylla'))

self.hard_link_or_copy_dir(os.path.join(self.get_install_dir(), 'libexec'),
os.path.join(self.get_path(), 'libexec'))

self.hard_link_or_copy_dir(os.path.join(self.get_install_dir(), 'libreloc'),
os.path.join(self.get_path(), 'libreloc'))

else:
relative_repos_root = '..'
self.hard_link_or_copy(os.path.join(self.get_install_dir(),
'build', scylla_mode, 'scylla'),
os.path.join(self.get_bin_dir(), 'scylla'))

if 'scylla-repository' in self.get_install_dir():
self.hard_link_or_copy(os.path.join(self.get_install_dir(), 'jmx', 'scylla-jmx-1.0.jar'),
self.hard_link_or_copy(os.path.join(self.get_install_dir(), 'scylla-jmx', 'scylla-jmx-1.0.jar'),
os.path.join(self.get_bin_dir(), 'scylla-jmx-1.0.jar'))
self.hard_link_or_copy(os.path.join(self.get_install_dir(), 'jmx', 'scylla-jmx'),
self.hard_link_or_copy(os.path.join(self.get_install_dir(), 'scylla-jmx', 'scylla-jmx'),
os.path.join(self.get_bin_dir(), 'scylla-jmx'))
else:
self.hard_link_or_copy(os.path.join(self.get_jmx_dir(relative_repos_root), 'target', 'scylla-jmx-1.0.jar'),
Expand Down
32 changes: 21 additions & 11 deletions ccmlib/scylla_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import tempfile
import shutil
import glob
import subprocess

from six import print_
from six.moves import urllib
Expand All @@ -31,18 +32,21 @@ def setup(version, verbose=True):
tmp_download = tempfile.mkdtemp()

url = os.environ.get('SCYLLA_CORE_PACKAGE', os.path.join(s3_url, 'scylla-package.tar.gz'))
download_version(version, verbose=verbose, url=url, target_dir=tmp_download)
download_version(version, verbose=verbose, url=url, target_dir=os.path.join(tmp_download, 'scylla-core-package'))

url = os.environ.get('SCYLLA_JAVA_TOOLS_PACKAGE', os.path.join(s3_url, 'scylla-tools-package.tar.gz'))
download_version(version, verbose=verbose, url=url, target_dir=os.path.join(tmp_download, 'scylla-java-tools'))

url = os.environ.get('SCYLLA_JMX_PACKAGE', os.path.join(s3_url, 'scylla-jmx-package.tar.gz'))
download_version(version, verbose=verbose, url=url, target_dir=os.path.join(tmp_download, 'jmx'))
download_version(version, verbose=verbose, url=url, target_dir=os.path.join(tmp_download, 'scylla-jmx'))

cdir = directory_name(version)

shutil.move(tmp_download, cdir)

# install using scylla install.sh
run_scylla_install_script(os.path.join(cdir, 'scylla-core-package'), cdir)

return cdir, version


Expand Down Expand Up @@ -89,15 +93,6 @@ def download_version(version, url=None, verbose=False, target_dir=None):
raise ArgumentError(msg)
except tarfile.ReadError as e:
raise ArgumentError("Unable to uncompress downloaded file: %s" % str(e))
except CCMError as e:
if target_dir:
# wipe out the directory if anything goes wrong.
try:
rmdirs(target_dir)
print_("Deleted %s due to error" % target_dir)
except:
raise CCMError("Downloading/extracting scylla version %s failed. Attempted to delete %s but failed. This will need to be manually deleted" % (version, target_dir))
raise e


def directory_name(version):
Expand All @@ -122,3 +117,18 @@ def __get_dir():
if not os.path.exists(repo):
os.mkdir(repo)
return repo


def run_scylla_install_script(install_dir, target_dir):
scylla_target_dir = os.path.join(target_dir, 'scylla')

def run(cmd, cwd=None):
subprocess.check_call(['bash', '-c', cmd], cwd=cwd, stderr=None, stdout=None)

# FIXME: remove this hack once scylladb/scylla#4949 is fixed and merged
run('''sed 's|"$prefix|"$root/$prefix|' -i install.sh''', cwd=install_dir)

run('''{0}/install.sh --root {1} --target centos --disttype redhat --pkg server'''.format(install_dir, scylla_target_dir), cwd=install_dir)
run('''mkdir -p {0}/conf; cp ./conf/scylla.yaml {0}/conf'''.format(scylla_target_dir), cwd=install_dir)
run('''ln -s {}/opt/scylladb/bin .'''.format(scylla_target_dir), cwd=target_dir)
run('''ln -s {}/conf .'''.format(scylla_target_dir), cwd=target_dir)
4 changes: 4 additions & 0 deletions scylla_ccm_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ echo

echo "=== Stop and remove"
echo "ccm remove"


echo "=== Create scylla cluster with single node [relocatable]"
echo "ccm create scylla-reloc-1 -n 1 --scylla --version unstable/master:380 --scylla-core-package-uri=../scylla/build/dev/scylla-package.tar.gz"

0 comments on commit 196404a

Please sign in to comment.