Merge lp:~tribaal/charms/precise/storage/make-local-provider-answer into lp:charms/storage

Proposed by Chris Glass
Status: Merged
Approved by: David Britton
Approved revision: 38
Merged at revision: 37
Proposed branch: lp:~tribaal/charms/precise/storage/make-local-provider-answer
Merge into: lp:charms/storage
Diff against target: 30 lines (+23/-3)
1 file modified
hooks/storage-provider.d/local/data-relation-changed (+23/-3)
To merge this branch: bzr merge lp:~tribaal/charms/precise/storage/make-local-provider-answer
Reviewer Review Type Date Requested Status
Charles Butler (community) Approve
David Britton (community) Approve
Stuart Bishop (community) Approve
Review via email: mp+231065@code.launchpad.net

Description of the change

This fixes the related bug. The local storage provider now simply answers the main charm immediately (since no IO is actually necessary).

To post a comment you must log in.
Revision history for this message
David Britton (dpb) wrote :

I tested this with postgresql and noticed that the default charmhelpers mount creation algorithm has a bug with permissions and ownership. I'll file a bug on that separately, but that led me to think that we should be creating the directory in the local provider so it is ready to go for the caller.

a simple 'os.makedirs()' on the mountpoint if it does not exist would be helpful and expected IMO.

Other than this, things look great. I'll mark needs fixing until then.

review: Needs Fixing
Revision history for this message
David Britton (dpb) wrote :
Revision history for this message
Chris Glass (tribaal) wrote :

Ohhh good catch, thanks. The charm I developed this for already has a mkdirs() call so I didn't see the issue. Will fix.

38. By Chris Glass

Added os.makedirs() call on the mountpoint to make sure it exists.

Revision history for this message
Chris Glass (tribaal) wrote :

Should be fixed now. Let me know if anything else is necessary.

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

Looks good.

review: Approve
Revision history for this message
David Britton (dpb) :
review: Approve
Revision history for this message
Charles Butler (lazypower) wrote :

Worked as advertised. LGTM +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/storage-provider.d/local/data-relation-changed'
2--- hooks/storage-provider.d/local/data-relation-changed 2013-11-29 22:23:56 +0000
3+++ hooks/storage-provider.d/local/data-relation-changed 2014-08-27 05:58:23 +0000
4@@ -1,3 +1,23 @@
5-#!/bin/bash -e
6-
7-exit 0
8+#!/usr/bin/python
9+import sys
10+import os
11+
12+from charmhelpers.core.hookenv import (
13+ relation_get,
14+ relation_set,
15+ log
16+)
17+
18+mountpoint = relation_get("mountpoint")
19+
20+if mountpoint is None:
21+ log("No local mountpoint requested for now, noop.")
22+ sys.exit(0)
23+
24+if not os.path.exists(mountpoint):
25+ log("Requested mountpoint '%s' does not exist. Creating now." % mountpoint)
26+ os.makedirs(mountpoint)
27+
28+log("Notifying the data relation that the mountpoint '%s' is ready "
29+ "(it's local)." % mountpoint)
30+relation_set(mountpoint=mountpoint)

Subscribers

People subscribed via source and target branches

to all changes: