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

kitchen fails with error 'vAPI: vapi.data.invalid: value does not have expected type' #22

Closed
seven10builder opened this issue Jan 11, 2018 · 12 comments
Assignees
Labels
Type: Bug Does not work as expected.

Comments

@seven10builder
Copy link

seven10builder commented Jan 11, 2018

Versions:

  • Version of kitchen-vcenter: 1.2.1
  • Version of test-kitchen: 1.19.2
  • Version of chef: ChefDK 2.4.17

Platform Details

  • Version of vCenter: 6.5.0
  • Version of ESXi: 6.5.0 (build 5969303)

Scenario:

I am trying to start a test-kitchen instance on our local vcenter. I have previously tested this cookbook using ec2, but now want to run it locally.

Steps to Reproduce:

I followed the steps listed in the current MASTER branch README.md. My .kitchen.yml file looks like the following

---
driver:
  name: vcenter
  vcenter_username: <%= ENV['VCENTER_USER'] || "[email protected]" %>
  vcenter_password: <%= ENV['VCENTER_PASSWORD'] || "TOTALLY_NOT_MY_PASSWD" %>
  vcenter_host: 'VCENTER_HOST_ADDRESS'
  vcenter_disable_ssl_verify: true
  driver_config:
    datacenter: 'MY_DATACENTER_NAME'
    template: 'Ubuntu-16.04'
    targethost: 'MY_HOST_ADDRESS'
    resource_pool: 'DeployTest'

provisioner:
  name: chef_zero
  # You may wish to disable always updating cookbooks in CI or other testing environments.
  # For example:
  #   always_update_cookbooks: <%= !ENV['CI'] %>
  always_update_cookbooks: false
  sudo_command: sudo

verifier:
  name: inspec

transport:
  user: ubuntu
  password: password

platforms:
  - name: ubuntu-16.04

suites:
  - name: default
    data_bags_path: "test/integration/default/data_bags"
    encrypted_data_bag_secret_key_path: "test/integration/default/encrypted_data_bag_secret"

    run_list:
      - recipe[hydra-base::default]
    verifier:
      inspec_tests:
        - test/smoke/default
    attributes: {}

Expected Result:

An instance is created and the various kitchen tasks are executed.

Actual Result:

executed according to this:

-----> Starting Kitchen (v1.19.2)
WARN: Unresolved specs during Gem::Specification.reset:
      rake (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
-----> Creating <default-ubuntu-1604>...
E, [2018-01-11T16:14:58.516537 #21252] ERROR -- vAPI: vapi.data.invalid: value does not have expected type
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [vapi.data.invalid: value does not have expected type] on default-ubuntu-1604
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
@jjasghar jjasghar self-assigned this Jan 11, 2018
@jjasghar jjasghar added the bug label Jan 11, 2018
@seven10builder
Copy link
Author

Output from kitchen diagnose --all:

kmm@kmilner ~/workspace/hydra-chef/cookbooks/hydra-base $ /opt/chefdk/embedded/bin/kitchen diagnose --all
WARN: Unresolved specs during Gem::Specification.reset:
      rake (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
---
timestamp: 2018-01-11 21:19:44 UTC
kitchen_version: 1.19.2
plugins:
  driver:
    Vcenter:
      class: Kitchen::Driver::Vcenter
      version: 
      api_version: 
  provisioner:
    ChefZero:
      class: Kitchen::Provisioner::ChefZero
      version: 1.19.2
      api_version: 2
  transport:
    Ssh:
      class: Kitchen::Transport::Ssh
      version: 1.19.2
      api_version: 1
  verifier:
    Inspec:
      class: Kitchen::Verifier::Inspec
      version: 0.20.0
      api_version: 1
loader:
  process_erb: true
  process_local: true
  process_global: true
  global_config: 
  project_config:
    filename: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base/.kitchen.yml"
    raw_data:
      driver:
        name: vcenter
        vcenter_username: [email protected]
        vcenter_password: TOTALLY_NOT_MY_PASSWD
        vcenter_host: VCENTER_HOST_ADDRESS
        vcenter_disable_ssl_verify: true
        driver_config:
          datacenter: MY_DATA_CENTER
          template: Ubuntu-16.04
          targethost: MY_HOST_ADDRESS
          resource_pool: DeployTest
      provisioner:
        name: chef_zero
        always_update_cookbooks: false
        sudo_command: sudo
      verifier:
        name: inspec
      transport:
        user: ubuntu
        password: password
      platforms:
      - name: ubuntu-16.04
      suites:
      - name: default
        data_bags_path: test/integration/default/data_bags
        encrypted_data_bag_secret_key_path: test/integration/default/encrypted_data_bag_secret
        run_list:
        - recipe[hydra-base::default]
        verifier:
          inspec_tests:
          - test/smoke/default
        attributes: {}
  local_config: 
  combined_config:
    filename: 
    raw_data:
      driver:
        name: vcenter
        vcenter_username: [email protected]
        vcenter_password: TOTALLY_NOT_MY_PASSWD
        vcenter_host: VCENTER_HOST_ADDRESS
        vcenter_disable_ssl_verify: true
        driver_config:
          datacenter: MY_DATA_CENTER
          template: Ubuntu-16.04
          targethost: MY_HOST_ADDRESS
          resource_pool: DeployTest
      provisioner:
        name: chef_zero
        always_update_cookbooks: false
        sudo_command: sudo
      verifier:
        name: inspec
      transport:
        user: ubuntu
        password: password
      platforms:
      - name: ubuntu-16.04
      suites:
      - name: default
        data_bags_path: test/integration/default/data_bags
        encrypted_data_bag_secret_key_path: test/integration/default/encrypted_data_bag_secret
        run_list:
        - recipe[hydra-base::default]
        verifier:
          inspec_tests:
          - test/smoke/default
        attributes: {}
instances:
  default-ubuntu-1604:
    platform:
      os_type: unix
      shell_type: bourne
    state_file:
      last_error: RuntimeError
    driver:
      datacenter: 
      driver_config:
        datacenter: MY_DATA_CENTER
        template: Ubuntu-16.04
        targethost: MY_HOST_ADDRESS
        resource_pool: DeployTest
      folder: 
      kitchen_root: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base"
      log_level: :info
      name: vcenter
      poweron: true
      pre_create_command: 
      resource_pool: 
      targethost: 
      template: 
      test_base_path: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base/test/integration"
      vcenter_disable_ssl_verify: true
      vcenter_host: VCENTER_HOST_ADDRESS
      vcenter_password: TOTALLY_NOT_MY_PASSWD
      vcenter_username: [email protected]
      vm_name: 
    provisioner:
      always_update_cookbooks: false
      architecture: 
      attributes: {}
      channel: :stable
      checksum: 
      chef_client_path: "/bin/chef-client"
      chef_omnibus_install_options: 
      chef_omnibus_url: https://omnitruck.chef.io/install.sh
      chef_zero_host: 
      chef_zero_port: 8889
      client_rb: {}
      clients_path: 
      command_prefix: 
      config_path: 
      cookbook_files_glob: README.*,metadata.{json,rb},attributes/**/*,definitions/**/*,files/**/*,libraries/**/*,providers/**/*,recipes/**/*,resources/**/*,templates/**/*
      data_bags_path: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base/test/integration/default/data_bags"
      data_path: 
      debug: 
      deprecations_as_errors: false
      download_url: 
      encrypted_data_bag_secret_key_path: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base/test/integration/default/encrypted_data_bag_secret"
      enforce_idempotency: false
      environments_path: 
      ftp_proxy: 
      http_proxy: 
      https_proxy: 
      install_strategy: once
      json_attributes: true
      kitchen_root: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base"
      log_file: 
      log_level: auto
      max_retries: 1
      multiple_converge: 1
      name: chef_zero
      named_run_list: {}
      nodes_path: 
      platform: 
      platform_version: 
      policyfile: 
      policyfile_path: 
      product_name: 
      product_version: :latest
      profile_ruby: false
      require_chef_omnibus: true
      retry_on_exit_code:
      - 35
      - 213
      roles_path: 
      root_path: "/tmp/kitchen"
      ruby_bindir: "/embedded/bin"
      run_list:
      - recipe[hydra-base::default]
      sudo: true
      sudo_command: sudo
      test_base_path: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base/test/integration"
      wait_for_retry: 30
    transport:
      compression: false
      compression_level: 0
      connection_retries: 5
      connection_retry_sleep: 1
      connection_timeout: 15
      keepalive: true
      keepalive_interval: 60
      kitchen_root: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base"
      log_level: :info
      max_ssh_sessions: 9
      max_wait_until_ready: 600
      name: ssh
      password: password
      port: 22
      ssh_gateway: 
      ssh_gateway_username: 
      ssh_key: 
      test_base_path: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base/test/integration"
      user: ubuntu
      username: root
    verifier:
      chef_omnibus_root: "/opt/chef"
      command_prefix: 
      debug: 
      ftp_proxy: 
      http_proxy: 
      https_proxy: 
      inspec_tests:
      - test/smoke/default
      kitchen_root: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base"
      log_level: :info
      name: inspec
      root_path: "/tmp/verifier"
      sudo: true
      sudo_command: sudo -E
      suite_name: default
      test_base_path: "/home/kmm/workspace/hydra-chef/cookbooks/hydra-base/test/integration"

@nimDevOps
Copy link

I've had the same issue for some time as well.
I think this is documentation issue of the https://github.com/chef/kitchen-vcenter project.
If you read the second paragraph of Required parameters section :
The following parameters should be set in the driver_config for the individual platform.
template - Template or virtual machine to use when cloning the new machine
datacenter - Name of the datacenter to use to deploy into

So if you remove driver_config from driver section of .kitchem.yml file and move it to platform section, the error will disappear.

@jjasghar
Copy link
Contributor

@nimDevOps really?! I'll verify this thanks for the find!

@jjasghar
Copy link
Contributor

@nimDevOps was right!

Updated PR here, can i get a plus 1? #23

@nimDevOps
Copy link

I think it's global/local variable initialization issue. Usually datacenter config is global for all platforms, that's why it's configuration placed on very top. This may mean that datacanter configuration under platform is not initialized in this case and validation failed to accept empty string.

@nimDevOps
Copy link

error comes from ~/AppData/Local/chefdk/gem/ruby/2.4.0/gems/vsphere-automation-sdk-6.6.1/client/sdk/runtime/lib/vapi/data/value.rb

@jjasghar
Copy link
Contributor

@seven10builder did this fix your issue? If so please close this, otherwise lets continue debugging.

@nimDevOps
Copy link

nimDevOps commented Apr 3, 2018

After moving datacenter to platform original issue is not happening anymore (for me) but there is a new issue which I cannot solve: [Unable to find template: <template_name>].
My .kitchen.yml is very basic

driver:
name: vcenter
vcenter_username: <%= ENV['VCENTER_USER'] || "[email protected]" %>
vcenter_password: <%= ENV['VCENTER_PASSWORD'] || "P@ssw0rd!" %>
vcenter_host: <%= ENV['VCENTER_HOST'] || "localhost" %>
vcenter_disable_ssl_verify: true

provisioner:
name: chef_zero

transport:
name: winrm
elevated: true
password: vagrant
username: vagrant

platforms:

  • name: Agent
    driver_config:
    datacenter: tempDC
    template: WS2016_svn65.18
    folder: Cloud

suites:

  • name: WS2016
    run_list:
    • recipe[java_se::default]

----> Starting Kitchen (v1.20.0)
-----> Creating ...
Kitchen::Driver::Vcenter::create==>state=[{}]
LookupServiceHelper::==>initialize host=[tempvc.absciexdev.local]
Kitchen::Driver::Vcenter::get_host==>name=[]
DEBUG-ListValue: value=[[VAPI::Data::StructValue(com.vmware.vcenter.host.summary, {"host"=>VAPI::Data::StringValue(host-10), "name"=>VAPI::Data::StringValue(temphost.absciexdev.local), "connection_state"=>VAPI::Data::StringValue(CONNECTED), "power_state"=>VAPI::Data::OptionalValue(VAPI::Data::StringValue(POWERED_ON))})]]
Kitchen::Driver::Vcenter::get_resource_pool==>
DEBUG-ListValue: value=[[VAPI::Data::StructValue(com.vmware.vcenter.resource_pool.summary, {"name"=>VAPI::Data::StringValue(Resources), "resource_pool"=>VAPI::Data::StringValue(resgroup-8)})]]
Kitchen::Driver::Vcenter::datacenter_exists==>name=tempDC
DEBUG-ListValue: value=[[]]
DEBUG-ListValue: value=[[VAPI::Data::StructValue(com.vmware.vcenter.datacenter.summary, {"name"=>VAPI::Data::StringValue(tempDC), "datacenter"=>VAPI::Data::StringValue(datacenter-2)})]]
Kitchen::Driver::Vcenter::get_folder==>name=Cloud
DEBUG-ListValue: value=[[]]
DEBUG-ListValue: value=[[VAPI::Data::StructValue(com.vmware.vcenter.folder.summary, {"folder"=>VAPI::Data::StringValue(group-v137), "name"=>VAPI::Data::StringValue(Cloud), "type"=>VAPI::Data::StringValue(VIRTUAL_MACHINE)})]]
::Support::initialize==>options={:name=>"WS2016-Agent-2893774b", :targethost=>"host-10", :poweron=>true, :template=>"WS2016_svn65.18", :datacenter=>"tempDC", :folder=>{:name=>"Cloud", :id=>"group-v137"}, :resource_pool=>"resgroup-8"}
::Support::clone==>
::Support::clone==>dc=[Datacenter("datacenter-2")]

------Exception-------
Class: Kitchen::ActionFailed
Message: 1 actions failed.
Failed to complete #create action: [Unable to find template: WS2016_svn65.18] on WS2016-Agent

Please see .kitchen/logs/kitchen.log for more details
Also try running kitchen diagnose --all for configuration

Any help is appreciated

@jjasghar
Copy link
Contributor

jjasghar commented Apr 3, 2018

are your templates in folders?

@nimDevOps
Copy link

yes, I have Work1/Cloud folder and template WS2016_svn65.18 is there, inside Cloud folder.

@nimDevOps
Copy link

@jjasghar , just found this issue: vmware-archive/rbvmomi#117 of rbvmomi API. I have version 1.11.6 and it looks like finding VMs in folders is broken in this version. After I moved my template out of any folders, cloning started to work.

@jjasghar
Copy link
Contributor

jjasghar commented Apr 4, 2018

Awesome! I'm going ahead to close this, I'm glad this got resolved.

@jjasghar jjasghar closed this as completed Apr 4, 2018
@tas50 tas50 added Type: Bug Does not work as expected. and removed bug labels Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Does not work as expected.
Projects
None yet
Development

No branches or pull requests

4 participants