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

VapiStdErrorsUnauthenticated when i try to create a VM #77

Closed
pdellarciprete opened this issue Sep 25, 2019 · 13 comments · Fixed by #150
Closed

VapiStdErrorsUnauthenticated when i try to create a VM #77

pdellarciprete opened this issue Sep 25, 2019 · 13 comments · Fixed by #150
Labels
Platform: VMware Priority: Medium Triage: Confirmed Indicates and issue has been confirmed as described.

Comments

@pdellarciprete
Copy link

Versions:

  • Version of kitchen-vcenter: 2.5.2
  • Version of test-kitchen: 2.2.5
  • Version of chef: 14

Platform Details

  • Version of vCenter: 6.5.0.23000

Steps to Reproduce:

Run kitchen converge with kitchen.yml like this

---
driver:
  name: vcenter
  vcenter_username: <%= ENV['VCENTER_USER'] %>
  vcenter_password: <%= ENV['VCENTER_PASSWORD'] %>
  vcenter_host:  vcenterdr.cervedgroup.com
  vcenter_disable_ssl_verify: true
  log_level: info
  customize:
    annotation: "Kitchen VM Test by <%= ENV['USER'] %> on <%= Time.now.to_s %>"

provisioner:
  name: chef_zero
  sudo_command: sudo
  deprecations_as_errors: true
  retry_on_exit_code:
    - 35 # 35 is the exit code signaling that the node is rebooting
  max_retries: 2
  wait_for_retry: 90
  log_level: info
  install_strategy: once # don't install again if an installation is detected.

verifier:
  name: inspec

platforms:
  - name: redhat-7
    driver:
      cluster: 'MyCluster' 
      resource_pool: 'low pool'
      clone_type: linked
      network_name: 'MyNetwork'
      datacenter: "MyDatacenter"
      template: 'CHEF/chef-base' 
      folder: 'CHEF'      
      vm_rollback: true
    transport:
      username: <%= ENV['LOCAL_USER'] %>
      password: <%= ENV['LOCAL_PASS'] %>

suites:
  - name: my-suite
    run_list:
      - recipe[mycookbook::default]
    verifier:
      inspec_tests:
        - test/integration/default

Actual Result:

