evertrue / zookeeper-cookbook

Chef cookbook for installing and managing Zookeeper.
https://supermarket.chef.io/cookbooks/zookeeper
Apache License 2.0
81 stars 117 forks source link

Fix Permissions #196

Closed davidsayers closed 7 years ago

davidsayers commented 7 years ago

All files and directories in /opt/zookeeper are being installed as root. This updates them to use the zookeeper user.

Files being owned by root is causing the following issue in https://github.com/evertrue/exhibitor-cookbook

2017-02-08_11:07:50.94238 java.io.FileNotFoundException: /opt/zookeeper-3.4.9/conf/zoo.cfg (Permission denied)
2017-02-08_11:07:50.94238       at java.io.FileOutputStream.open(Native Method)
2017-02-08_11:07:50.94239       at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
2017-02-08_11:07:50.94239       at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
2017-02-08_11:07:50.94240       at com.netflix.exhibitor.core.processes.StandardProcessOperations.prepConfigFile(StandardProcessOperations.java:167)
2017-02-08_11:07:50.94240       at com.netflix.exhibitor.core.processes.StandardProcessOperations.startInstance(StandardProcessOperations.java:109)
2017-02-08_11:07:50.94240       at com.netflix.exhibitor.core.state.KillRunningInstance.completed(KillRunningInstance.java:41)
2017-02-08_11:07:50.94240       at com.netflix.exhibitor.core.activity.ActivityQueue$1.run(ActivityQueue.java:127)
2017-02-08_11:07:50.94240       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
2017-02-08_11:07:50.94240       at java.util.concurrent.FutureTask.run(FutureTask.java:262)
2017-02-08_11:07:50.94240       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
2017-02-08_11:07:50.94241       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
2017-02-08_11:07:50.94241       at java.lang.Thread.run(Thread.java:745)
jeffbyrnes commented 7 years ago

@davidsayers oh my goodness, thanks for chasing that down!

jeffbyrnes commented 7 years ago

@davidsayers hm. The exhibitor cookbook doesn’t use the zookeeper_config resource. How does this solve this?

davidsayers commented 7 years ago

It looked to me like the exhibitor cookbook will need to use zookeeper_config. Currently there is an issue in where java_opts are being ignored.

jeffbyrnes commented 7 years ago

@davidsayers it doesn’t use zookeeper_config on purpose; Exhibitor handles configuring ZooKeeper.

That said, you’re right; that’s tricky. Once upon a time, this & the exhibitor cookbook were tightly coupled.

jeffbyrnes commented 7 years ago

@davidsayers this is tricky for me to help out with; I’m not actually using ZooKeeper at my current job. @eherot is still using it at EverTrue. Doing my best to keep contributing to this cookbook!

That said, I think that Exhibitor’s --defaultconfig takes over the zoo.cfg. So that covers that portion.

Perhaps the zookeeper-env.sh file needs to be part of the zookeeper resource, and not zookeeper_config?

jeffbyrnes commented 7 years ago

What things are you trying to configure via the JVMFLAGS (which corresponds to the java_opts property of zookeeper_config)?

davidsayers commented 7 years ago

I'm not sure if it is the way I will go but I was testing Zookeeper authentication as described here https://www.cloudera.com/documentation/enterprise/5-6-x/topics/cdh_sg_zookeeper_security.html

This requires a JVM setting.

jeffbyrnes commented 7 years ago

What about setting Exhibitor’s java.env config value? It’s very lightly described in the Exhibitor wiki Config UI docs.

Based on what I can tell, you’d populate that config with what you want the contents of a Java environment file to contain.

So if you want that to pass along JVMFLAGS to ZooKeeper, I think you’d do something like:

override['exhibitor']['config']['java-environment'] = "JVMFLAGS=#{your_flags}"

That is entirely guesswork, but give it a go in your wrapper cookbook!

jeffbyrnes commented 7 years ago

I’ve got to get back to other things now unfortunately. I’ll ship this ownership fix though.

davidsayers commented 7 years ago

I did try java.env but it didn't work. Maybe I didn't spend enough time on it. Will try again.

If that ends up being the recommended approach, https://github.com/evertrue/exhibitor-cookbook/blob/master/recipes/default.rb#L25 should be removed as it is confusing.

jeffbyrnes commented 7 years ago

@davidsayers good point; that is confusing. I’ll nix that, since it doesn’t have any effect anymore (it used to, long ago).