我在流浪盒上安装了ChecfDK。
Brekshelf运作不佳。无法连接无法连接
我检查了Iptables等,但在网络上找不到问题。 URL可以通过curl获得,并且可以在ubuntu框上正常工作。
CentOS(https://github.com/takase1024/chefdk-centos)
[vagrant@vagrant-centos65 ~]$ cd /vagrant/berks
[vagrant@vagrant-centos65 berks]$ berks install
Resolving cookbook dependencies...
Fetching 'myapp' from source at .
Fetching cookbook index from http://api.berkshelf.com/...
Error retrieving universe from source: http://api.berkshelf.com/
* [Berkshelf::APIClient::TimeoutError] Unable to connect to: http://api.berkshelf.com/
E, [2014-08-25T03:14:08.122005 #1776] ERROR -- : Actor crashed!
Berkshelf::MissingLockfileCookbookVersion: Cookbook 'apache2' (2.0.0) not found in any of the sources! This can happen if the remote cookbook has been deleted or if the sources inside the Berksfile have changed. Please run `berks update apache2` to resolve to a valid version.
/opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/installer.rb:95:in `install'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/calls.rb:26:in `public_send'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/calls.rb:26:in `dispatch'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/calls.rb:63:in `dispatch'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/cell.rb:60:in `block in invoke'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/cell.rb:71:in `block in task'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/actor.rb:369:in `block in task'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/tasks.rb:55:in `block in initialize'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'
E, [2014-08-25T03:14:08.123992 #1776] ERROR -- : Actor crashed!
Berkshelf::MissingLockfileCookbookVersion: Cookbook 'iptables' (0.13.2) not found in any of the sources! This can happen if the remote cookbook has been deleted or if the sources inside the Berksfile have changed. Please run `berks update iptables` to resolve to a valid version.
/opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/installer.rb:95:in `install'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/calls.rb:26:in `public_send'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/calls.rb:26:in `dispatch'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/calls.rb:63:in `dispatch'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/cell.rb:60:in `block in invoke'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/cell.rb:71:in `block in task'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/actor.rb:369:in `block in task'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/tasks.rb:55:in `block in initialize'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'
Cookbook 'apache2' (2.0.0) not found in any of the sources! This can happen if the remote cookbook has been deleted or if the sources inside the Berksfile have changed. Please run `berks update apache2` to resolve to a valid version.
(Following omitted)
[vagrant@vagrant-centos65 berks]$ curl http://api.berkshelf.com/
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
(Following omitted)
答案 0 :(得分:2)
在尝试使用Berkshelf工作流程后,我发现它并不真正适用于在Windows主机上运行的流浪者(或者我猜虚拟盒子?)。这是因为如上所述的超时问题。我的hacky修复就是这个。我知道推送一个允许你传递它的增强可能会更好。
现在我假设你正在使用ChefDK的嵌入式红宝石和berkshelf宝石。如果没有,位置可能在其他地方。
在此处阅读有关特定课程的更多信息:
http://ruby-doc.org/gems/docs/b/berkshelf-api-client-1.2.0/Berkshelf/APIClient/Connection.html
[vagrant@vagrant-centos65 apache-acquity]$ cd /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-api-client-1.2.0/
lib/berkshelf/api_client
[vagrant@vagrant-centos65 api_client]$ vim connection.rb
找到这个:
def initialize(url, options = {})
options = options.reverse_merge(retries: 3, retry_interval: 0.5,
open_timeout: 3, timeout: 30)
并改为:
def initialize(url, options = {})
options = options.reverse_merge(retries: 3, retry_interval: 0.5,
open_timeout: 30, timeout: 30)
保存并关闭并再次尝试。
答案 1 :(得分:0)
这看起来可能是berkshelf-api-client选项的问题。默认情况下,open_timeout选项设置为3秒。通过增加此超时,我能够获得成功的连接。
1.9.3-p547 :010 > source = Berkshelf::Source.new("http://berkshelf.example.come")
=> #<Berkshelf::Source uri: "http://berkshelf.example.com">
1.9.3-p547 :011 > api = source.send(:api_client)
=> #<Berkshelf::APIClient::Connection:0x00000001b613f8 @url="http://berkshelf.example.com", @retries=3, @retry_interval=0.5, @parallel_manager=nil, @headers={"User-Agent"=>"Faraday v0.9.0"}, @params={}, @options=#<Faraday::RequestOptions timeout=30, open_timeout=3>, @ssl=#<Faraday::SSLOptions (empty)>, @default_parallel_manager=nil, @builder=#<Faraday::RackBuilder:0x00000001b612b8 @handlers=[Ridley::Middleware::ParseJson, Ridley::Middleware::Gzip, Faraday::Request::Retry, Faraday::Adapter::NetHttp]>, @url_prefix=#<URI::HTTP:0x000000023938a0 URL:http://berkshelf.example.com/>, @proxy=nil>
1.9.3-p547 :012 > api.universe
错误:
Berkshelf::APIClient::TimeoutError: Unable to connect to: http://berkshelf.example.com
现在,如果我按如下方式修改APIClient使用的选项:
1.9.3-p547 :012 > opts = api.options
=> #<Faraday::RequestOptions timeout=30, open_timeout=3>
1.9.3-p547 :013 > opts.open_timeout = 30
=> 30
1.9.3-p547 :014 > api.instance_eval { @options = opts }
=> #<Faraday::RequestOptions timeout=30, open_timeout=30>
成功:
1.9.3-p547 :015 > api.universe
=> [#<Berkshelf::APIClient::RemoteCookbook:0x00000002a30320 @blah=blah @etc=true>]