D      Message: Failed to complete #create action: [undefined method `empty?' for #<VSphereAutomation::VCenter::VapiStdErrorsUnauthenticated:0x0000000008072b48>] on zk-base-redhat-7
D      ----------------------
D      ------Backtrace-------
D      /home/jenkins/.chefdk/gem/ruby/2.6.0/gems/kitchen-vcenter-2.5.2/lib/kitchen/driver/vcenter.rb:384:in `get_cluster'
D      /home/jenkins/.chefdk/gem/ruby/2.6.0/gems/kitchen-vcenter-2.5.2/lib/kitchen/driver/vcenter.rb:93:in `create'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:485:in `public_send'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:485:in `block in perform_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:552:in `synchronize_or_call'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:514:in `block in action'
D      /opt/chefdk/embedded/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:513:in `action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:485:in `perform_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:394:in `create_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:382:in `block (2 levels) in transition_to'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/lifecycle_hooks.rb:45:in `run_with_hooks'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:381:in `block in transition_to'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:380:in `each'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:380:in `transition_to'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:162:in `verify'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:191:in `block in test'
D      /opt/chefdk/embedded/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/instance.rb:187:in `test'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/command.rb:197:in `public_send'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/command.rb:197:in `run_action_in_thread'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.2.5/lib/kitchen/command.rb:169:in `block (2 levels) in run_action'
D      /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
D      ----End Backtrace-----

It worked with this version of gems:
Successfully installed vsphere-automation-cis-0.1.0
Successfully installed vsphere-automation-appliance-0.1.0
Successfully installed vsphere-automation-content-0.1.0
Successfully installed vsphere-automation-vapi-0.1.0
Successfully installed vsphere-automation-vcenter-0.1.0
Successfully installed vsphere-automation-sdk-0.1.0
Successfully installed kitchen-vcenter-2.4.0

doesn't work now with these:
Successfully installed vsphere-automation-runtime-0.4.2
Successfully installed vsphere-automation-cis-0.4.2
Successfully installed vsphere-automation-appliance-0.4.2
Successfully installed vsphere-automation-content-0.4.2
Successfully installed vsphere-automation-vapi-0.4.2
Successfully installed vsphere-automation-vcenter-0.4.2
Successfully installed vsphere-automation-sdk-0.4.2
Successfully installed kitchen-vcenter-2.5.2

@pdellarciprete pdellarciprete added the Status: Untriaged An issue that has yet to be triaged. label Sep 25, 2019
@thheinen
Copy link
Collaborator

Hi there,

apparently versions 0.4.0 - 0.4.2 of the vsphere-automation-sdk gems are bugged (vmware-archive/vsphere-automation-sdk-ruby#57) , they released a 0.4.3 just a few minutes ago. You could try that one or pin your versions to the last known working version 0.3.0.

Would appreciate some response, if 0.4.3 indeed fixed your issue so I know if I need to look further.

@pdellarciprete
Copy link
Author

I have the same error also with :

Successfully installed vsphere-automation-runtime-0.4.3
Successfully installed vsphere-automation-cis-0.4.3
Successfully installed vsphere-automation-appliance-0.4.3
Successfully installed vsphere-automation-content-0.4.3
Successfully installed vsphere-automation-vapi-0.4.3
Successfully installed vsphere-automation-vcenter-0.4.3
Successfully installed vsphere-automation-sdk-0.4.3
Successfully installed kitchen-vcenter-2.5.2

@pdellarciprete
Copy link
Author

Sorry @tecracer-theinen, but if you are aware of the bugs of vsphere-automation-sdk gems, why you don't fix the version of your dependency to 0.3.0 in .gemspec ?

spec.add_dependency "vsphere-automation-sdk", "~> 0.1"

@pdellarciprete
Copy link
Author

Update with this combination of gems version it works:

vsphere-automation-runtime-0.3.0
vsphere-automation-cis-0.3.0
vsphere-automation-appliance-0.3.0
vsphere-automation-content-0.3.0
vsphere-automation-vapi-0.3.0
vsphere-automation-vcenter-0.3.0
vsphere-automation-sdk-0.3.0
kitchen-vcenter-2.5.2

@thheinen
Copy link
Collaborator

thheinen commented Oct 7, 2019

Sorry, but I have been on vacation. I just tried reproducing the bug, but was not able to do so.

Brand new Ubuntu 18 box with ChefDK 4.4 works with:

kitchen-vcenter (2.5.1)
test-kitchen (2.3.3)
vsphere-automation-appliance (0.4.1)
vsphere-automation-cis (0.4.1)
vsphere-automation-content (0.4.1)
vsphere-automation-runtime (0.4.1)
vsphere-automation-sdk (0.4.1)
vsphere-automation-vapi (0.4.1)
vsphere-automation-vcenter (0.4.1)

But Chef Workstation 0.10.6 on the same base works as well:

test-kitchen (2.3.3)
kitchen-vcenter (2.5.2)
vsphere-automation-appliance (0.4.3)
vsphere-automation-cis (0.4.3)
vsphere-automation-content (0.4.3)
vsphere-automation-runtime (0.4.3)
vsphere-automation-sdk (0.4.3)
vsphere-automation-vapi (0.4.3)
vsphere-automation-vcenter (0.4.3)

I am quite confused and will keep looking into this.

@thheinen thheinen added Platform: VMware Priority: Medium Triage: Not Reproducible Indicates an issue can not be reproduced as described. and removed Status: Untriaged An issue that has yet to be triaged. labels Oct 7, 2019
@thheinen thheinen pinned this issue Oct 7, 2019
@bodinewilson
Copy link

bodinewilson commented Oct 8, 2019

I've got the same issue:

CentOS Linux release 7.6.1810 (Core)
test-kitchen (2.3.3)
kitchen-vcenter (2.5.2)
vsphere-automation-appliance (0.4.4)
vsphere-automation-cis (0.4.4)
vsphere-automation-content (0.4.4)
vsphere-automation-runtime (0.4.4)
vsphere-automation-sdk (0.4.4)
vsphere-automation-vapi (0.4.4)
vsphere-automation-vcenter (0.4.4)

chefdk-4.4.27-1.el7.x86_64

vcenter 6.7 update 1

the same creds do work with fine with knife

D ---Nested Exception---
D Class: Kitchen::ActionFailed
D Message: Failed to complete #create action: [undefined method map' for #<VSphereAutomation::VCenter::VapiStdErrorsUnauthenticated:0x0000000008a7e470> Did you mean? tap] D ---------------------- D ------Backtrace------- D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/kitchen-vcenter-2.5.2/lib/kitchen/driver/vcenter.rb:418:in get_resource_pool'
D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/kitchen-vcenter-2.5.2/lib/kitchen/driver/vcenter.rb:415:in get_resource_pool' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/kitchen-vcenter-2.5.2/lib/kitchen/driver/vcenter.rb:91:in create'
D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:485:in public_send' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:485:in block in perform_action'
D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:552:in synchronize_or_call' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:514:in block in action'
D /opt/chefdk/embedded/lib/ruby/2.6.0/benchmark.rb:293:in measure' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:513:in action'
D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:485:in perform_action' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:394:in create_action'
D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:382:in block (2 levels) in transition_to' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/lifecycle_hooks.rb:45:in run_with_hooks'
D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:381:in block in transition_to' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:380:in each'
D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:380:in transition_to' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/instance.rb:129:in create'
D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:198:in public_send' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:198:in run_action_in_thread'
D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/test-kitchen-2.3.3/lib/kitchen/command.rb:169:in block (2 levels) in run_action' D /opt/chefdk/embedded/lib/ruby/gems/2.6.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in block in create_with_logging_context'
D ----End Backtrace-----

@thheinen
Copy link
Collaborator

thheinen commented Oct 9, 2019

Thanks for this update. I found a customer installation which has the same problems, so I can look into it now.

@thheinen thheinen added Triage: Confirmed Indicates and issue has been confirmed as described. and removed Triage: Not Reproducible Indicates an issue can not be reproduced as described. labels Oct 9, 2019
@thheinen
Copy link
Collaborator

thheinen commented Oct 9, 2019

Just looped in @jrgarcia to help with the VMware side of things.

@jrgarcia
Copy link

@tecracer-theinen Hey, I just released v0.4.5 of the SDK which should fix this for you. Thanks for reporting!

@thheinen
Copy link
Collaborator

Getting reports from customers that 0.4.5 solved their problems. Closing this issue accordingly. Thanks @jrgarcia :)

@tzvifriedman
Copy link

This is still a problem for me (in Windows) after installing 0.4.5.

With the latest kitchen-vcenter (2.5.2), I'm getting this error:

-----> Creating ...

------Exception-------
Class: Kitchen::ActionFailed
Message: 1 actions failed.
Failed to complete #create action: [undefined method `delete_if' for #<VSphereAutomation::VCenter::VapiStdErr
orsUnauthenticated:0x000000000fd7b630>] on default-windows-2019-core

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

