Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
5ddfd28
nonexistent target ballclean
Dec 11, 2021
4ec03f3
determine otp version from erlang:system_info(otp_release)
Dec 14, 2021
df64555
upgrade rebar3 to 3.17 plus git revlist fix
Dec 10, 2021
73f12e9
upgrade rebar3_cuttlefish (to a version that supports fqdn data type)
Dec 11, 2021
3db7582
avoid copying .git dirs when preparing rel- targets
hmmr Dec 15, 2021
6976d5e
improvements in deb packaging (compliance with current standards, etc)
Dec 13, 2021
b5951f8
clean up after dropping yokozuna
Dec 13, 2021
10598c5
improvements in rpm packaging
Dec 14, 2021
d83d0ae
enable packaging for Amazon Linux 2
Dec 14, 2021
cb67886
osx package
Dec 24, 2021
debd415
cleaner su in launcher script
Dec 19, 2021
8b95c99
refactor and repair release assembly
Dec 19, 2021
9cb62b8
upgrade rebar3 to 3.18
Jan 2, 2022
88c76ff
rm node_package relic
Feb 4, 2022
9f25dab
alpine packaging groundwork
Feb 4, 2022
b052781
launcher without su, just for alpine
Feb 10, 2022
8009ff2
copy APKBUILD, with instruction on how to use it
Feb 10, 2022
9149d75
packaging for freebsd
Feb 19, 2022
2fa2d8b
use https:// when fetching github deps
hmmr Mar 22, 2022
48e829a
tmp repoint, bump lager_syslog
hmmr Mar 23, 2022
cfcacbc
Merge branch 'hmmr/develop-3.0/upgrade-to-rebar3.17' of github.com:TI…
hmmr Mar 23, 2022
ffb83b6
update rel/pkg/alpine/README
hmmr Mar 23, 2022
918f17b
more dependency bumps
hmmr Mar 23, 2022
e6f64bf
pre-create ./log in 'rel' release (fixes silent fail on first riak st…
hmmr Mar 26, 2022
bb10751
read release version from git tag
hmmr Mar 26, 2022
6ab6b0b
rm a leftover in rel/pkg/rpm
hmmr Mar 26, 2022
1ce0262
deprecate, warn about hyphenated forms of riak-admin
hmmr Mar 26, 2022
937e08d
pid file for local release is useless
Mar 28, 2022
c74a556
change to rebar3_cuttlefish-0.2.1 (0.2.0 with rebar3.18 API fix)
Mar 28, 2022
3628c74
riak_not_running is actually a template
Mar 28, 2022
5c0009e
let relx handle pid files (unbroken in rebar3_cuttlefish-0.2.1)
Mar 28, 2022
58b063a
rm leftover debian/riak.init
Mar 29, 2022
f75df62
rebar3.org recommends starting riak with 'foreground'
Mar 29, 2022
a50898f
tmp point rebar3_cuttlefish to a branch
Mar 29, 2022
4a3f0ff
missing items in debian/control BuildDepends
Mar 30, 2022
3140383
debian/Makefile: don't do make clean when nothing has been built yet
Mar 30, 2022
de4b6e9
deb/Makefile: link _build/default/{libs,plugins} to avoid fetching do…
Mar 30, 2022
36d6970
export RUNNER_LOG_DIR to unbreak cuttlefish-generated scripts
Mar 30, 2022
a6b196a
move hooks into own dir under rel/files
Mar 31, 2022
b03a592
why prepend riak- to PKG_ID?
Mar 31, 2022
f776cd7
symlnk deps from _build/default/lib/* into tree snapshot in rel/pkg/o…
Mar 31, 2022
8647c98
try explicit config/vm.args, to unbreak relx internode ops
Mar 31, 2022
323453d
amend de4b6e9a to only symlink libs (cuttlefish plugin fails unless r…
Mar 31, 2022
231d6f1
Merge branch 'hmmr/develop-3.0/fbsdng-support' into hmmr/develop-3.0/…
Apr 1, 2022
2afabb2
point deps to develop-3.0 branches
Apr 1, 2022
f0dc94c
tmp remove rebar.lock while deps are floated
Apr 2, 2022
332f71f
typo in rebar.config
Apr 4, 2022
e0b92c3
with rebar3_cuttlefish unbroken, undo hyphenated command routing
hmmr Apr 6, 2022
57314bd
make use of cf_config in riak-chkconfig, again
Apr 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PKG_REVISION ?= $(shell git describe --tags 2>/dev/null)
PKG_BUILD = 1
BASE_DIR = $(shell pwd)
ERLANG_BIN = $(shell dirname $(shell which erl 2>/dev/null) 2>/dev/null)
OTP_VER = $(shell echo $(ERLANG_BIN) | rev | cut -d "/" -f 2 | rev)
OTP_VER = $(shell erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell)
REBAR ?= $(BASE_DIR)/rebar3
OVERLAY_VARS ?=
TEST_IGNORE ?= lager riak basho_bench
Expand All @@ -30,12 +30,12 @@ compile:

deps:
$(if $(HEAD_REVISION),$(warning "Warning: you have checked out a tag ($(HEAD_REVISION)) and should use the compile target"))
$(REBAR) upgrade
$(REBAR) upgrade --all

clean: testclean
$(REBAR) clean

distclean: clean devclean relclean ballclean
distclean: clean devclean relclean
@rm -rf _build

##
Expand Down Expand Up @@ -74,20 +74,25 @@ test : testclean eunit test-deps
## Release targets
##
rel: compile
$(REBAR) as rel release
cp -a _build/rel/rel/riak rel/
@$(REBAR) as rel release
# freebsd tar won't write to stdout, so
@tar -c -f rel.tar --exclude-vcs -C _build/rel/rel riak && tar -x -f rel.tar -C rel && rm rel.tar

rel-rpm: compile
$(REBAR) as rpm release
cp -a _build/rpm/rel/riak rel/
@$(REBAR) as rpm release
@tar --exclude-vcs -c -C _build/rpm/rel riak | tar -x -C rel

rel-deb: compile
$(REBAR) as deb release
cp -a _build/deb/rel/riak rel/
@$(REBAR) as deb release
@tar --exclude=vcs -c -C _build/deb/rel riak | tar -x -C rel

rel-osx: compile
@$(REBAR) as osx release
@tar --exclude=vcs -c -C _build/osx/rel riak | tar -x -C rel

relclean:
rm -rf $(REL_DIR)
rm -rf rel/riak
@rm -rf $(REL_DIR)
@rm -rf rel/riak rel/.libs rel/.deps

##
## Developer targets
Expand Down
13 changes: 9 additions & 4 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{deps, [
{lager_syslog, {git, "https://github.com/basho/lager_syslog.git", {tag, "3.1.0"}}},
{cluster_info, {git, "https://github.com/basho/cluster_info.git", {tag, "2.1.0"}}},
{riak_kv, {git, "https://github.com/basho/riak_kv.git", {tag, "riak_kv-3.0.9"}}},
{riak_kv, {git, "https://github.com/TI-Tokyo/riak_kv.git", {tag, "riak_kv-3.0.9.2"}}},
{riak_auth_mods, {git, "https://github.com/basho/riak_auth_mods.git", {tag, "riak_kv-3.0.0"}}},
{riaknostic, {git, "https://github.com/basho/riaknostic.git", {tag, "riak_kv-3.0.2"}}},

Expand All @@ -21,7 +21,7 @@
]}.

{project_plugins, [
{rebar3_cuttlefish, {git, "https://github.com/basho/rebar3_cuttlefish", {tag, "0.2.0"}}}
{rebar3_cuttlefish, {git, "https://github.com/TI-Tokyo/rebar3_cuttlefish", {tag, "2.1.2"}}}
]}.

{cuttlefish, [
Expand All @@ -46,7 +46,7 @@
]}
]}.

{relx, [{release, {riak, "3.0.9"},
{relx, [{release, {riak, "3.0.9.1"},
[kernel,
stdlib,
lager,
Expand Down Expand Up @@ -161,7 +161,7 @@
]},
{deb, [
{relx, [
{overlay_vars, "debian/vars.config"},
{overlay_vars, "rel/pkg/deb/vars.config"},
{overlay, [
{template, "rel/files/riak", "usr/bin/riak"}
]},
Expand All @@ -177,5 +177,10 @@
{wait_for_process, riak_core_node_watcher}]}
]}
]}
]},
{osx, [
{relx, [
{overlay_vars, "rel/pkg/osx/vars.config"}
]}
]}
]}.
27 changes: 17 additions & 10 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"1.1.0",
{"1.2.0",
[{<<"basho_stats">>,
{git,"https://github.com/basho/basho_stats.git",
{ref,"c5b7ecb92af7b050bc62d08c6fbf1aafd6bdeff0"}},
Expand All @@ -13,16 +13,16 @@
{ref,"2cd39378442f3dc727de22289243b3c4d56f25fd"}},
1},
{<<"clique">>,
{git,"https://github.com/basho/clique.git",
{ref,"4014357e4e677164b890fdad08a45cfa54b3e8f3"}},
{git,"https://github.com/TI-Tokyo/clique.git",
{ref,"002dc72d3ea38dc037df93edbaffee716eb40892"}},
2},
{<<"cluster_info">>,
{git,"https://github.com/basho/cluster_info.git",
{ref,"389d43af7ac1550b3c01cd55b8147bcc0e20022f"}},
0},
{<<"cuttlefish">>,
{git,"https://github.com/basho/cuttlefish.git",
{ref,"e84070b6cf08196ece2ae54083eefae4dc4e4ecc"}},
{git,"https://github.com/TI-Tokyo/cuttlefish.git",
{ref,"e9069c1ecd7fe25e971e4621c597eaec4856af20"}},
3},
{<<"ebloom">>,
{git,"git://github.com/basho/ebloom.git",
Expand Down Expand Up @@ -113,8 +113,8 @@
{ref,"1eccaef8e9e6200f0b75ea9312f0a731c8d572bf"}},
0},
{<<"riak_core">>,
{git,"https://github.com/basho/riak_core.git",
{ref,"7e0aa310ecf5ec7b9fd03df61b996c2823591950"}},
{git,"https://github.com/TI-Tokyo/riak_core.git",
{ref,"f197db606acab855b2a7d99021daff3beee95882"}},
1},
{<<"riak_dt">>,
{git,"https://github.com/basho/riak_dt.git",
Expand All @@ -125,8 +125,8 @@
{ref,"573a271aa546dcdcaeaaf09b3de6949a3130e021"}},
2},
{<<"riak_kv">>,
{git,"https://github.com/basho/riak_kv.git",
{ref,"0af857d57d0206b100db59043a926df2ada8f7db"}},
{git,"https://github.com/TI-Tokyo/riak_kv.git",
{ref,"d242bc57c947040d5014dd0489b666d000192bc0"}},
0},
{<<"riak_pb">>,
{git,"https://github.com/basho/riak_pb.git",
Expand Down Expand Up @@ -180,5 +180,12 @@
{<<"goldrush">>, <<"F06E5D5F1277DA5C413E84D5A2924174182FB108DABB39D5EC548B27424CD106">>},
{<<"hut">>, <<"08D46679523043424870723923971889E8A34D63B2F946A35B46CF921D1236E7">>},
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
{<<"setup">>, <<"1203F4CDA11306C2E34434244576DED0A7BBFB0908D9A572356C809BD0CDF085">>}]}
{<<"setup">>, <<"1203F4CDA11306C2E34434244576DED0A7BBFB0908D9A572356C809BD0CDF085">>}]},
{pkg_hash_ext,[
{<<"bear">>, <<"534217DCE6A719D59E54FB0EB7A367900DBFC5F85757E8C1F94269DF383F6D9B">>},
{<<"folsom">>, <<"F7B644FC002A75AF00B8BFBD3CC5C2BD955E09A118D2982D9A6C04E5646FF367">>},
{<<"goldrush">>, <<"99CB4128CFFCB3227581E5D4D803D5413FA643F4EB96523F77D9E6937D994CEB">>},
{<<"hut">>, <<"953FC447514BAF9CC79FA147D66469243C94DFA1593779614E070C692D0BF0F3">>},
{<<"parse_trans">>, <<"17EF63ABDE837AD30680EA7F857DD9E7CED9476CDD7B0394432AF4BFC241B960">>},
{<<"setup">>, <<"7D6AAF5281D0B0C40980E128F9DC410DACD03799A8577201D4C8B43E7F97509A">>}]}
].
Binary file modified rebar3
Binary file not shown.
2 changes: 2 additions & 0 deletions rel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.deps/
.libs/
126 changes: 78 additions & 48 deletions rel/files/riak
Original file line number Diff line number Diff line change
@@ -1,57 +1,87 @@
#!/bin/bash

RUNNER_GEN_DIR="${RUNNER_GEN_DIR:-{{ platform_gen_dir }}}"
RELEASE_ROOT_DIR="${RELEASE_ROOT_DIR:-{{ runner_base_dir }}}"
PID_DIR={{pid_dir}}
COMMAND={{platform_bin_dir}}/riak
DEBUG_COMMAND={{platform_bin_dir}}/riak-debug
RUNNER_LOG_DIR={{platform_log_dir}}
RELX_CONFIG_PATH=${RUNNER_GEN_DIR}/sys.config
VMARGS_PATH=${RUNNER_GEN_DIR}/vm.args
RUNNER_GEN_DIR={{platform_gen_dir}}
RELX_RIAK={{platform_bin_dir}}/riak
export PID_DIR={{pid_dir}}
export PIPE_DIR={{pipe_dir}}/ # terminating / (relx treats it as a prefix)

mkdir -p $PID_DIR $PIPE_DIR
chown riak:riak $PID_DIR $PIPE_DIR

# On first running the sys.config and vm.args will not be a link
# as cfconfig has not yet been run as a pre_start hook. If there's no
# link use the default for now
if [ ! -L $RELX_CONFIG_PATH ]; then
cp $RELEASE_ROOT_DIR/releases/{{release_version}}/sys.config $RELX_CONFIG_PATH
fi
if [ ! -L $VMARGS_PATH ]; then
cp $RELEASE_ROOT_DIR/releases/{{release_version}}/vm.args $VMARGS_PATH
fi
function write_pid_file { # relx doesn't seem to write the pid file, does it?
local c=3
sleep 1
while [[ $c -ne 0 ]]; do
if [ "`maybe_su ${RELX_RIAK} ping`" = "pong" ]; then
maybe_su ${RELX_RIAK} pid >$PID_DIR/riak.pid
# systemd wants it to be owned by root, so:
chown root:root $PID_DIR/riak.pid 2&>1 >/dev/null \
|| true # if we are run as non-root, just never mind
break
fi
sleep 2
c=$(($c - 1))
done
}

function delete_pid_file {
rm -f $PID_DIR/riak.pid
}

# When running as a service, running as riak not as root, and systemd has created PID folder
if [[ $EUID -ne 0 ]]; then
case "$1" in
start|console|foreground)
RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*} -pa {{platform_lib_dir}}/patches
;;
*)
RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*}
;;
esac
# centos7-based distros have a su that contacts pam and prints the "Last logged in" message
if [ "`cat /etc/redhat-release 2>&1`" = "CentOS Stream release 8" ] ||
[ "`cat /etc/system-release 2>&1`" = "Amazon Linux release 2 (Karoo)" ]; then
SU="su --session-command"
else
# In this case we're running sudo riak - so have root access, but cannot rely
# systemd having created the PID dir, and need to sudo to the riak user
if [ ! -d $PID_DIR ]; then
mkdir $PID_DIR
chown riak:riak $PID_DIR
fi
case "$1" in
start|console|foreground)
su - riak -c "NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*} -pa {{platform_lib_dir}}/patches"
;;
debug)
# Drop the "debug" from the args as we're going to directly call riak-debug now
shift
# Debug may fail if run via relx script due to use of relative start location, and also need for root access
NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${DEBUG_COMMAND} ${*}
;;
*)
ESCAPED_ARGS=`echo "$@" | sed -e 's/\([\\\(\\\){}"\x27]\)/\\\\\1/g'`
su - riak -c "NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${ESCAPED_ARGS}"
;;
esac
SU=su
fi

function maybe_su {
if [[ $EUID -ne 0 ]]; then
$*
else
# if we are executing an admin command that spins up a
# (hidden) node to then execute custom erlang code via -eval,
# we need to cd to a dir containing the erlang cookie
# (previously implicitly done by su -, which option we have
# removed in order to allow any env vars to be available for
# the ultimate invocation of riak/riak-cs/stanchion)
cd {{platform_base_dir}}
$SU riak -c "$*"
fi
}

case "$1" in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does each command need to be present in this case - is this not already handled in the extended start script as extensions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an effort to make hyphenated and non-hyphenated forms equivalent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it works as expected, and I'm not even sure that resurrecting the hyphenated commands is warranted - what purpose does it serve? It's been a couple of years since we moved to start script extensions. You now have to re-insert a bunch of boilerplate environment stuff at the top of the script files to make them work, whereas that was all inherited with from the root start script with extensions.

My opinion is that it's a backwards step, unless there's a compelling reason that I'm not aware of / considering.

The tidy up across the rest of the release config is very decent though, and much needed. Some of the deps currently reference TI forks, which would need to target basho, but guess that would be fixed up before everything gets merged in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To deal with the easier part first: re-pinning deps to TI-Tokyo repos has a single purpose: pull in cuttlefish and rebar3_cuttlefish, not so much for the fqdn data type in cuttlefish but rather for several commits in the plugin that make it compatible with rebar3 3.18 (by ioolkos, see this one and thereabout), synchronize its internal install_update_escript with the "upstream" version of it in relx, and last but not least, this little gem.

I note that the fqdn-type patch has already been merged in basho/cuttlefish, but there is no tag. If you do the tagging, I will then prepare the necessary PRs to bump cuttlefish version where necessary (it is an explicit dependency in bitcask, clique, eleveldb and riak_sysmon), and collect a patchset for another PR in rebar3_cuttlefish.

Regarding the phasing out of hyphenated forms, I have no strong opinions and will gladly follow the party line (although I would invite @Bob-The-Marauder to this discussion, who has been in the business of dealing with customers for some time).

For the record, my understanding of the underlying machinery is as follows:

  • The riak script generated by relx and/or cuttlefish provides basic commands like start, stop, console, pid, ping, rpc. It is how riak is started/stopped in riak_test setting. It is not under our control.
  • The other riak, the one created from the template in rel/files, has a distinct and specific purpose:
    • it takes care of the pid file (relx-generated one will not do this for us);
    • it does su as appropriate, and is therefore installed in PATH when riak is installed from a package;
    • it launches riak-admin etc when called as riak admin.

I saw this last item precisely as a way to enable non-hyphenated forms (if we remove riak-admin and its hyphenated friends from PATH, the move to hide hyphenated forms will be complete, from the user standpoint). Apparently, by "move to start script extensions" you mean to do it differently -- perhaps by injecting code in the script produced by relx? If so, I would be happy to rework my contribution accordingly, but I didn't see how relx can be massaged to achieve that.

start)
maybe_su $RELX_RIAK $* -pa {{platform_patch_dir}} \
&& write_pid_file
test -r $PID_DIR/riak.pid && exit 0
;;
console|foreground)
maybe_su $RELX_RIAK $* -pa {{platform_patch_dir}}
;;
stop)
maybe_su $RELX_RIAK $* \
&& delete_pid_file
;;
admin)
shift
maybe_su `which riak-admin` $*
;;
chkconfig)
shift
maybe_su `which riak-chkconfig` $*
;;
repl)
shift
maybe_su `which riak-repl` $*
;;
debug)
shift
maybe_su `which riak-debug` $*
;;
*)
ESCAPED_ARGS=`echo "$@" | sed -e 's/\([\\\(\\\){}"\x27]\)/\\\\\1/g'`
maybe_su $RELX_RIAK $ESCAPED_ARGS
;;
esac
Loading