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

consul_ui resource does not work #255

Closed
nicxvan opened this issue Dec 11, 2015 · 15 comments
Closed

consul_ui resource does not work #255

nicxvan opened this issue Dec 11, 2015 · 15 comments

Comments

@nicxvan
Copy link

nicxvan commented Dec 11, 2015

When attempting to converge my wrapper cookbook I get an error:

[2015-12-11T15:52:51+00:00] ERROR: consul_ui[consul] () had an error: KeyError: key not found: "0.6.0_web_ui"

Here is my resource declaration:

consul_ui 'consul' do
    version '0.6.0'
    binary_url 'https://releases.hashicorp.com/consul/0.6.0/consul_0.6.0_web_ui.zip'
    install_path node['cookbook_consul']['ui_path']
    action [:install]
end

Note that I overrode the binary url as well since the resource generates the wrong url, I did see a pull request to fix that though.

The key does exist in the attributes file under ['consul']['checksums']
and the attribute is called in the resource definition:

def binary_checksum
        node['consul']['checksums'].fetch(binary_filename)
      end
@Ginja
Copy link
Contributor

Ginja commented Dec 11, 2015

Had the same issue. This should be fixed with #252.

@nicxvan
Copy link
Author

nicxvan commented Dec 11, 2015

@Ginja Not quite, the download piece will fix my needing to override the binary_url attribute, but it doesn't fix the primary issue with the consul_ui resource.

The resource is not finding the checksum so it's failing, if you see in the error it's saying the key doesn't exist even though the attribute does exist for 0.6.0_web_ui

@scalp42
Copy link
Contributor

scalp42 commented Dec 11, 2015

@nicxvan do you have a fix ? I'll try to get to it next week if not.

@Ginja
Copy link
Contributor

Ginja commented Dec 11, 2015

@nicxvan I still believe #252 does fix your issue. The reason it couldn't find the checksum was because they started prefixing their download URLs with consul. I changed all the keys for the checksum attributes to have consul before their version. I also changed the binary_filename method to add consul before the version and text web_ui. This should properly fetch the 'consul_0.6.0_web_ui' key from the node['consul']['checksums'] hash.

# attributes/default.rb
default['consul']['checksums'] = {
  ...,
  ...,
  'consul_0.6.0_web_ui'        => '73c5e7ee50bb4a2efe56331d330e6d7dbf46335599c028344ccc4031c0c32eb0'
}

# libraries/consul_ui.rb
      def binary_checksum
        # binary_filename will return 'consul_0.6.0_web_ui'
        node['consul']['checksums'].fetch(binary_filename)
      end

      def binary_filename
        ['consul', version, 'web_ui'].join('_')
      end

Try using the latest code from the master branch, and let me know if it doesn't work.

EDIT: Hold up, I didn't see PR #253 was merged. I believe your issue is once again valid. The default value for:binary_url will now return consul_consul_0.6.0_web_ui when this is executed:

# libraries/consul_ui.rb
attribute(:binary_url, kind_of: String, default: 'https://releases.hashicorp.com/consul/%{version}/consul_%{filename}.zip')

remote_url new_resource.binary_url % { version: new_resource.version, filename: new_resource.binary_filename }

If you're going to test #252, use the commit before that PR was merged (ede4642).

@nicxvan
Copy link
Author

nicxvan commented Dec 11, 2015

@scalp42 I do not have a fix.

@Ginja You may be right, I was looking at master not the right tag, using version 0.5.2 it converges, but I just get another copy of the binary in the directory, not the web ui that I got when manually downloading

@nicxvan
Copy link
Author

nicxvan commented Dec 11, 2015

@Ginja What you said is partially right, if I download the web_ui manually I get an archive with the dist folder and the ui works, if I use the resource I end up with another binary in the location I specify in the directory attribute.

@Ginja
Copy link
Contributor

Ginja commented Dec 11, 2015

@nicxvan Could you elaborate (e.g. show your resources & properties/attributes set in both examples)?

@nicxvan
Copy link
Author

nicxvan commented Dec 11, 2015

Attributes:

default['cookbook_consul']['ui_path'] = '/srv/consul/ui'

Recipe / resource:

