20973899 Installation of zones in parallel may fail with: [Errno 17] File exists default tip
authorBart Smaalders <Bart.Smaalders@Oracle.COM>
Thu, 30 Mar 2017 17:05:02 -0700
changeset 3537 03bba058e598
parent 3536 dc2dc8d8eacc
20973899 Installation of zones in parallel may fail with: [Errno 17] File exists
src/modules/altroot.py
src/modules/client/linkedimage/common.py
--- a/src/modules/altroot.py	Wed Mar 29 22:28:03 2017 -0700
+++ b/src/modules/altroot.py	Thu Mar 30 17:05:02 2017 -0700
@@ -21,7 +21,7 @@
 #
 
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 """
@@ -265,7 +265,7 @@
         os.close(dst_dir_fd)
         return
 
-def ar_mkdir(root, path, mode):
+def ar_mkdir(root, path, mode, exists_is_ok=False):
         """A function similar to os.mkdir() that ensures that the path we're
         opening resides within a specified directory subtree.
 
@@ -287,6 +287,8 @@
                 sat.mkdirat(path_dir_fd, path_file, mode)
         except OSError as e:
                 os.close(path_dir_fd)
+                if exists_is_ok and e.errno == errno.EEXIST:
+                        return
                 raise e
 
         os.close(path_dir_fd)
--- a/src/modules/client/linkedimage/common.py	Wed Mar 29 22:28:03 2017 -0700
+++ b/src/modules/client/linkedimage/common.py	Thu Mar 30 17:05:02 2017 -0700
@@ -21,7 +21,7 @@
 #
 
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 """
@@ -3596,7 +3596,8 @@
 
         try:
                 if not ar.ar_exists(root, path_dir):
-                        ar.ar_mkdir(root, path_dir, misc.PKG_DIR_MODE)
+                        ar.ar_mkdir(root, path_dir, misc.PKG_DIR_MODE,
+                            exists_is_ok=True) # parallel zone create race
 
                 # write the output to a temporary file
                 fd = ar.ar_open(root, pathtmp, os.O_WRONLY,