voxpupuli / voxpupuli/puppet-python

`python::pip` doesn't reinstall if `extras` is updated (with no change in `ensure`)

Open
#630 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
196
Forks
372
Avg merge
1d 18m
Merged PRs (30d)
4

Description

Affected Puppet, Ruby, OS and module versions/distributions

  • Master
    • Puppet: 6.25.0
    • Distribution: Centos 7
  • Agent:
    • Puppet: 5.5.10
    • Distribution: Debian 10
    • Ruby: ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
  • Module version: d9c51a.

Problem

I can install a Python package with an arbitrary list of optional dependencies (extras) and it works just fine on a blank VM.
However, if I change the list of optional dependencies and run the agent again, the new dependencies are not installed.

How to reproduce (e.g Puppet code you use)

  • This works on a blank VM:
  python::pip { 'apache-superset':
    ensure       => '1.3.2',
    extras       => ['postgres'],
    virtualenv   => "${base_dir}/venv",
    pip_provider => 'pip3',
    install_args => '',
    owner        => $owner,
  }
  • This works on a blank VM too:
  python::pip { 'apache-superset':
    ensure       => '1.3.2',
    extras       => ['postgres', 'mysql'],
    virtualenv   => "${base_dir}/venv",
    pip_provider => 'pip3',
    install_args => '',
    owner        => $owner,
  }
  • However, this change doesn't install the optional dependency (i.e. mysqlclient>=2.1.0, <3) required by the added 'mysql' extra dependency:
 python::pip { 'apache-superset':
   ensure       => '1.3.2',
-  extras       => ['postgres'],
+  extras       => ['postgres', 'mysql'],
   virtualenv   => "${base_dir}/venv",
   pip_provider => 'pip3',
   install_args => '',
   owner        => $owner,
 }

What are you seeing

# install 'apache-superset[postgres, prophet]==1.3.2'
$ puppet agent

# (we effectively waited a few days — hence the dependencies update, see below)
# update dependencies to 'apache-superset[postgres, prophet, mysql]==1.3.2'
$ puppet agent

# manually install the package
$ pip freeze > /tmp/pip_deps_old.txt
$ pip install --upgrade --force-reinstall 'apache-superset[prophet, mysql, postgresql]'==1.3.2
$ pip freeze > /tmp/pip_deps_new.txt
$ diff /tmp/pip_deps_old.txt /tmp/pip_deps_new.txt
[…]
85c87
< msgpack==1.0.2
---
> msgpack==1.0.3
86a89
> mysqlclient==1.4.2.post1
89c92
< packaging==21.2
---
> packaging==21.3
[…]

We can see that some dependencies have been updated with more recent ones (e.g. msgpack and packaging, as the Agent hadn't run for a few days)… but more importantly, mysqlclient — required by the mysql extra dependency — is a new installed.
This means that the Agent hadn't installed it.

What behaviour did you expect instead

The agent should --force-reinstall the package if the list of extra dependencies changes — even if ensure => M.m.p hasn't changed.

Any additional information you'd like to impart

In our real-life case, apache-superset has been installed via this part of our home-baked manifest.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the python::pip resource entry point and reproduce the two-step Puppet agent run, first with one extra and then with an added extra while keeping ensure unchanged. Compare the resulting environment with pip freeze; done means the newly requested optional dependency is installed on the second run.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.