Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: client/run_isolated.py

Issue 1871113002: Stop choosing $TMPDIR as a safe place to create hardlinks on OSX. (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2012 The LUCI Authors. All rights reserved. 2 # Copyright 2012 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed by the Apache v2.0 license that can be 3 # Use of this source code is governed by the Apache v2.0 license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Reads a .isolated, creates a tree of hardlinks and runs the test. 6 """Reads a .isolated, creates a tree of hardlinks and runs the test.
7 7
8 To improve performance, it keeps a local cache. The local cache can safely be 8 To improve performance, it keeps a local cache. The local cache can safely be
9 deleted. 9 deleted.
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 package.add_directory(os.path.join(BASE_DIR, 'third_party')) 81 package.add_directory(os.path.join(BASE_DIR, 'third_party'))
82 package.add_directory(os.path.join(BASE_DIR, 'utils')) 82 package.add_directory(os.path.join(BASE_DIR, 'utils'))
83 return package 83 return package
84 84
85 85
86 def make_temp_dir(prefix, root_dir=None): 86 def make_temp_dir(prefix, root_dir=None):
87 """Returns a temporary directory. 87 """Returns a temporary directory.
88 88
89 If root_dir is given and /tmp is on same file system as root_dir, uses /tmp. 89 If root_dir is given and /tmp is on same file system as root_dir, uses /tmp.
90 Otherwise makes a new temp directory under root_dir. 90 Otherwise makes a new temp directory under root_dir.
91
92 Except on OSX, because it's dangerous to create hardlinks in $TMPDIR on OSX!
93 /System/Library/LaunchDaemons/com.apple.bsd.dirhelper.plist runs every day at
94 3:35am and deletes all files older than 3 days in $TMPDIR, but hardlinks do
95 not have the inode modification time updated, so they tend to be old, thus
96 they get deleted.
91 """ 97 """
92 base_temp_dir = None 98 base_temp_dir = None
93 if (root_dir and 99 real_temp_dir = unicode(tempfile.gettempdir())
94 not file_path.is_same_filesystem( 100 if sys.platform == 'darwin':
95 root_dir, unicode(tempfile.gettempdir()))): 101 # Nope! Nope! Nope!
102 assert root_dir, 'It is unsafe to create hardlinks in $TMPDIR'
103 base_temp_dir = root_dir
104 elif root_dir and not file_path.is_same_filesystem(root_dir, real_temp_dir):
96 base_temp_dir = root_dir 105 base_temp_dir = root_dir
97 return unicode(tempfile.mkdtemp(prefix=prefix, dir=base_temp_dir)) 106 return unicode(tempfile.mkdtemp(prefix=prefix, dir=base_temp_dir))
98 107
99 108
100 def change_tree_read_only(rootdir, read_only): 109 def change_tree_read_only(rootdir, read_only):
101 """Changes the tree read-only bits according to the read_only specification. 110 """Changes the tree read-only bits according to the read_only specification.
102 111
103 The flag can be 0, 1 or 2, which will affect the possibility to modify files 112 The flag can be 0, 1 or 2, which will affect the possibility to modify files
104 and create or delete files. 113 and create or delete files.
105 """ 114 """
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 assert storage.hash_algo == cache.hash_algo 543 assert storage.hash_algo == cache.hash_algo
535 return run_tha_test( 544 return run_tha_test(
536 options.isolated, storage, cache, options.leak_temp_dir, options.json, 545 options.isolated, storage, cache, options.leak_temp_dir, options.json,
537 options.root_dir, options.hard_timeout, options.grace_period, args) 546 options.root_dir, options.hard_timeout, options.grace_period, args)
538 547
539 548
540 if __name__ == '__main__': 549 if __name__ == '__main__':
541 # Ensure that we are always running with the correct encoding. 550 # Ensure that we are always running with the correct encoding.
542 fix_encoding.fix_encoding() 551 fix_encoding.fix_encoding()
543 sys.exit(main(sys.argv[1:])) 552 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698