node.default['consul']['config']['path'] = '/etc/consul/default.json'

include_recipe 'consul::default'
consul_config 'consul' do
  server true
  path node['consul']['config']['path']
  bootstrap_expect 1
  ui_dir node['cookbook_consul']['ui_path']
end
directory '/srv/consul' do
  owner 'consul'
  group 'consul'
  mode '0755'
  action :create
end

directory '/srv/consul/ui' do
  owner 'consul'
  group 'consul'
  mode '0755'
  action :create
end
consul_ui 'consul' do
  version '0.5.2'
  binary_url 'https://releases.hashicorp.com/consul/0.5.2/consul_0.5.2_web_ui.zip'
  install_path node['cookbook_consul']['ui_path']
  action [:install]
end

Thanks!

@scalp42
Copy link
Contributor

scalp42 commented Dec 12, 2015

@nicxvan any chance you can use markdown ?

just add ```ruby at top and 3 backticks at bottom.

Thanks!

@nicxvan
Copy link
Author

nicxvan commented Dec 12, 2015

Sorry @scalp42 It's now formatted.

@Ginja
Copy link
Contributor

Ginja commented Dec 12, 2015

I think you need to change your install_path property to the containing folder. For example, this is how I declared the consul_ui resource:

node['consul']['config']['ui_dir'] = '/opt/consul-ui/current'

# "/#{node['consul']['config']['ui_dir'].split('/')[1]}" == '/opt'
consul_ui 'consul-ui' do
  install_path "/#{node['consul']['config']['ui_dir'].split('/')[1]}"
  owner node['consul']['service_user']
  group node['consul']['service_group']
  version node['consul']['version']
end

After Chef runs, the directory layout on my filesystem looks like:

$ ls /opt/
consul-ui
$ ls -lF /opt/consul-ui/
0.6.0/
current -> /opt/consul-ui/0.6.0/

@nicxvan
Copy link
Author

nicxvan commented Dec 14, 2015

Thanks @Ginja I tried that but it didn't work. I ended up trying this:

install_path "/#{node['cookbook_consul']['ui_path'].split('/')[1]}"

And get this structure with no response on 8500 after converging:

-----> Kitchen is finished. (0m21.42s)
zlib(finalizer): the stream was freed prematurely.
:/opt/repos/cookbook_wrapper_consul$ kitchen login
Last login: Mon Dec 14 15:47:49 2015 from 10.0.2.2
[vagrant@default-centos-71 ~]$ curl http://localhost:8500
curl: (7) Failed connect to localhost:8500; Connection refused
[vagrant@default-centos-71 ~]$ ls -al /srv/consul/ui/consul/
0.5.2/   current/ 
[vagrant@default-centos-71 ~]$ ls -al /srv/consul/ui/consul/current/
total 17820
drwxr-xr-x 2 consul consul       19 Dec 11 22:46 .
drwxr-xr-x 3 consul consul       32 Dec 11 22:34 ..
-rwxr-xr-x 1 consul consul 18245010 Dec 11 22:46 consul
[vagrant@default-centos-71 ~]$ ls -al /srv/consul/ui/consul/
total 0
drwxr-xr-x 3 consul consul 32 Dec 11 22:34 .
drwxr-xr-x 3 consul consul 19 Dec 11 22:34 ..
drwxr-xr-x 2 consul consul 19 Dec 11 22:46 0.5.2
lrwxrwxrwx 1 root   root   27 Dec 11 22:34 current -> /srv/consul/ui/consul/0.5.2
[vagrant@default-centos-71 ~]$ curl http://localhost:8500/#/ui
curl: (7) Failed connect to localhost:8500; Connection refused
[vagrant@default-centos-71 ~]$ 

@Ginja
Copy link
Contributor

Ginja commented Dec 14, 2015

A couple of things to check:

  • Is your Consul agent running? ps aux | grep consul
  • Is your Firewall on & does it have a rule for port 8500? systemctl disable firewalld
  • Is anything listening? netstat -napt |grep -i LISTEN

@nicxvan
Copy link
Author

nicxvan commented Dec 14, 2015

Hmm sometimes is the most obvious things, consul is not running, how do you kick off the start with chef? I thought the config_resource took care of that.

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants