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

cookbook does not install requested version if package & repo for a different version already present #201

Open
jayhendren opened this issue May 17, 2019 · 7 comments
Assignees
Labels
Priority: Medium Will bring visible benefit to the project

Comments

@jayhendren
Copy link

jayhendren commented May 17, 2019

Cookbook version

6.0.0

Chef-client version

14.2.0

Platform Details

RHEL 7

Scenario:

If a system already has a node.js repository and nodejs package installed that are different from the version specified in the node['nodejs']['version'] attribute, then the nodejs cookbook will not update the package to the requested version.

Steps to Reproduce:

recipes/default.rb:

include_recipe 'nodejs'

attributes.rb:

override['nodejs']['version'] = '10.15.3'
override['nodejs']['repo'] = 'https://rpm.nodesource.com/pub_10.x/el/7/$basearch'
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_nodejs] - [2019-05-17 04:04:21]
└─[0] <git:(master 7a9f10c✱) > kitchen login
X11 forwarding request failed on channel 0
Last login: Fri May 17 16:04:44 2019 from 10.0.2.2
[vagrant@testkitchen-cub-rh7 ~]$ node --version
v6.17.1
[vagrant@testkitchen-cub-rh7 ~]$ which node
/usr/bin/node
[vagrant@testkitchen-cub-rh7 ~]$ cat /etc/yum.repos.d/
node.js.repo  redhat.repo   
[vagrant@testkitchen-cub-rh7 ~]$ cat /etc/yum.repos.d/node.js.repo 
# This file was generated by Chef
# Do NOT modify this file by hand.

[node.js]
name=nodesource.com nodejs repository
baseurl=https://rpm.nodesource.com/pub_6.x/el/7/$basearch
enabled=1
fastestmirror_enabled=0
gpgcheck=1
gpgkey=https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
[vagrant@testkitchen-cub-rh7 ~]$ exit
logout
Connection to 127.0.0.1 closed.
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_nodejs] - [2019-05-17 04:06:01]
└─[0] <git:(master 7a9f10c✱) > kitchen converge
-----> Starting Kitchen (v1.22.0)
-----> Converging <default-cub-rh7>...
       Preparing files for transfer
       Installing cookbooks for Policyfile /home/jay/Work/git/cookbooks/cub_nodejs/Policyfile.rb using `chef install`
       Installing cookbooks from lock
       Using      ark             4.0.0
       Using      build-essential 8.2.1
       Installing cub_nodejs      0.2.2
       Using      mingw           2.1.0
       Using      nodejs          6.0.0
       Using      seven_zip       3.1.0
       Using      windows         6.0.0
       Preparing dna.json
       Exporting cookbook dependencies from Policyfile /tmp/default-cub-rh7-sandbox-20190517-16042-1hp86sm...
       Exported policy 'cub_nodejs' to /tmp/default-cub-rh7-sandbox-20190517-16042-1hp86sm
       
       To converge this system with the exported policy, run:
         cd /tmp/default-cub-rh7-sandbox-20190517-16042-1hp86sm
         chef-client -z
       Removing non-cookbook files before transfer
       Preparing data_bags
       Preparing validation.pem
       Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
       Transferring files to <default-cub-rh7>
       Starting Chef Client, version 14.2.0
       Using policy 'cub_nodejs' at revision '968566b5560677e29e9642bdfb2ae071197de697e26645bed2ac7436f8eedfea'
       resolving cookbooks for run list: ["cub_nodejs::default@0.2.2 (cf42f71)"]
       Synchronizing Cookbooks:
         - build-essential (8.2.1)
         - ark (4.0.0)
         - mingw (2.1.0)
         - nodejs (6.0.0)
         - seven_zip (3.1.0)
         - windows (6.0.0)
         - cub_nodejs (0.2.2)
       Installing Cookbook Gems:
       Compiling Cookbooks...
       Converging 3 resources
       Recipe: nodejs::repo
         * yum_repository[node.js] action create
           * template[/etc/yum.repos.d/node.js.repo] action create
             - update content in file /etc/yum.repos.d/node.js.repo from 1682d2 to 68337c
             --- /etc/yum.repos.d/node.js.repo	2019-05-17 17:02:51.555989589 -0600
             +++ /etc/yum.repos.d/.chef-node20190517-6951-158ifma.js.repo	2019-05-17 17:06:40.829953132 -0600
             @@ -3,7 +3,7 @@
       
       [node.js]
       name=nodesource.com nodejs repository
             -baseurl=https://rpm.nodesource.com/pub_6.x/el/7/$basearch
             +baseurl=https://rpm.nodesource.com/pub_10.x/el/7/$basearch
       enabled=1
       fastestmirror_enabled=0
       gpgcheck=1
             - restore selinux security context
           * execute[yum clean metadata node.js] action run
             - execute yum clean metadata --disablerepo=* --enablerepo=node.js
           * execute[yum-makecache-node.js] action run
             - execute yum -q -y makecache --disablerepo=* --enablerepo=node.js
           * ruby_block[package-cache-reload-node.js] action create
             - execute the ruby block package-cache-reload-node.js
           * execute[yum clean metadata node.js] action nothing (skipped due to action :nothing)
           * execute[yum-makecache-node.js] action nothing (skipped due to action :nothing)
           * ruby_block[package-cache-reload-node.js] action nothing (skipped due to action :nothing)
         
       Recipe: nodejs::nodejs_from_package
         * yum_package[nodejs] action install (up to date)
         * yum_package[nodejs-devel] action install (up to date)
       
       Running handlers:
       Running handlers complete
       Chef Client finished, 5/10 resources updated in 08 seconds
       Downloading files from <default-cub-rh7>
       Finished converging <default-cub-rh7> (0m13.70s).
