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

service[zookeeper] cannot be found in the resource collection. #186

Open
eyalzek opened this issue Aug 31, 2016 · 10 comments
Open

service[zookeeper] cannot be found in the resource collection. #186

eyalzek opened this issue Aug 31, 2016 · 10 comments
Assignees
Labels

Comments

@eyalzek
Copy link

eyalzek commented Aug 31, 2016

I am trying to create a simple wrapper cookbook for zookeeper-cookbook, here's my configuration:

zookeeper node[cookbook_name]['version'] do
  mirror node[cookbook_name]['mirror']
  checksum node[cookbook_name]['checksum']
  action :install
end

config_hash = {
  clientPort: 2181,
  dataDir: '/var/zookeeper',
  tickTime: 2000,
  autopurge: {
    purgeInterval: 24
  },
  initLimit: 10,
  syncLimit: 5
}

zookeeper_config 'zoo.cfg' do
  config config_hash
  action :render
  notifies :restart, 'service[zookeeper]', :delayed
end

zookeeper_service 'zookeeper'

The line notifies :restart, 'service[zookeeper]', :delayed is obviously what fails me here. I tried using include_recipe 'zookeeper::service even though it's pretty much identical from what I understood reading the code, and the results are the same:

ERROR: resource zookeeper_config[zoo.cfg] is configured to notify resource service[zookeeper] with action restart, but service[zookeeper] cannot be found in the resource collection.

I realize I might be doing something wrong here, but considering I want to install, configure and create a service, but also that the service would restart on a configuration change, how should I go at it?

@jeffbyrnes jeffbyrnes self-assigned this Aug 31, 2016
@jeffbyrnes jeffbyrnes added the bug label Aug 31, 2016
@jeffbyrnes
Copy link
Contributor

@eyalzek hmm… seems some refactor of the actions for zookeeper_service is in order. It should provide a mechanism to pass through any notifications to its inner resources (as it is an abstraction of your chosen service provider).

The technical reason for the error is because service[zookeeper] doesn’t exist in the scope of your recipe; it’s inside the inner scope of the zookeeper_service[zookeeper] resource you have.

For now, you can get things up & running by omitting the notifies, and manually restart ZK.

I’d welcome some help with this, as I likely won’t have much time to devote to this for a while.

@eyalzek
Copy link
Author

eyalzek commented Sep 1, 2016

I took a look at it and as you said, it seems like it requires a refactor more than a minor 2-line change. I might be able to help if you point me in the right direction.

@jeffbyrnes
Copy link
Contributor

@eyalzek thanks! If you check out resources/service.rb, you’ll see that it has two actions:

  • :create
  • :delete

Taking a cue from poise_service, I think it’s better if it had a set of actions that correspond 1:1 with the underlying service resources:

actions :enable, :disable, :start, :stop, :restart, :reload

In fact, now that I think about it, it might be sensible to just use poise_service, since that solves this for us…

@cullenmcdermott
Copy link

cullenmcdermott commented Oct 1, 2016

I took a crack at using poise-service to create the zookeeper_service resource. So far I've only implemented it with upstart(and poorly at that) and wanted to get your thoughts before putting much more time into this.

@jeffbyrnes
Copy link
Contributor

@cullenmcdermott oh nice! That looks pretty good so far. If you want to open a pull request with that work, we can try to get it fully fleshed out together.

Two notes:

  • Please leave the version number alone in the PR (I’ll handle that on master when the code merges in & I can properly release it)
  • Rather than comment out the content of resources/service.rb, just delete the file

@cullenmcdermott
Copy link

Hey sorry, its been a crazy week so far. I'll try to get a PR submitted tonight or tomorrow. Something with what I had committed so far wasn't working so I refactored it a bit and have it working better now.

@cullenmcdermott
Copy link

@jeffbyrnes I just created #191

@heaven
Copy link

heaven commented Jan 30, 2018

Hi, any chance this will be merged?

We have a large cluster and need an ability to restart the service on config change when new servers added/removed.

@jeffbyrnes
Copy link
Contributor

@heaven I wager you mean #191?

tl;dr, probably not anytime soon.

I’ve had very few cycles to put towards this, especially since I no longer use ZK (job change, no need for it at the new gig).

However, I caution: this would not handle restarts gracefully (i.e., rolling restart), and thus the potential for data loss exists.

In the past, I’ve solved that with Exhibitor, but that project has seen some ups & downs since it’s departure from Netflix, so I recommend taking a hard look at it. We’ve a cookbook that used to play nicely with this one for managing all of that, but again, maintenance has been minimal lately.

Moving forward, the ZooKeeper team is focused on providing dynamic configuration, including resizing of the cluster. It’s available starting in v3.5.0, and here are the latest docs for v3.5.3-beta.

I realize using software that’s yet to be marked stable may not be an option, and this cookbook doesn’t even properly support v3.5.x, so that may not be optimal, but perhaps you can pick up #199 and finish up the v3.5.x support, and use that.

Sorry I’m not able to offer more support, and since I’m not the owner of this, I can’t exactly hand off maintenance (though I do still possess admin, so I can grant contributor if you want to step in).

@jeffbyrnes
Copy link
Contributor

@heaven so I did manage to squeeze in some work and get the zookeeper-env.sh fixes (and some others) done & released as v10.0.0.

Fixing this is a much larger refactor, where the zookeeper_service resource is rewritten to be a more direct wrapper around its internals. I would very much welcome any assistance with that; #191 is a good starting point.

And as I said, it might be good to get #199 finished up.

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

No branches or pull requests

4 participants