chef-boneyard / chef-provisioning-google

Chef Provisioning driver for the Google Cloud Platform
Apache License 2.0
8 stars 8 forks source link

Refactored the client code and added tests #5

Closed Lykos closed 7 years ago

Lykos commented 8 years ago
Temikus commented 8 years ago

@Lykos See my small comment + I do have issues starting up if I rebase on your PR with the following repro, I'm digging into it:

temikus λ bundle exec chef-client --color -z test_cluster.rb
[2016-02-22T14:46:58-08:00] WARN: No config file found or specified on command line, using command line options.
[2016-02-22T14:46:58-08:00] WARN: No cookbooks directory found at or above current directory.  Assuming /Users/temikus/Code/chef-dev/chef-provisioning-google.
Starting Chef Client, version 12.5.1
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Compiling Cookbooks...
[2016-02-22T14:47:03-08:00] WARN: Node a-macbook.contozo.com has an empty run list.
Converging 2 resources
Recipe: @recipe_files::/Users/temikus/Code/chef-dev/chef-provisioning-google/test_cluster.rb
  * google_key_pair[chef-provisioning] action create[2016-02-22T14:47:03-08:00] WARN: Class Chef::Provider::GoogleKeyPair does not declare 'provides :google_key_pair'.
[2016-02-22T14:47:03-08:00] WARN: This will no longer work in Chef 13: you must use 'provides' to use the resource's DSL.

    - adding key for username temikus
    - ensuring we store metadata mapping for google_key_pair[chef-provisioning]
    ================================================================================
    Error executing action `create` on resource 'google_key_pair[chef-provisioning]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `projects_client' for #<Chef::Provisioning::GoogleDriver::Driver:0x007fe592163c60>

    Resource Declaration:
    ---------------------
    # In /Users/temikus/Dropbox/Code/chef-dev/chef-provisioning-google/test_cluster.rb

     11: google_key_pair "chef-provisioning" do
     12:   private_key_path 'google_nouveaux'
     13:   public_key_path 'google_nouveaux.pub'
     14:   allow_overwrite true
     15: end
     16:

    Compiled Resource:
    ------------------
    # Declared in /Users/temikus/Dropbox/Code/chef-dev/chef-provisioning-google/test_cluster.rb:11:in `from_file'

    google_key_pair("chef-provisioning") do
      action [:create]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :google_key_pair
      cookbook_name "@recipe_files"
      recipe_name "/Users/temikus/Code/chef-dev/chef-provisioning-google/test_cluster.rb"
      private_key_path "/Users/temikus/.chef/keys/google_nouveaux"
      public_key_path "/Users/temikus/.chef/keys/google_nouveaux.pub"
      allow_overwrite true
    end

Running handlers:
[2016-02-22T14:47:05-08:00] ERROR: Running exception handlers
Running handlers complete
[2016-02-22T14:47:05-08:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 07 seconds
[2016-02-22T14:47:05-08:00] FATAL: Stacktrace dumped to /Users/temikus/.chef/local-mode-cache/cache/chef-stacktrace.out
[2016-02-22T14:47:05-08:00] ERROR: google_key_pair[chef-provisioning] (@recipe_files::/Users/temikus/chef-dev/chef-provisioning-google/test_cluster.rb line 11) had an error: NoMethodError: undefined method `projects_client' for #<Chef::Provisioning::GoogleDriver::Driver:0x007fe592163c60>
[2016-02-22T14:47:05-08:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

With the following recipe:

require 'chef/provisioning/google_driver'

with_driver 'google:us-central1-a:dev-utility-AAAAA',
  :google_credentials => {
    :json_key_path => '/Users/temikus/.gce/graphite-sandbox-xxxxx.json',
  }

google_key_pair "chef-provisioning" do
  private_key_path 'google_nouveaux'
  public_key_path 'google_nouveaux.pub'
  allow_overwrite true
end

machine 'chef-provisioning-test-basic' do
  machine_options key_name: 'google_nouveaux'
  action [:converge, :destroy]
end
Temikus commented 8 years ago

@Lykos See my comments above, esp. the key creation issues, I think we need to make sure to test all scenarios - key doesn't exist and gets created, key exists, key exists but doesn't match, etc.

Otherwise - looks good so far :+1:

Lykos commented 8 years ago

Fixed the issues.

Temikus commented 8 years ago

@tyler-ball, @someara, can you please take a look?

/CC @erjohnso

tas50 commented 7 years ago

Closing in favor of #8