Merge ~tasdomas/influxdb-charm:d01-actions-fix into influxdb-charm:master

Proposed by Domas Monkus
Status: Merged
Approved by: Stuart Bishop
Approved revision: fcf0f4a8fb32e2a76e5a39b6789c0d1f3924cc77
Merged at revision: 0a38401b2c89ec85afb02d1239c7029ae5e9ee93
Proposed branch: ~tasdomas/influxdb-charm:d01-actions-fix
Merge into: influxdb-charm:master
Diff against target: 91 lines (+9/-18)
6 files modified
actions/create-database (+1/-1)
actions/create-user (+2/-2)
actions/grant-privilege (+1/-1)
actions/show-admin-password (+2/-11)
lib/influxdbcharmlib.py (+2/-2)
reactive/influxdb.py (+1/-1)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Domas Monkus (community) Needs Resubmitting
Tom Haddon Needs Fixing
Review via email: mp+365397@code.launchpad.net

Commit message

Actions in the current version of the influxdb charm are broken due to changes in the basic layer. This fixes the actions.

To post a comment you must log in.
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
Tom Haddon (mthaddon) wrote :

This creates a number of lint errors:

$ make lint
./actions/create-database:8:1: E402 module level import not at top of file
./actions/create-database:11:1: E402 module level import not at top of file
./actions/create-database:12:1: E402 module level import not at top of file
./actions/create-database:14:1: E402 module level import not at top of file
./actions/create-user:8:1: E402 module level import not at top of file
./actions/create-user:11:1: E402 module level import not at top of file
./actions/create-user:12:1: E402 module level import not at top of file
./actions/create-user:13:1: E402 module level import not at top of file
./actions/create-user:14:1: E402 module level import not at top of file
./actions/create-user:16:1: E402 module level import not at top of file
./actions/grant-privilege:8:1: E402 module level import not at top of file
./actions/grant-privilege:11:1: E402 module level import not at top of file
./actions/grant-privilege:12:1: E402 module level import not at top of file
./actions/grant-privilege:14:1: E402 module level import not at top of file
./actions/show-admin-password:7:1: E402 module level import not at top of file
./actions/show-admin-password:10:1: E402 module level import not at top of file
./actions/show-admin-password:10:1: F401 'os' imported but unused
./actions/show-admin-password:11:1: E402 module level import not at top of file
./lib/influxdbcharmlib.py:36:78: W291 trailing whitespace
./lib/influxdbcharmlib.py:37:78: W291 trailing whitespace

It looks like not all of those are you changes, but could those be addressed as part of this?

review: Needs Fixing
Revision history for this message
Stuart Bishop (stub) wrote :

The shebang lines for all the action scripts should be "!/usr/local/sbin/charm-env python3", and the sys.path.append manipulation and activate_venv() calls removed. What you have works, but can break with base layer updates and has lint issues as the #noqa comments demonstrate.

The switch to a raw string for the regexp is correct, thanks.

Revision history for this message
Stuart Bishop (stub) :
review: Needs Fixing
Revision history for this message
Domas Monkus (tasdomas) wrote :

Fixed

review: Needs Resubmitting
Revision history for this message
Stuart Bishop (stub) wrote :

Yup, looks good. Thanks!

Feel free to attempt to fix the influxdb import, or not since that is existing code and you are just delinting it.

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

Change successfully merged at revision 0a38401b2c89ec85afb02d1239c7029ae5e9ee93

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/actions/create-database b/actions/create-database
2index d2cd4bd..2736b9e 100755
3--- a/actions/create-database
4+++ b/actions/create-database
5@@ -1,4 +1,4 @@
6-#!/usr/bin/python3
7+#!/usr/local/sbin/charm-env python3
8 # Create a database
9
10 import requests
11diff --git a/actions/create-user b/actions/create-user
12index 8ad8db3..628696d 100755
13--- a/actions/create-user
14+++ b/actions/create-user
15@@ -1,4 +1,4 @@
16-#!/usr/bin/python3
17+#!/usr/local/sbin/charm-env python3
18 # Create a database
19
20 import random
21@@ -14,7 +14,7 @@ from charmhelpers.core.hookenv import (
22 )
23
24 try:
25- import influxdb
26+ import influxdb # noqa: E402
27 except ImportError:
28 print("Missing python3-influxdb package")
29 exit(1)
30diff --git a/actions/grant-privilege b/actions/grant-privilege
31index 87cfb0d..6ae856c 100755
32--- a/actions/grant-privilege
33+++ b/actions/grant-privilege
34@@ -1,4 +1,4 @@
35-#!/usr/bin/python3
36+#!/usr/local/sbin/charm-env python3
37 # Create a database
38
39 import requests
40diff --git a/actions/show-admin-password b/actions/show-admin-password
41index 093b2d2..878bb8e 100755
42--- a/actions/show-admin-password
43+++ b/actions/show-admin-password
44@@ -1,17 +1,8 @@
45 #!/usr/local/sbin/charm-env python3
46
47-import os
48-import sys
49+from charmhelpers.core import hookenv
50
51-hooks_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'hooks'))
52-if hooks_dir not in sys.path:
53- sys.path.append(hooks_dir)
54-libs_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'lib'))
55-if libs_dir not in sys.path:
56- sys.path.append(libs_dir)
57-
58-from charmhelpers.core import hookenv # NOQA: E402
59-from influxdbcharmlib import get_influxdb_credentials # NOQA: E402
60+from influxdbcharmlib import get_influxdb_credentials
61
62
63 if __name__ == '__main__':
64diff --git a/lib/influxdbcharmlib.py b/lib/influxdbcharmlib.py
65index 4bf06b5..3c0016c 100644
66--- a/lib/influxdbcharmlib.py
67+++ b/lib/influxdbcharmlib.py
68@@ -33,8 +33,8 @@ def create_influxdb_user(username, admin=False, local_user=None):
69 password = str(uuid.uuid4())
70
71 # Repeat the process of creating teh user until completed or max times
72- # reached because sometimes happens a race condition between the influxdb
73- # service startup and the client use. In those cases the service is still
74+ # reached because sometimes happens a race condition between the influxdb
75+ # service startup and the client use. In those cases the service is still
76 # not fully started when the client is sending the first request
77 n = 3
78 while True:
79diff --git a/reactive/influxdb.py b/reactive/influxdb.py
80index db19fca..c751ea8 100644
81--- a/reactive/influxdb.py
82+++ b/reactive/influxdb.py
83@@ -92,7 +92,7 @@ def apply_configs(fh, config): # noqa: TODO: fix overly complex
84 indent = ' '
85 continue
86 # Format is 'key = value' or '# key = value'
87- match = re.match('^([\s#]*)(\S+)(\s*=.*)', line)
88+ match = re.match(r'^([\s#]*)(\S+)(\s*=.*)', line)
89 if not match:
90 new_config.append(line)
91 continue

Subscribers

People subscribed via source and target branches

to all changes: