cisco / cisco-network-puppet-module

Apache License 2.0
55 stars 68 forks source link

Adding in details on the net_http_unix dependency #549

Closed Thomas-Franklin closed 5 years ago

mikewiebe commented 5 years ago

@Thomas-Franklin Not sure we need to be explicit here. When the cisco_node_utils gem is installed from rubygems.org the net_http_unix is automatically installed.

agent-ci-42:~:2010> gem list | grep cisco_node_utils
agent-ci-42:~:2011> gem list | grep net_http_unix
agent-ci-42:~:2012> 
agent-ci-42:~:2012> gem install cisco_node_utils
Fetching: cisco_node_utils-2.0.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed cisco_node_utils-2.0.1
Parsing documentation for cisco_node_utils-2.0.1
Installing ri documentation for cisco_node_utils-2.0.1
Done installing documentation for cisco_node_utils after 7 seconds
1 gem installed
agent-ci-42:~:2013> 
agent-ci-42:~:2013> gem list | grep cisco_node_utils
cisco_node_utils (2.0.1)
agent-ci-42:~:2014> gem list | grep net_http_unix
net_http_unix (0.2.2)
agent-ci-42:~:2015> 
DavidS commented 5 years ago

This seems to be an artefact of your test environment. If I create a new gemset/bundle, cisco_node_utils does not pull in net_http_unix:

david@davids:~/tmp$ mkdir cisco_gem_test
david@davids:~/tmp$ cd cisco_gem_test/
david@davids:~/tmp/cisco_gem_test$ bundle init
Writing new Gemfile to /home/david/tmp/cisco_gem_test/Gemfile
david@davids:~/tmp/cisco_gem_test$ vi Gemfile 
david@davids:~/tmp/cisco_gem_test$ cat Gemfile 
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"
gem 'cisco_node_utils'
david@davids:~/tmp/cisco_gem_test$ bundle install --path ~/gems
Fetching gem metadata from https://rubygems.org/...
Resolving dependencies...
Using bundler 1.17.3
Fetching cisco_node_utils 2.0.1
Installing cisco_node_utils 2.0.1 with native extensions
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Bundled gems are installed into `/home/david/gems`
david@davids:~/tmp/cisco_gem_test$ bundle list net_http_unix
Could not find gem 'net_http_unix'.
david@davids:~/tmp/cisco_gem_test$ 

Edit: also looking at the dependencies on https://rubygems.org/gems/cisco_node_utils I don't see what should pull in the net_http_unix gem.

mikewiebe commented 5 years ago

@DavidS What happens if you just issue the gem install cisco_node_utils by itself to install from rubygems.org?

DavidS commented 5 years ago

I think I found it. When installing using gem install directly, it does pull in net_http_unix and grpc through https://github.com/cisco/cisco-network-node-utils/blob/a393fb7d6aecc19b05dbac8879a5485651f8b851/ext/mkrf_conf.rb

When using bundler this fails to make the gem available as bundler is not exposing any randomly installed gems into the development environment.

Since the cisco_node_utils dependencies are not clearly declared, I'd definitely prefer to be explicit in the install class to avoid future surprises.

Reading the mkrf_conf code also makes me wonder whether we couldn't simplify this a lot by ripping out the unused(?) XR code. At that point it would be an unconditional install of net_http_unix and we could lift that to the gemspec and get rid of all that magic.

mikewiebe commented 5 years ago

@DavidS I am fine with being more explicit. We would like to remove the XR code from cisco_node_utils but that will be a bigger effort to test through all the various NX-OS platforms and ensure we don't break anything in the process.