Repository: aurora Updated Branches: refs/heads/master 8fa4fb0f3 -> 1c0086ffc
Use "a" mode instead of "w" when opening stdout and stderr. This allows an external log rotation process to truncate stdout and stderr without causing the creation of a sparse file. Testing Done: With "w" mode testfile is 300 bytes despite being truncated externally. ``` % python 3> testfile Python 2.7.6 (default, Sep 9 2014, 15:04:36) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> f = os.fdopen(3, 'w') >>> f.write(100 * 'a') >>> f.flush() % echo -n '' > testfile >>> f.write(200 * 'b') >>> f.flush() % ls -l testfile -rw-r--r-- 1 ksweeney staff 300 Apr 22 15:40 testfile ``` With "a" mode testfile is 200 bytes. ``` % python 3> testfile Python 2.7.6 (default, Sep 9 2014, 15:04:36) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> f = os.fdopen(3, 'a') >>> f.write(100 * 'a') >>> f.flush() % echo -n '' > testfile >>> f.write(200 * 'b') >>> f.flush() % ls -l testfile -rw-r--r-- 1 ksweeney staff 200 Apr 22 15:40 testfile ``` Bugs closed: AURORA-1317 Reviewed at https://reviews.apache.org/r/33455/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/1c0086ff Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/1c0086ff Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/1c0086ff Branch: refs/heads/master Commit: 1c0086ffcf95f9279c11b89ac16f04b5d0d88a7f Parents: 8fa4fb0 Author: Kevin Sweeney <[email protected]> Authored: Mon Aug 3 11:44:40 2015 -0700 Committer: Kevin Sweeney <[email protected]> Committed: Mon Aug 3 11:44:40 2015 -0700 ---------------------------------------------------------------------- src/main/python/apache/thermos/core/process.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/1c0086ff/src/main/python/apache/thermos/core/process.py ---------------------------------------------------------------------- diff --git a/src/main/python/apache/thermos/core/process.py b/src/main/python/apache/thermos/core/process.py index 5ce138d..fe95cb3 100644 --- a/src/main/python/apache/thermos/core/process.py +++ b/src/main/python/apache/thermos/core/process.py @@ -208,8 +208,8 @@ class ProcessBase(object): uid, gid = user.pw_uid, user.pw_gid self._fork_time = self._platform.clock().time() self._setup_ckpt() - self._stdout = safe_open(self._pathspec.with_filename('stdout').getpath('process_logdir'), "w") - self._stderr = safe_open(self._pathspec.with_filename('stderr').getpath('process_logdir'), "w") + self._stdout = safe_open(self._pathspec.with_filename('stdout').getpath('process_logdir'), "a") + self._stderr = safe_open(self._pathspec.with_filename('stderr').getpath('process_logdir'), "a") os.chown(self._stdout.name, user.pw_uid, user.pw_gid) os.chown(self._stderr.name, user.pw_uid, user.pw_gid)
