Bitcoin (Core) cookbook #121

Merged
greg merged 20 commits from feature/bitcoin_cookbook into master 2020-08-20 17:17:31 +00:00
Owner

Installs and configures Bitcoin Core on Ubuntu via the official snap package. (Update: we now only use the new source recipe, which compiles from source.)

@gregkare The installation of the actual bitcoin-core snap package via the snap_package resource makes the chef client process hang for me, and I'm stuck trying to figure out why. I tried to attach strace, but it's too late and I don't see a way of starting the chef run as an argument for strace from within the VM. Maybe you could see if it hangs on your machine, too, and maybe you'd have an idea for how to find out more?

Installs and configures [Bitcoin Core](https://github.com/bitcoin/bitcoin) on Ubuntu via the official snap package. (Update: we now only use the new `source` recipe, which compiles from source.) @gregkare The installation of the actual `bitcoin-core` snap package via the `snap_package` resource makes the chef client process hang for me, and I'm stuck trying to figure out why. I tried to attach strace, but it's too late and I don't see a way of starting the chef run as an argument for strace from within the VM. Maybe you could see if it hangs on your machine, too, and maybe you'd have an idea for how to find out more?
Owner

Sure, I will investigate

Sure, I will investigate
Owner

It's not just the bitcoin-core snap package, even the hello-world package has the same behavior. I found this issue on the chef repo: https://github.com/chef/chef/issues/8827

So it looks like snap_package is completely broken, at least on Ubuntu 18.04 (and 19.04, as the person who reported the issue is running that). In the mean time we can work around it by not using it, instead doing something like:

execute "snap install bitcoin-core"

snap install returns 0 when a package already exists so no need for a guard clause

I have pushed a few changes, including running snap install as an execute command and fixing the mounting of the directory (typo in an attribute name)

It's not just the bitcoin-core snap package, even the hello-world package has the same behavior. I found this issue on the chef repo: https://github.com/chef/chef/issues/8827 So it looks like `snap_package` is completely broken, at least on Ubuntu 18.04 (and 19.04, as the person who reported the issue is running that). In the mean time we can work around it by not using it, instead doing something like: ```ruby execute "snap install bitcoin-core" ``` `snap install` returns 0 when a package already exists so no need for a guard clause I have pushed a few changes, including running `snap install` as an execute command and fixing the mounting of the directory (typo in an attribute name)
Author
Owner

Great, thanks!

Great, thanks!
greg was assigned by raucao 2020-01-22 14:08:40 +00:00
raucao self-assigned this 2020-01-22 14:08:40 +00:00
Owner

I created an issue about the invalid systemd unit when passing a hash as a config: https://github.com/chef/chef/issues/9259

I created an issue about the invalid systemd unit when passing a hash as a config: https://github.com/chef/chef/issues/9259
Author
Owner

Doesn't it also add newlines around every key/value pair? I'm pretty sure it did that on my machine.

Doesn't it also add newlines around every key/value pair? I'm pretty sure it did that on my machine.
Owner

For me it only adds a newline before the start of a section, so that behavior is correct

For me it only adds a newline before the start of a section, so that behavior is correct
Author
Owner

Strange. Maybe a difference between Linux and macOS hosts?

Strange. Maybe a difference between Linux and macOS hosts?
Author
Owner

Status update:

I wrote a whole new source recipe yesterday (see latest commit), and got everything working as intended. However, I ended up with a leveldb issue when starting bitcoin, which I wasn't able to fix. So I have it re-indexing the whole chain database now.

Status update: I wrote a whole new source recipe yesterday (see latest commit), and got everything working as intended. However, I ended up with a leveldb issue when starting bitcoin, which I wasn't able to fix. So I have it re-indexing the whole chain database now.
Author
Owner

After a while of indexing, it runs into the same issue. Goes something like:

LevelDB read failure: IO error: /mnt/data/bitcoin/chainstate/1629202.ldb: Too many open files

I have already upped the ulimit for open files to unlimited in the systemd service config (and tried doing it via ulimit before). But somehow it seems to be stuck at the 1024 default, no matter what I do.

I'm wondering if there's a different issue, and this error message is just a symptom. In any case, I'm completely stuck now. Already spent hours trying to fix it.

Anyone has ideas for debugging it further?

After a while of indexing, it runs into the same issue. Goes something like: > LevelDB read failure: IO error: /mnt/data/bitcoin/chainstate/1629202.ldb: Too many open files I have already upped the ulimit for open files to unlimited in the systemd service config (and tried doing it via ulimit before). But somehow it seems to be stuck at the 1024 default, no matter what I do. I'm wondering if there's a different issue, and this error message is just a symptom. In any case, I'm completely stuck now. Already spent hours trying to fix it. Anyone has ideas for debugging it further?
Author
Owner

Hmm:

Note that most process resource limits configured with these options are per-process, and processes may fork in order to acquire a new set of resources that are accounted independently of the original process, and may thus escape limits set

So maybe it's worth fixing the ulimit after all.

Unfortunately, the current ulimit cookbook and resource didn't work for me. When I opened a shell as the satoshi user, it would always show me the default value again. Same when I tried setting it in /etc/security/limits.conf.

I also set a high value in /proc/sys/fs/file-max and ran sysctl -p to apply it, and that also didn't work.

I must be doing something terribly wrong for all the normal methods to fail like that.

Hmm: > Note that most process resource limits configured with these options are per-process, and processes may fork in order to acquire a new set of resources that are accounted independently of the original process, and may thus escape limits set So maybe it's worth fixing the ulimit after all. Unfortunately, the current ulimit cookbook and resource didn't work for me. When I opened a shell as the `satoshi` user, it would always show me the default value again. Same when I tried setting it in `/etc/security/limits.conf`. I also set a high value in `/proc/sys/fs/file-max` and ran `sysctl -p` to apply it, and that also didn't work. I must be doing something terribly wrong for all the normal methods to fail like that.
Owner

We're using the ulimit cookbook to set the file handle limit for dirsrv (2c40ad4591/site-cookbooks/kosmos-dirsrv/resources/instance.rb (L16-L18)) and that works on barnard:

$ ulimit -a | grep "open files"
open files                      (-n) 40960

Can you post the code you're using?

We're using the ulimit cookbook to set the file handle limit for dirsrv (https://gitea.kosmos.org/kosmos/chef/src/commit/2c40ad4591e277ae1d74d7510fdfd06f88a94222/site-cookbooks/kosmos-dirsrv/resources/instance.rb#L16-L18) and that works on barnard: ``` $ ulimit -a | grep "open files" open files (-n) 40960 ``` Can you post the code you're using?
Author
Owner

I used that exact code when trying it with that resource. The question is not so much about that resource as about none of the various methods working at all.

I used that exact code when trying it with that resource. The question is not so much about that resource as about *none* of the various methods working at all.
Author
Owner

I found out that limits from limits.conf don't apply to systemd services at all, but it still doesn't explain why opening a shell for that user still shows the default limit when there are entries in the config file that change it.

https://bugzilla.redhat.com/show_bug.cgi?id=754285

I found out that limits from `limits.conf` don't apply to systemd services at all, but it still doesn't explain why opening a shell for that user still shows the default limit when there are entries in the config file that change it. https://bugzilla.redhat.com/show_bug.cgi?id=754285
Author
Owner

OK, I also just confirmed that this is happening with a ulimit set correctly in a shell session when running the exec command manually. So the issue is something else.

Unfortunately, there's nobody on the Web who had the same issue with this program apparently. :/

OK, I also just confirmed that this is happening with a ulimit set correctly in a shell session when running the exec command manually. So the issue is something else. Unfortunately, there's nobody on the Web who had the same issue with this program apparently. :/
Author
Owner

Turns out that this is an unknown issue with encfs (and/or leveldb).

I pushed a change to only store the wallet data in encfs, but use the default directory (still configurable) for the rest.

As I nuked all data, it is currently re-syncing the whole chain. So I'm going to revisit this when sync is done.

Turns out that this is an unknown issue with encfs (and/or leveldb). I pushed a change to only store the wallet data in encfs, but use the default directory (still configurable) for the rest. As I nuked all data, it is currently re-syncing the whole chain. So I'm going to revisit this when sync is done.
Author
Owner

Another few improvements later, and it's finally finished! 🎉

Another few improvements later, and it's finally finished! 🎉
raucao changed title from WIP: Bitcoin (Core) cookbook to Bitcoin (Core) cookbook 2020-08-18 12:47:42 +00:00
greg requested changes 2020-08-19 12:51:51 +00:00
greg left a comment
Owner

Looks good to me apart from the Vagrant file change and the license file. I also don't see the ulimit change anywhere, did you forget to push it?

Looks good to me apart from the Vagrant file change and the license file. I also don't see the ulimit change anywhere, did you forget to push it?
Vagrantfile Outdated
@ -96,3 +96,3 @@
chef.add_recipe 'kosmos-base'
chef.add_recipe 'kosmos_encfs'
# chef.add_recipe 'kosmos-postgresql::default'
# chef.add_recipe 'kosmos-bitcoin::snapd'
Owner

I don't think that should have been checked in

I don't think that should have been checked in
Author
Owner

Why not? It's commented, so you can uncomment it to easily run the recipe locally. Same as all the other commented recipes.

Why not? It's commented, so you can uncomment it to easily run the recipe locally. Same as all the other commented recipes.
@ -0,0 +1,3 @@
Copyright 2019 The Authors
Owner

The license should be MIT like the other kosmos cookbooks

The license should be MIT like the other kosmos cookbooks
raucao marked this conversation as resolved
Author
Owner

I also don’t see the ulimit change anywhere, did you forget to push it?

Which ulimit change are you referring to?

> I also don’t see the ulimit change anywhere, did you forget to push it? Which ulimit change are you referring to?
raucao requested review from greg 2020-08-19 13:29:51 +00:00
Owner

Which ulimit change are you referring to?

I don't see the code that sets the file handle limit for the satoshi user

> Which ulimit change are you referring to? I don't see the code that sets the file handle limit for the satoshi user
Author
Owner

That's because...

I found out that limits from limits.conf don’t apply to systemd services at all

With systemd services, this is done via the LimitNOFILE config.

See https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Process%20Properties

(Which also makes the ulimit cookbook obsolete for anything that is run as a systemd service.)

That's because... > I found out that limits from limits.conf don’t apply to systemd services at all With systemd services, this is done via the `LimitNOFILE` config. See https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Process%20Properties (Which also makes the ulimit cookbook obsolete for anything that is run as a systemd service.)
greg approved these changes 2020-08-20 15:20:51 +00:00
greg left a comment
Owner

LGTM!

I didn't see the LimitNOFILE option in the systemd unit

LGTM! I didn't see the `LimitNOFILE` option in the systemd unit
greg merged commit 414a595719 into master 2020-08-20 17:17:31 +00:00
greg deleted branch feature/bitcoin_cookbook 2020-08-20 17:17:38 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: kosmos/chef#121
No description provided.