Merge lp:~cjwatson/charms/xenial/storage/fix-nfs into lp:~stub/charms/xenial/storage/trunk

Proposed by Colin Watson
Status: Needs review
Proposed branch: lp:~cjwatson/charms/xenial/storage/fix-nfs
Merge into: lp:~stub/charms/xenial/storage/trunk
Diff against target: 121 lines (+11/-13)
8 files modified
hooks/common_util.py (+5/-6)
hooks/storage-provider.d/block-storage-broker/block-storage-relation-broken (+1/-1)
hooks/storage-provider.d/block-storage-broker/block-storage-relation-changed (+1/-1)
hooks/storage-provider.d/local/data-relation-changed (+1/-1)
hooks/storage-provider.d/nfs/config-changed (+0/-2)
hooks/storage-provider.d/nfs/data-relation-changed (+1/-1)
hooks/storage-provider.d/nfs/data-relation-departed (+1/-1)
metadata.yaml (+1/-0)
To merge this branch: bzr merge lp:~cjwatson/charms/xenial/storage/fix-nfs
Reviewer Review Type Date Requested Status
Stuart Bishop Approve
Review via email: mp+360965@code.launchpad.net

Commit message

Drop idmapd reconfiguration from nfs provider. Declare bionic support.

Description of the change

There hasn't been a NEED_IDMAPD entry in /etc/default/nfs-common since at least precise (it's been unconditionally started where needed), and so we don't need to change it or restart idmapd. Furthermore, restarting idmapd fails as of vivid (it's called nfs-idmapd instead), and is superseded on the client side by nfsidmap in any case. With this I was able to deploy this on bionic as a subordinate for charms requiring NFS storage.

I don't really know if this is the best place to send this MP, but it was the only multi-series version I could find. Merging all the disparate versions together, maybe moving them into a storage-charm project, and getting an updated and unified version into the store would be nice ...

To post a comment you must log in.
43. By Colin Watson

Port to Python 3.

This should be safe on >= trusty, as cloud images contain python3, and
charm-helpers will bootstrap the rest as long as the hook #! line works.

I dropped unicode() from the data persistence functions, as it's
unnecessary: on Python 2 a file opened with "w" will accept str writes, and
on Python 3 json.dumps always returns str rather than bytes.

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

Erm, ok.

Any bionic deployments should be using Juju storage rather than this charm as of Juju 2.5.2, after confirming lp:1783419 is fixed.

The code should move out of the charms/xenial namespace to a top level storage-charm project. That isn't your problem though, as the charm already is multi-series and in the wrong namespace. Whoever takes up maintenance of this charm can worry about that.

review: Approve

Unmerged revisions

43. By Colin Watson

Port to Python 3.

This should be safe on >= trusty, as cloud images contain python3, and
charm-helpers will bootstrap the rest as long as the hook #! line works.

I dropped unicode() from the data persistence functions, as it's
unnecessary: on Python 2 a file opened with "w" will accept str writes, and
on Python 3 json.dumps always returns str rather than bytes.

42. By Colin Watson

Declare bionic support.

41. By Colin Watson

Drop idmapd reconfiguration from nfs provider.

