Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Fix Permissions #196

Closed
wants to merge 1 commit into from
Closed

Conversation

davidsayers
Copy link
Contributor

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)

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
Copy link
Contributor

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

@jeffbyrnes jeffbyrnes self-assigned this Feb 8, 2017
@jeffbyrnes
Copy link
Contributor

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

@@ -72,6 +72,8 @@
prefix_root install_dir
prefix_home install_dir
checksum new_resource.checksum if new_resource.checksum
owner username
group username
Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh, I see. This is the trick, right here.

owner user
group user
owner new_resource.user
group new_resource.user
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not part of the fix, since the user value and new_resource.user are the same, in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

user was being passed in as nil when using:

owner   user
group   user

Copy link
Contributor

@jeffbyrnes jeffbyrnes left a comment

Choose a reason for hiding this comment

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

I’m going to get these changes in, slightly tweaked. Thanks for catching this!

@@ -46,7 +46,8 @@
env_vars_hash['JVMFLAGS'] = java_opts if java_opts

file "#{conf_dir}/zookeeper-env.sh" do
owner user
owner new_resource.user
group new_resource.user
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding the group here is a good call.

@davidsayers
Copy link
Contributor Author

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 jeffbyrnes closed this in ce3f790 Feb 8, 2017
@jeffbyrnes
Copy link
Contributor

@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
Copy link
Contributor

@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
Copy link
Contributor

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

@davidsayers
Copy link
Contributor Author

davidsayers commented Feb 8, 2017

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
Copy link
Contributor

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
Copy link
Contributor

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

@davidsayers
Copy link
Contributor Author

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
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants