0

vagrant ボックスに 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)
4

2 に答える 2

2

Berkshelf ワークフローを使用しようとした後、Windows ホストで実行されている vagrant (または Virtual Box だと思いますか?) の CentOS ゲストでは実際には機能しないことがわかりました。これは、上記で指摘したタイムアウトの問題が原因です。私のハッキーな修正はこれでした。これを変数として渡すことができる拡張機能をプッシュする方がおそらく良いでしょう。

ここで、ChefDK の埋め込みルビーと berkshelf gem を使用していると仮定します。そうでない場合、場所は他の場所にある可能性があります。

特定のクラスの詳細については、こちらをご覧ください。

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)

保存して閉じ、もう一度試してください。

于 2014-09-23T17:05:28.327 に答える
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>]
于 2014-09-05T18:00:32.900 に答える