Merge ~afreiberger/charm-mongodb:add-py3pip-to-install-hook into charm-mongodb:master

Proposed by Drew Freiberger
Status: Merged
Approved by: Xav Paice
Approved revision: 1881adcb113dacd0ba1a99e9544ce32b6e9c4e34
Merged at revision: 92a24f9739e46b8ac0cd09609ae0d763f0ae31ec
Proposed branch: ~afreiberger/charm-mongodb:add-py3pip-to-install-hook
Merge into: charm-mongodb:master
Diff against target: 70 lines (+16/-11)
2 files modified
hooks/hooks.py (+15/-10)
hooks/install (+1/-1)
Reviewer Review Type Date Requested Status
Xav Paice (community) Approve
Giuseppe Petralia Approve
BootStack Reviewers Pending
Review via email: mp+387959@code.launchpad.net

This proposal supersedes a proposal from 2020-07-20.

Commit message

Add python3-pip to install hook to support trusty fresh installs.

Description of the change

Addressing Andrea's note for install hook to add in py3-pip package on top of Zach's fix for trusty upgrade-charm imports.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : Posted in a previous version of this proposal

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : Posted in a previous version of this proposal

Unable to determine commit message from repository - please click "Set commit message" and enter the commit message manually.

Revision history for this message
Xav Paice (xavpaice) wrote : Posted in a previous version of this proposal

LGTM

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : Posted in a previous version of this proposal

Failed to merge change (unable to merge source repository due to conflicts), setting status to needs review.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Drew Freiberger (afreiberger) wrote :

resubmitting after rebase.

pyflakes complaining about config_changed complexity (17). it's got a lot of repetitive code (just check out the web_admin_ui sections) and needs a complete refactor that is outside the scope of this bug.

Revision history for this message
Giuseppe Petralia (peppepetra) wrote :

This looks good to me. For the complexity we need to fix that before going
forward CI, either increasing complexity in tox (this can be acceptable for
legacy charms where we don't want to touch working code) or splitting the
if in different functions. In any case out of scope here.

review: Approve
Revision history for this message
Drew Freiberger (afreiberger) wrote :

moved the C901 skip on config_changed to the function definition line. lint passes now.

Revision history for this message
Drew Freiberger (afreiberger) wrote :

filed bug https://bugs.launchpad.net/charm-mongodb/+bug/1888692 regarding need to reduce complexity/refactor

Revision history for this message
Xav Paice (xavpaice) wrote :

LGTM, tests OK so long as you don't have juju-http-proxy set in the model. I'll raise a separate bug about that.

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 92a24f9739e46b8ac0cd09609ae0d763f0ae31ec

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/hooks.py b/hooks/hooks.py
2index 275a0ba..0c7798b 100755
3--- a/hooks/hooks.py
4+++ b/hooks/hooks.py
5@@ -9,7 +9,6 @@ import collections
6 import distutils
7 import json
8 import os
9-import pip
10 import pprint
11 import re
12 import signal
13@@ -19,13 +18,7 @@ import sys
14 import time
15
16 try:
17- import distro
18-except ImportError:
19- pip.main(['install', "distro"])
20- import distro
21-
22-try:
23- import yaml
24+ import yaml # flake8: noqa
25 except ImportError:
26 if sys.version_info.major == 2:
27 subprocess.check_call(['apt-get', 'install', '-y', 'python-yaml'])
28@@ -92,6 +85,18 @@ except ImportError:
29 from pymongo import MongoClient
30 from pymongo.errors import OperationFailure
31
32+try:
33+ import pip # flake8: noqa
34+except ImportError:
35+ apt_install('python3-pip', fatal=True)
36+ import pip # flake8: noqa
37+
38+try:
39+ import distro # flake8: noqa
40+except ImportError:
41+ pip.main(['install', "distro"])
42+ import distro # flake8: noqa
43+
44 from charmhelpers.contrib.charmsupport.nrpe import NRPE
45
46 hooks = Hooks()
47@@ -965,8 +970,8 @@ def install_hook():
48 apt_install(packages=INSTALL_PACKAGES, fatal=True)
49
50
51-@hooks.hook('config-changed') # noqa: C901
52-def config_changed():
53+@hooks.hook('config-changed')
54+def config_changed(): # noqa: C901
55 juju_log("Entering config_changed")
56 status_set('maintenance', 'Configuring unit')
57 config_data = config()
58diff --git a/hooks/install b/hooks/install
59index baffb57..8a1f051 100755
60--- a/hooks/install
61+++ b/hooks/install
62@@ -2,7 +2,7 @@
63 # Wrapper to deal with newer Ubuntu versions that don't have py2 installed
64 # by default.
65
66-declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml')
67+declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml' 'python3-pip')
68
69 wait_for_dpkg_unlock() {
70 while $(fuser -s /var/lib/dpkg/lock); do sleep .5;done

Subscribers

People subscribed via source and target branches

to all changes: