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

Multiple 'user' installs conflict #99

Open
athiede-vendavo opened this issue Jan 27, 2023 · 0 comments
Open

Multiple 'user' installs conflict #99

athiede-vendavo opened this issue Jan 27, 2023 · 0 comments

Comments

@athiede-vendavo
Copy link
Contributor

athiede-vendavo commented Jan 27, 2023

👻 Brief Description

When running mutiple pyenv_install as a user in a recipe (instead of old pyenv_user_install), the file /etc/profile.d/pyenv.sh gets replaced multiple times per chef run, and the second install errors out.

I expect a user install to not add anything to /etc/profile.d/, instead the user's ~/.profile maybe?

The code in question:

%w(user1 user2).each do |user|
  pyenv_install 'user' do
    user user
    prefix_type 'user'
    update_pyenv true
  end
end

This fails with the following output:

      ================================================================================
      Error executing action `checkout` on resource 'git[/home/athiede/.pyenv]'
      ================================================================================

      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '1'
      ---- Begin output of git ls-remote "https://github.com/pyenv/pyenv.git" "master*" ----
      STDOUT:
      STDERR: /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout.rb:221:in `getgrnam': can't find group for athiede (ArgumentError)
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout.rb:221:in `gid'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:164:in `set_group'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:336:in `block in fork_subprocess'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:321:in `fork'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:321:in `fork_subprocess'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/unix.rb:97:in `run_command'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout.rb:270:in `run_command'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/helper.rb:154:in `__shell_out_command'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/helper.rb:128:in `shell_out_compacted!'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/mixlib-shellout-3.2.7/lib/mixlib/shellout/helper.rb:54:in `shell_out!'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:390:in `git'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:350:in `git_ls_remote'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:300:in `remote_resolve_reference'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:287:in `target_revision'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider/git.rb:80:in `block (2 levels) in define_resource_requirements'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/mixin/why_run.rb:229:in `run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/mixin/why_run.rb:322:in `block in run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/mixin/why_run.rb:321:in `each'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/mixin/why_run.rb:321:in `run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:257:in `process_resource_requirements'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:233:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:601:in `block in run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:628:in `with_umask'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:600:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:74:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `block in run_all_actions'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `each'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `run_all_actions'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection.rb:64:in `insert'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/dsl/declare_resource.rb:267:in `declare_resource'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/dsl/resources.rb:36:in `git'
      	from /var/cinc/cache/cookbooks/pyenv/resources/install.rb:71:in `block in class_from_file'
      	from (eval):2:in `block in action_install'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:304:in `instance_eval'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:304:in `compile_and_converge_action'
      	from (eval):2:in `action_install'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/provider.rb:245:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:601:in `block in run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:628:in `with_umask'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource.rb:600:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:74:in `run_action'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `block in run_all_actions'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `each'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:108:in `run_all_actions'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:132:in `block in converge'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/resource_list.rb:96:in `block in execute_each_resource'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/stepable_iterator.rb:54:in `each_with_index'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/resource_collection/resource_list.rb:94:in `execute_each_resource'
      	from /opt/cinc/embedded/lib/ruby/3.1.0/forwardable.rb:238:in `execute_each_resource'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/runner.rb:130:in `converge'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:852:in `block in converge'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:847:in `catch'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:847:in `converge'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:871:in `converge_and_save'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/client.rb:289:in `run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application.rb:305:in `run_with_graceful_exit_option'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application.rb:281:in `block in run_chef_client'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/local_mode.rb:42:in `with_server_connectivity'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application.rb:264:in `run_chef_client'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application/base.rb:352:in `run_application'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-18.0.185/lib/chef/application.rb:67:in `run'
      	from /opt/cinc/embedded/lib/ruby/gems/3.1.0/gems/chef-bin-18.0.185/bin/cinc-client:25:in `<top (required)>'
      	from /bin/cinc-client:184:in `load'
      	from /bin/cinc-client:184:in `<main>'
      ---- End output of git ls-remote "https://github.com/pyenv/pyenv.git" "master*" ----
      Ran git ls-remote "https://github.com/pyenv/pyenv.git" "master*" returned 1

      Cookbook Trace: (most recent call first)
      ----------------------------------------
      /var/cinc/cache/cookbooks/pyenv/resources/install.rb:71:in `block in class_from_file'

      Resource Declaration:
      ---------------------
      # In /var/cinc/cache/cookbooks/pyenv/resources/install.rb

       71:   git new_resource.prefix do
       72:     repository new_resource.git_url
       73:     revision   new_resource.git_ref
       74:     user       new_resource.user
       75:     group      new_resource.group
       76:     depth      1
       77:     action     new_resource.update_pyenv ? :sync : :checkout
       78:     environment(new_resource.environment)
       79:     notifies :run, 'ruby_block[Add pyenv to PATH]', :immediately
       80:     notifies :run, 'execute[Initialize pyenv]', :immediately
       81:   end
       82:

      Compiled Resource:
      ------------------
      # Declared in /var/cinc/cache/cookbooks/pyenv/resources/install.rb:71:in `block in class_from_file'

      git("/home/athiede/.pyenv") do
        action [:checkout]
        default_guard_interpreter :default
        declared_type :git
        cookbook_name "vendavo-base-cfg"
        recipe_name "python"
        repository "https://github.com/pyenv/pyenv.git"
        revision "master"
        user "athiede"
        group "athiede"
        depth 1
        destination "/home/athiede/.pyenv"
      end

      System Info:
      ------------
      chef_version=18.0.185
      platform=centos
      platform_version=7.9.2009
      ruby=ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
      program_name=/bin/cinc-client
      executable=/opt/cinc/bin/cinc-client

🥞 Cookbook version

4.2.0

👩‍🍳 Chef-Infra Version

18.0.185 (cinc)

🎩 Platform details

CentOS 7 in Azure

Steps To Reproduce

Steps to reproduce the behavior:

run a recipe with this in it:

%w(user1 user2).each do |user|
  pyenv_install 'user' do
    user user
    prefix_type 'user'
    update_pyenv true
  end
end

🚓 Expected behavior

I expect there to be two identical pyenvs setup.

➕ Additional context

The second user fails at this step: * git[/home/user2/.pyenv] action sync

This worked on version 3.4.0.

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

No branches or pull requests

1 participant