Reply
Highlighted
Explorer
Posts: 6
Registered: ‎07-13-2017

Unable to start Agent in Azure

I am using CDH 5.12.0 and just experienced an error that I debugged and fixed in the agent Python code. Here is the patch:

 

--- /usr/lib64/cmf/agent/build/env/lib/python2.7/site-packages/cmf-5.12.0-py2.7.egg/cmf/tmpfs.py.orig	2017-08-04 19:58:34.515680774 +0000
+++ /usr/lib64/cmf/agent/build/env/lib/python2.7/site-packages/cmf-5.12.0-py2.7.egg/cmf/tmpfs.py	2017-08-04 19:52:00.987008633 +0000
@@ -59,15 +59,18 @@
   # Set up or reuse an executable tmpfs mount, if found.
   reuse = False
   for p in psutil.disk_partitions(all=True):
-    if os.path.samefile(p.mountpoint, path) and p.fstype == "tmpfs" and "noexec" not in p.opts:
-      if clean_existing:
-        if not _mount_tmpfs(path, False, sudo=sudo):
-          # Failed to unmount, reuse.
+    try:
+      if os.path.samefile(p.mountpoint, path) and p.fstype == "tmpfs" and "noexec" not in p.opts:
+        if clean_existing:
+          if not _mount_tmpfs(path, False, sudo=sudo):
+            # Failed to unmount, reuse.
+            reuse = True
+        else:
+          # Existing tmpfs without noexec, reuse.
           reuse = True
-      else:
-        # Existing tmpfs without noexec, reuse.
-        reuse = True
-      break
+        break
+    except OSError:
+      LOG.exception("OSError when comparing partitions, ignoring")
   if reuse:
     LOG.info("Reusing mounted tmpfs at %s" % (path,))
     return True

Here is the exception logged:

[04/Aug/2017 19:54:03 +0000] 5545 MainThread tmpfs        ERROR    OSError when comparing partitions, ignoring
Traceback (most recent call last):
  File "/usr/lib64/cmf/agent/build/env/lib/python2.7/site-packages/cmf-5.12.0-py2.7.egg/cmf/tmpfs.py", line 63, in mount_tmpfs
    if os.path.samefile(p.mountpoint, path) and p.fstype == "tmpfs" and "noexec" not in p.opts:
  File "/usr/lib64/python2.7/posixpath.py", line 162, in samefile
    s1 = os.stat(f1)
OSError: [Errno 2] No such file or directory: '/mnt/resource'

My Azure VM has the ephermeral storage mounted at '/mnt', not '/mnt/resource' but for some reason this is still registered as a mount in the system. The patch above will handle the exception and allow the agent installation to complete successfull.