Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#366 from douglasjacobsen/archi…
Browse files Browse the repository at this point in the history
…ve_log_files

Add archival to log files within workspaces
  • Loading branch information
rfbgo authored Jan 10, 2024
2 parents 20f676c + 7a9b671 commit be57378
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/ramble/ramble/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ def _prepare(self):
fs.mkdirp(os.path.dirname(dest))
shutil.copyfile(file, dest)

# Copy logs, but omit all symlinks (i.e. "latest")
archive_logs = os.path.join(self.workspace.latest_archive_path,
ramble.workspace.workspace_log_path)
fs.mkdirp(archive_logs)
for root, dirs, files in os.walk(self.workspace.log_dir):
for name in files:
src_dir = os.path.join(self.workspace.log_dir, root)
src = os.path.join(src_dir, name)
if not (os.path.islink(src_dir) or os.path.islink(src)) \
and os.path.isfile(src):
dest = src.replace(self.workspace.log_dir, archive_logs)
fs.mkdirp(os.path.dirname(dest))
shutil.copyfile(src, dest)

def _complete(self):
if self.create_tar:
tar = which('tar', required=True)
Expand Down
4 changes: 3 additions & 1 deletion lib/ramble/ramble/workspace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
root,
ramble_workspace_var,
namespace,
workspace_config_path
workspace_config_path,
workspace_log_path
)

__all__ = [
Expand Down Expand Up @@ -77,4 +78,5 @@
'ramble_workspace_var',
'namespace',
'workspace_config_path',
'workspace_log_path',
]

0 comments on commit be57378

Please sign in to comment.