Yuvipanda has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/222690

Change subject: labstore: Minor code cleanup of the exports daemon
......................................................................

labstore: Minor code cleanup of the exports daemon

Change-Id: I5f39013beaceee39d2a05fdc1ed43ac92e5ad79e
---
M modules/labstore/files/nfs-project-exports-daemon
1 file changed, 21 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/90/222690/1

diff --git a/modules/labstore/files/nfs-project-exports-daemon 
b/modules/labstore/files/nfs-project-exports-daemon
index 47901df..998e8ca 100755
--- a/modules/labstore/files/nfs-project-exports-daemon
+++ b/modules/labstore/files/nfs-project-exports-daemon
@@ -122,23 +122,21 @@
         logging.info('Fetched config for project %s, with %s instances',
                      name, len(project.instance_ips))
 
-    return projects
-
-
-def manage_exports(exports_d_base, projects_config_path):
-    """
-    Collects projets that need exports, and then do the exports
-    """
-    projects = get_projects_with_nfs(projects_config_path)
-    logging.info("Found %s projects requiring private mounts", len(projects))
-
     # Validate that there are no duplicate gids
-    gids = [project.gid for project in projects]
+    gids = [p.gid for p in projects]
     if len(set(gids)) != len(gids):
         # OMG DUPLICATES
         logging.error('Duplicate GIDs found in project config, aborting')
         sys.exit(1)
 
+    logging.info("Found %s projects requiring private mounts", len(projects))
+    return projects
+
+
+def sync_exports_files(projects, exports_d_base):
+    """
+    Generate exports files for syncfs
+    """
     for project in projects:
         logging.debug('Writing exports file for %s', project.name)
         path = os.path.join(exports_d_base, '%s.exports' % project.name)
@@ -147,6 +145,9 @@
         logging.info('Wrote exports file for %s', project.name)
 
     logging.debug('Attempting to exportfs')
+
+
+def exportfs():
     try:
         subprocess.check_call([
             '/usr/bin/sudo',
@@ -173,6 +174,11 @@
         help='Turn on debug logging',
         action='store_true'
     )
+    argparser.add_argument(
+        '--dry-run',
+        help='Do a dry run, do not call exportfs',
+        action='store_true'
+    )
 
     args = argparser.parse_args()
 
@@ -188,5 +194,8 @@
     logging.info('Daemon starting')
 
     while True:
-        manage_exports(args.exports_d_path, args.projects_config_path)
+        projects = get_projects_with_nfs(args.projects_config_path)
+        sync_exports_files(projects, args.exports_d_path)
+        if not args._dry_run:
+            exportfs()
         time.sleep(60)

-- 
To view, visit https://gerrit.wikimedia.org/r/222690
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f39013beaceee39d2a05fdc1ed43ac92e5ad79e
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Yuvipanda <yuvipa...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to