← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/turnip:fix-masked-data-storage into turnip:master

 

Thiago F. Pappacena has proposed merging ~pappacena/turnip:fix-masked-data-storage into turnip:master.

Commit message:
Making sure to have the data mount when `nfs.available` is triggered without mount-info change 

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~pappacena/turnip/+git/turnip/+merge/389683
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/turnip:fix-masked-data-storage into turnip:master.
diff --git a/charm/layer/turnip-storage/lib/charms/turnip/storage.py b/charm/layer/turnip-storage/lib/charms/turnip/storage.py
index b4cc3ea..4770b93 100644
--- a/charm/layer/turnip-storage/lib/charms/turnip/storage.py
+++ b/charm/layer/turnip-storage/lib/charms/turnip/storage.py
@@ -20,6 +20,15 @@ from charms.turnip.base import (
     )
 
 
+def ensure_mounted():
+    # If the service is stopped, start it. Make sure it is also unmasked to
+    # avoid blocking other services that depends on the data mount.
+    data_mount = data_mount_unit()
+    host.service('unmask', data_mount)
+    if not host.service_running(data_mount):
+        host.service_resume(data_mount)
+
+
 def mount_data(mount_info):
     # We use a systemd.mount(5) unit rather than a line in /etc/fstab partly
     # because it's easier to deal with a file we can completely overwrite,
diff --git a/charm/layer/turnip-storage/reactive/turnip-storage.py b/charm/layer/turnip-storage/reactive/turnip-storage.py
index 613468f..1b6e7c4 100644
--- a/charm/layer/turnip-storage/reactive/turnip-storage.py
+++ b/charm/layer/turnip-storage/reactive/turnip-storage.py
@@ -19,6 +19,7 @@ from charms.reactive import (
 
 from charms.turnip.base import data_dir
 from charms.turnip.storage import (
+    ensure_mounted,
     ensure_repo_store_writable,
     mount_data,
     unmount_data,
@@ -78,6 +79,12 @@ def nfs_available():
             ensure_repo_store_writable()
         toggle_flag('turnip.storage.nfs', mount_info is not None)
         update_storage_available()
+    # If mount-info didn't changed but is present, let's just make sure that
+    # the data storage is mounted.
+    elif mount_info is not None:
+        ensure_mounted()
+        set_flag('turnip.storage.nfs')
+        update_storage_available()
 
 
 @when_any('turnip.storage.nfs-requested', 'turnip.storage.nfs')