@thheinen
Copy link
Collaborator

Just collected the following info with @tzvifriedman about this:

vsphere-automation-appliance (0.4.5, 0.1.0)
vsphere-automation-cis (0.4.5, 0.1.0)
vsphere-automation-content (0.4.5, 0.1.0)
vsphere-automation-runtime (0.4.5)
vsphere-automation-sdk (0.4.5)
vsphere-automation-vapi (0.4.5, 0.1.0)
vsphere-automation-vcenter (0.4.5, 0.1.0)

VMware vCenter 6.5.0.23000
VMware ESXi, 6.5.0, 13004031

The Error occurs both on Windows 2016 and OS X as development workstation.

Still, pinning the vsphere-automation-sdk to version 0.3.0 is probably a viable workaround until this has been resolved.

@thheinen thheinen reopened this Oct 17, 2019
@nielsbuus
Copy link

@tecracer-theinen I think I have located the cause of this error as I am facing it now. We are using 0.4.6 of the API and 2.9.0 of kitchen-vcenter. The error is caused by the interfacing between VSphereAutomation and kitchen-vcenter. The error is present in all (recent) versions of kitchen-vcenter.

If you look at this line:

https://github.com/chef/kitchen-vcenter/blob/master/lib/kitchen/driver/vcenter.rb#L396

You can see that it checks clusters.empty? assuming it is an array, but the problem is that the value method called just above can return some sort of error object if your credentials are not accepted.

So if the interface for the ClusterApi class is that list.value can return error object (which is not that intuitive), then the bug is within kitchen-vcenter which should check for the type of object returned and handle arrays and error objects explicitly.

If ClusterApi should raise an exception on errors (which I think it should), then the bug is within VSphereAutomation, which needs to raise errors rather than returning them.

@thheinen thheinen linked a pull request Aug 16, 2021 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: VMware Priority: Medium Triage: Confirmed Indicates and issue has been confirmed as described.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants