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

init clean-up #82

Merged
merged 11 commits into from
Jul 5, 2016
Merged

init clean-up #82

merged 11 commits into from
Jul 5, 2016

Conversation

igalic
Copy link
Contributor

@igalic igalic commented Jul 4, 2016

This WIP pull request tries to clean-up our init scripts.
They are currently quadrupled (broker, consumer, mirror, producer). Unnecessarily so.

This pr will first attempt to clean up the shell scripts, then consolidate them into one template.

all init scripts now look the same and can probably be merged into one,
if needed.
@@ -21,29 +34,29 @@ if [ -f /etc/default/kafka ]; then
fi

start() {
if [ -f $PID_FILE ]
then
if [ -f $PID_FILE ]; then
Copy link
Member

Choose a reason for hiding this comment

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

this needs quotes around the var

@igalic
Copy link
Contributor Author

igalic commented Jul 4, 2016

thank you for the review, @bastelfreak.
i'll add proper quoting once i've merged all three files into one :)
as far as vs $() goes: i'm not sure i can do this. debuntu's systemv prescribes/bin/sh (i don't know about rhel)

@igalic igalic added needs-tests needs-work not ready to merge just yet labels Jul 4, 2016
@bastelfreak
Copy link
Member

on a first look this looks good. Are we sure that zookeeper.service always has that name or does it need to be configurable?
I will have to review this when I've a few hours of free time, or a day.

@igalic
Copy link
Contributor Author

igalic commented Jul 5, 2016

i'm contemplating to review it by putting it into production.

n.b.: This ignores stdout / stderr in sysv-inits!
The reason for this is because we weren't rotating those logs — in some
cases we weren't even appending, just overwriting it! Additionally,
those logs were partially duplicated from those already existing under
/opt/kafka/logs/.
@bastelfreak
Copy link
Member

meme

@igalic igalic closed this Jul 5, 2016
@igalic igalic reopened this Jul 5, 2016
@igalic
Copy link
Contributor Author

igalic commented Jul 5, 2016

close/open did nothing to make @voxpupuli/pcci pick it up

previously, we were comparing the command 2699 (a random pid) with 2699.
usually, that command wasn't found ;)
additionally, our status had that condition wrong!
comparing `ps -p non-existent-pid` with `pgrep -f non-running-process`
will always return true. This adds a saftey-switch.
then
if [ -f "$PID_FILE" ]; then
PID=`cat "$PID_FILE"`
if [ `ps -p "$PID" -o pid= || echo 1` -eq `pgrep -f "$PGREP_PATTERN" || echo 2` ] ; then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i really hope this isn't too clever

Copy link
Member

Choose a reason for hiding this comment

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

that looks really strange. Have you tested that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes!! it works really well

what it does is this:
if ps -p 2194 -o pid= doesn't find that pid to be running, it'll output nothing, but return 1. In that case the || echo 1 case will fire. simiarily, if pgrep -f kafka.Kafka doesn't find anything, it will output nothing, but return 1. Now, || echo 2 is the result. hence, we're comparing
[ 1 -eq 2 ], which will be false. but! if one of ps or pgrep returns a sensible value, something is off! and we're catching those cases, too: [ 2967 -eq 2 ] is just as false, as [ 1 -eq 2957 ] is.

@igalic
Copy link
Contributor Author

igalic commented Jul 5, 2016

it took creating and destroying 3 stacks, but with the latest patches it now works.

@igalic igalic changed the title [WIP] init clean-up init clean-up Jul 5, 2016
@igalic igalic removed the needs-work not ready to merge just yet label Jul 5, 2016
ensure => present,
file { "${service_name}.service":
ensure => file,
path => "/usr/lib/systemd/system/${service_name}.service",
Copy link
Member

Choose a reason for hiding this comment

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

overwriting anything in /usr/lib/systemd/system is a bad idea and not recommened. The prefered solution is to use /etc/systemd/system. The first path is meant to be used by package managers only. You can create a unit at the second path with an equal name which will kind of inherit from the first one. Also ubuntu or debian don't use /usr/lib but /lib/something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so, /etc/systemd/system ?

Copy link
Member

Choose a reason for hiding this comment

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

yep. I'm currently not sure how exactly the overwrites work. Not everything is possible here. I've to read up the docs.
https://wiki.archlinux.org/index.php/systemd
https://www.freedesktop.org/software/systemd/man/systemd.unit.html
https://www.freedesktop.org/software/systemd/man/systemd.service.html#

(/usr)/lib/systemd is reserved for the system. we shouldn't touch that
ourselves. instead we should use /etc/systemd. This comes with an
additional benefit: it's compatible between debuntu & rhel!
@bastelfreak
Copy link
Member

two fails on travis, this is based on a gem fuckup. the rest is fine.

@bastelfreak bastelfreak merged commit 88066f7 into voxpupuli:master Jul 5, 2016
@igalic igalic deleted the sys-deps branch July 6, 2016 14:43
elmendalerenda pushed a commit to elmendalerenda/puppet-kafka that referenced this pull request Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants