Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Cannot declare two virtualenvs in the same recipe #137

Open
nkovacne opened this issue Nov 8, 2018 · 0 comments
Open

Cannot declare two virtualenvs in the same recipe #137

nkovacne opened this issue Nov 8, 2018 · 0 comments

Comments

@nkovacne
Copy link

nkovacne commented Nov 8, 2018

Trying to create two python_virtualenv resources within the same recipe throws an error on the creation of the second one, as the parent_python seems to include the path to the first one. The problem is that both virtualenvs are independent and shouldn't be referenced.

The recipe:

# UFC
git node['stic_correo']['ec']['local_ufc_path'] do
  repository node['stic_correo']['ec']['remote_ufc_path']
  user 'root'
  group 'root'
  action :sync
end

python_runtime '2'

python_virtualenv "#{node['stic_correo']['ec']['local_ufc_path']}/venv" do
  user 'root'
  group 'root'
  action :create
  not_if { ::File.directory?("#{node['stic_correo']['ec']['local_ufc_path']}/venv") }
end

pip_requirements "#{node['stic_correo']['ec']['local_ufc_path']}/requirements.txt" do
  virtualenv "#{node['stic_correo']['ec']['local_ufc_path']}/venv"
end

# PCC
git node['stic_correo']['ec']['local_pcc_path'] do
  repository node['stic_correo']['ec']['remote_pcc_path']
  user 'root'
  group 'root'
  action :sync
end

python_virtualenv "#{node['stic_correo']['ec']['local_pcc_path']}/venv" do
  user 'root'
  group 'root'
  action :create
  not_if { ::File.directory?("#{node['stic_correo']['ec']['local_pcc_path']}/venv") }
end

pip_requirements "#{node['stic_correo']['ec']['local_pcc_path']}/requirements.txt" do
  virtualenv "#{node['stic_correo']['ec']['local_pcc_path']}/venv"
end

These are two scripts (UFC and PCC). The creation of the first one's python_virtualenv resource goes smoothly, the second one's python_virtualenv throws this error:

         * python_virtualenv[/opt/stic/pcc/venv] action create
           
           ================================================================================
           Error executing action `create` on resource 'python_virtualenv[/opt/stic/pcc/venv]'
           ================================================================================
           
           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '1'
           ---- Begin output of ["/opt/stic/ufc/venv/bin/python", "-m", "virtualenv", "/opt/stic/pcc/venv"] ----
           STDOUT: 
           STDERR: /opt/stic/ufc/venv/bin/python: No module named virtualenv
           ---- End output of ["/opt/stic/ufc/venv/bin/python", "-m", "virtualenv", "/opt/stic/pcc/venv"] ----
           Ran ["/opt/stic/ufc/venv/bin/python", "-m", "virtualenv", "/opt/stic/pcc/venv"] returned 1
           
           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/poise-languages/files/halite_gem/poise_languages/command/mixin.rb:207:in `tap'
           /tmp/kitchen/cache/cookbooks/poise-languages/files/halite_gem/poise_languages/command/mixin.rb:207:in `language_command_shell_out!'
           /tmp/kitchen/cache/cookbooks/poise-languages/files/halite_gem/poise_languages/command/mixin.rb:222:in `block in language_command_mixin'
           /tmp/kitchen/cache/cookbooks/poise-python/files/halite_gem/poise_python/resources/python_virtualenv.rb:157:in `create_virtualenv'
           /tmp/kitchen/cache/cookbooks/poise-python/files/halite_gem/poise_python/resources/python_virtualenv.rb:124:in `block in install_python'
           /tmp/kitchen/cache/cookbooks/poise-python/files/halite_gem/poise_python/resources/python_virtualenv.rb:123:in `install_python'
           /tmp/kitchen/cache/cookbooks/poise-python/files/halite_gem/poise_python/python_providers/base.rb:46:in `block in action_install'
           /tmp/kitchen/cache/cookbooks/poise/files/halite_gem/poise/helpers/subcontext_block.rb:54:in `instance_eval'
           /tmp/kitchen/cache/cookbooks/poise/files/halite_gem/poise/helpers/subcontext_block.rb:54:in `subcontext_block'
           /tmp/kitchen/cache/cookbooks/poise/files/halite_gem/poise/helpers/notifying_block.rb:67:in `notifying_block'
           /tmp/kitchen/cache/cookbooks/poise-python/files/halite_gem/poise_python/python_providers/base.rb:45:in `action_install'
           
           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/stic_correo/recipes/enviocorreo.rb
           
            56: python_virtualenv "#{node['stic_correo']['ec']['local_pcc_path']}/venv" do
            57:   user 'root'
            58:   group 'root'
            59:   action :create
            60:   not_if { ::File.directory?("#{node['stic_correo']['ec']['local_pcc_path']}/venv") }
            61: end
            62: 
           
           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/stic_correo/recipes/enviocorreo.rb:56:in `from_file'
           
           python_virtualenv("/opt/stic/pcc/venv") do
             provider PoisePython::Resources::PythonVirtualenv::Provider
             action [:create]
             default_guard_interpreter :default
             subresources [pip_requirements[/opt/stic/pcc/requirements.txt]]
             declared_type :python_virtualenv
             cookbook_name "stic_correo"
             recipe_name "enviocorreo"
             user "root"
             group "root"
             parent_python python_virtualenv[/opt/stic/ufc/venv]
             path "/opt/stic/pcc/venv"
             timeout 900
             not_if { #code block }
           end
           
           System Info:
           ------------
           chef_version=14.6.47
           platform=centos
           platform_version=7.3.1611
           ruby=ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
           program_name=/opt/chef/bin/chef-client
           executable=/opt/chef/bin/chef-client
       
       Running handlers:
       [2018-11-08T14:20:22+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2018-11-08T14:20:22+00:00] ERROR: Exception handlers complete
       Chef Client failed. 16 resources updated in 01 minutes 32 seconds
       [2018-11-08T14:20:22+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2018-11-08T14:20:22+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2018-11-08T14:20:22+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: python_virtualenv[/opt/stic/pcc/venv] (stic_correo::enviocorreo line 56) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
       ---- Begin output of ["/opt/stic/ufc/venv/bin/python", "-m", "virtualenv", "/opt/stic/pcc/venv"] ----
       STDOUT: 
       STDERR: /opt/stic/ufc/venv/bin/python: No module named virtualenv
       ---- End output of ["/opt/stic/ufc/venv/bin/python", "-m", "virtualenv", "/opt/stic/pcc/venv"] ----
       Ran ["/opt/stic/ufc/venv/bin/python", "-m", "virtualenv", "/opt/stic/pcc/venv"] returned 1

As you can see it includes parent_python python_virtualenv[/opt/stic/ufc/venv] which is the first virtualenv, although it doesn't have anything to do with it, the python executable (/opt/stic/ufc/venv/bin/python) is wrong as well.

Is this a bug? Any way to bypass this situation? I can't find anything in documentation regarding to parent_python.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant