Skip to content
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

Kafka Packaging rework 2 #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
28 changes: 24 additions & 4 deletions build_kafka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ src_package="kafka_${scala_version}-${version}.tgz"
download_url="http://mirror.cc.columbia.edu/pub/software/apache/kafka/${version}/${src_package}"
origdir="$(pwd)"

DISTRIB_CODENAME=""
if [ -e /etc/lsb-release ]; then
source /etc/lsb-release
fi

case "${1:-$DISTRIB_CODENAME}" in
trusty)
version_tag="~u1404"
fpm_init_opts="--deb-upstart ../../../upstart/kafka-broker.conf"
;;
xenial)
version_tag="~u1604"
fpm_init_opts="--deb-systemd ../../../systemd/kafka.service"
;;
*)
echo "Unrecognized host distribution or codename unspecified (try '$0 xenial' or '$0 trusty')!"
exit 1
;;
esac

#_ MAIN _#
rm -rf ${name}*.deb
if [ ! -f "${src_package}" ]; then
Expand All @@ -29,18 +49,17 @@ mkdir -p build/etc/init
mkdir -p build/etc/kafka
mkdir -p build/var/log/kafka

cp ${origdir}/kafka-broker.default build/etc/default/kafka-broker
cp ${origdir}/kafka-broker.upstart.conf build/etc/init/kafka-broker.conf

tar zxf ${origdir}/${src_package}
cd kafka_${scala_version}-${version}
mv config/log4j.properties config/server.properties ../build/etc/kafka

Choose a reason for hiding this comment

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

Posting this here so I remember to ask but it's prob a salt thing... Is Kafka logging working okay for prod? I know there were issues in staging.

Copy link
Author

Choose a reason for hiding this comment

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

I don't actually know. I didn't remember any clear complaints. :-/

Choose a reason for hiding this comment

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

Ah yeah, it's potentially confusing. So I do see something in: https://staging.papertrailapp.com/groups/1/events?q=host%3Akafka%20-program%3A(cron%20rsyslog%20dhclient%20systemd%20snapteld%20clear-aoagent%20salt-minion) but I'm guessing that's not all of it as I can't seem to track down where the logs specified in log4j.properties are going:

log4j.appender.kafkaAppender.File=${kafka.logs.dir}/server.log

I assumed kafka.logs.dir = /var/log/kafka, but that's empty. If we can find out where it lives, we can monitor them with remote_syslog2 or send them into syslog and rsyslog will forward 'em over.

Having said all that, perhaps there's just nothing to log and so no files existing is normal?

mv * ../build/usr/lib/kafka
cd ../build

patch -p0 < ../../../kafka-server-start.sh.pidfile.patch

fpm -t deb \
-n ${name} \
-v ${version}${package_version} \
-v ${version}${version_tag}${package_version} \
--description "${description}" \
--url="{$url}" \
-a ${arch} \
Expand All @@ -49,6 +68,7 @@ fpm -t deb \
--license "${license}" \
-m "${USER}@localhost" \
--prefix=/ \
${fpm_init_opts} \
-s dir \
-- .
mv kafka*.deb ${origdir}
Expand Down
9 changes: 9 additions & 0 deletions kafka-server-start.sh.pidfile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- usr/lib/kafka/bin/kafka-server-start.sh 2016-12-15 10:04:05.000000000 -0800
+++ usr/lib/kafka/bin/kafka-server-start.sh.new 2017-10-31 22:44:04.692890284 -0700
@@ -41,4 +41,6 @@
;;
esac

+echo $$ > ${KAFKA_PID_FILE:-/run/kafka/kafka.pid}
+
exec $base_dir/kafka-run-class.sh $EXTRA_ARGS kafka.Kafka "$@"
15 changes: 15 additions & 0 deletions systemd/kafka.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Apache Kafka server (broker)
Documentation=http://kafka.apache.org/documentation.html
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
Type=simple
User=kafka
Group=kafka
RuntimeDirectory=kafka
PIDFile=/run/kafka/kafka10-pt.pid
Environment=KAFKA_HOME=/usr/lib/kafka CONFIG_HOME=/etc/kafka
ExecStart=/usr/lib/kafka/bin/kafka-server-start.sh /etc/kafka/server.properties
ExecStop=/usr/lib/kafka/bin/kafka-server-stop.sh

Choose a reason for hiding this comment

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

For the ZK systemd script, I ended up adding this:

Restart=always
RestartSec=3

so it'll get restarted if it crashes. I think we're doing that now with god and it's all good. Do we want that with Kafka as well? Could see args on both sides so just raising the question more than anything.

File renamed without changes.