-----> Kitchen is finished. (0m13.94s)
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_nodejs] - [2019-05-17 04:07:57]
└─[0] <git:(master 7a9f10c✱) > kitchen login
X11 forwarding request failed on channel 0
Last login: Fri May 17 16:06:37 2019 from 10.0.2.2
[vagrant@testkitchen-cub-rh7 ~]$ which node
/usr/bin/node
[vagrant@testkitchen-cub-rh7 ~]$ node --version
v6.17.1
[vagrant@testkitchen-cub-rh7 ~]$ cat /etc/yum.repos.d/node.js.repo 
# This file was generated by Chef
# Do NOT modify this file by hand.

[node.js]
name=nodesource.com nodejs repository
baseurl=https://rpm.nodesource.com/pub_10.x/el/7/$basearch
enabled=1
fastestmirror_enabled=0
gpgcheck=1
gpgkey=https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
[vagrant@testkitchen-cub-rh7 ~]$ exit
logout
Connection to 127.0.0.1 closed.

Expected Result:

nodejs cookbook upgrades node to the specified package version.

Actual Result:

nodejs cookbook does not upgrade node.

@Dragsbaek
Copy link

@Poohblah did you find a fix for this? Im having same issue

@jayhendren
Copy link
Author

No, I haven't really been looking for a fix. The nodejs cookbook is one of my least-used cookbooks, so this is very low-priority for me personally. IIRC I just manually removed the package & repo and re-ran chef when I ran into this issue.

@MarkGibbons
Copy link
Member

Consistent with other reports about upgrades of packages. There are at least 3 related issues.

@MarkGibbons MarkGibbons added the Priority: Medium Will bring visible benefit to the project label Oct 2, 2020
@MarkGibbons
Copy link
Member

This is a very nice report. It's almost the same issue as #110. I'm working on a solution for #110 that I suspect will fix this issue.

@MarkGibbons MarkGibbons self-assigned this Oct 21, 2020
@Brantone
Copy link
Contributor

Brantone commented Dec 9, 2020

From tracing the code, it doesn't look like version is really taken into account much at all, is it?

@MarkGibbons
Copy link
Member

Correct.

@sbailliez
Copy link

Will leave this here instead of opening another bug but for people looking out to fix this, the nodejs_from_package is ignoring the version, so specifying another version than the original one will not work. To fix it you need to add the version:

In https://github.com/sous-chefs/nodejs/blob/main/recipes/nodejs_from_package.rb#L38, it should be

  package node_pkg do
    action node['nodejs']['package_action'][node_pkg] if node['nodejs']['package_action'][node_pkg]
    version node['nodejs']['version'] if node['nodejs']['version'] # need version here to install the version specified
    options node['nodejs']['package_options'][node_pkg] if node['nodejs']['package_options'][node_pkg]
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium Will bring visible benefit to the project
Projects
None yet
Development

No branches or pull requests

5 participants