There hasn't been a NEED_IDMAPD entry in /etc/default/nfs-common since
at least precise (it's been unconditionally started where needed), and
so we don't need to change it or restart idmapd. Furthermore,
restarting idmapd fails as of vivid (it's called nfs-idmapd instead),
and is superseded on the client side by nfsidmap in any case.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/common_util.py'
2--- hooks/common_util.py 2014-08-27 11:01:14 +0000
3+++ hooks/common_util.py 2018-12-17 14:11:37 +0000
4@@ -29,7 +29,7 @@
5 data = json.load(inputfile)
6 data[key] = value
7 with open(filepath, "w") as outfile:
8- outfile.write(unicode(json.dumps(data, ensure_ascii=False)))
9+ outfile.write(json.dumps(data, ensure_ascii=False))
10
11
12 def _get_persistent_data(key=None, remove_values=False):
13@@ -50,8 +50,7 @@
14 data.pop(key, None)
15 if data:
16 with open(filepath, "w") as outfile:
17- outfile.write(
18- unicode(json.dumps(data, ensure_ascii=False)))
19+ outfile.write(json.dumps(data, ensure_ascii=False))
20 elif os.path.exists(filepath):
21 os.remove(filepath)
22 else:
23@@ -108,7 +107,7 @@
24 message = "WARNING: umount %s failed. Retrying." % mountpoint
25 try:
26 lsof = subprocess.check_output(["lsof", mountpoint])
27- except subprocess.CalledProcessError, e:
28+ except subprocess.CalledProcessError as e:
29 log("WARNING: %s" % str(e), hookenv.WARNING)
30 else:
31 process_name = lsof.split("\n")[1].split()[0]
32@@ -312,7 +311,7 @@
33 metadata = subprocess.check_output(
34 "curl %s/instance-id" % EC2_METADATA_URL, shell=True)
35 return metadata.strip()
36- except subprocess.CalledProcessError, e:
37+ except subprocess.CalledProcessError as e:
38 log("Error: couldn't discover ec2 instance id. %s" % str(e),
39 hookenv.ERROR)
40 sys.exit(1)
41@@ -337,7 +336,7 @@
42 "curl %s/placement/availability-zone" % EC2_METADATA_URL,
43 shell=True)
44 return metadata.strip()
45- except subprocess.CalledProcessError, e:
46+ except subprocess.CalledProcessError as e:
47 log("Error: couldn't discover ec2 availability zone. %s" % str(e),
48 hookenv.ERROR)
49 sys.exit(1)
50
51=== modified file 'hooks/storage-provider.d/block-storage-broker/block-storage-relation-broken'
52--- hooks/storage-provider.d/block-storage-broker/block-storage-relation-broken 2014-02-11 17:34:15 +0000
53+++ hooks/storage-provider.d/block-storage-broker/block-storage-relation-broken 2018-12-17 14:11:37 +0000
54@@ -1,4 +1,4 @@
55-#!/usr/bin/python
56+#!/usr/bin/python3
57
58 import common_util
59
60
61=== modified file 'hooks/storage-provider.d/block-storage-broker/block-storage-relation-changed'
62--- hooks/storage-provider.d/block-storage-broker/block-storage-relation-changed 2014-03-07 08:01:15 +0000
63+++ hooks/storage-provider.d/block-storage-broker/block-storage-relation-changed 2018-12-17 14:11:37 +0000
64@@ -1,4 +1,4 @@
65-#!/usr/bin/python
66+#!/usr/bin/python3
67
68 import common_util
69 import sys
70
71=== modified file 'hooks/storage-provider.d/local/data-relation-changed'
72--- hooks/storage-provider.d/local/data-relation-changed 2014-08-27 05:53:12 +0000
73+++ hooks/storage-provider.d/local/data-relation-changed 2018-12-17 14:11:37 +0000
74@@ -1,4 +1,4 @@
75-#!/usr/bin/python
76+#!/usr/bin/python3
77 import sys
78 import os
79
80
81=== modified file 'hooks/storage-provider.d/nfs/config-changed'
82--- hooks/storage-provider.d/nfs/config-changed 2014-01-22 19:02:54 +0000
83+++ hooks/storage-provider.d/nfs/config-changed 2018-12-17 14:11:37 +0000
84@@ -7,6 +7,4 @@
85 echo nfs-common already installed.
86 else
87 apt-get -y install -qq nfs-common
88- sed -i -e "s/NEED_IDMAPD.*/NEED_IDMAPD=yes/" /etc/default/nfs-common
89 fi
90-service idmapd restart || service idmapd start
91
92=== modified file 'hooks/storage-provider.d/nfs/data-relation-changed'
93--- hooks/storage-provider.d/nfs/data-relation-changed 2014-03-06 16:02:32 +0000
94+++ hooks/storage-provider.d/nfs/data-relation-changed 2018-12-17 14:11:37 +0000
95@@ -1,4 +1,4 @@
96-#!/usr/bin/python
97+#!/usr/bin/python3
98
99 import common_util
100
101
102=== modified file 'hooks/storage-provider.d/nfs/data-relation-departed'
103--- hooks/storage-provider.d/nfs/data-relation-departed 2014-02-10 18:34:02 +0000
104+++ hooks/storage-provider.d/nfs/data-relation-departed 2018-12-17 14:11:37 +0000
105@@ -1,4 +1,4 @@
106-#!/usr/bin/python
107+#!/usr/bin/python3
108
109 import common_util
110
111
112=== modified file 'metadata.yaml'
113--- metadata.yaml 2016-07-04 11:34:30 +0000
114+++ metadata.yaml 2018-12-17 14:11:37 +0000
115@@ -19,5 +19,6 @@
116 block-storage:
117 interface: volume-request
118 series:
119+ - bionic
120 - xenial
121 - trusty

Subscribers

People subscribed via source and target branches

to all changes: