Skip to content

Commit

Permalink
Create the workflow context in the Popper cache dir
Browse files Browse the repository at this point in the history
Earlier the Kubernetes runner used to create the workflow context tar file in the workspace. To prevent that, the context tar file is now created in `$POPPER_CACHE_DIR/kubernetes` directory. Also, the workflow context file is appended with the workflow id so that we can later build the feature of resuing a workflow context tar file.


Co-authored-by: Vivek Ramanathan <vivek@Viveks-MBP.attlocal.net>
  • Loading branch information
vivekr123 and Vivek Ramanathan committed Nov 30, 2020
1 parent 7dfa179 commit b66140f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/popper/runner_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,17 @@ def _copy_ctx(self):
"""Tar up the workspace context and copy the tar file into
the PersistentVolume in the Pod.
"""
source_dir = os.path.join(self._config.cache_dir, "kubernetes")
if not os.path.exists(source_dir):
os.makedirs(source_dir)

target_file = "ctx_" + str(self._config.wid) + ".tar.gz"
source_file = os.path.join(source_dir, target_file)
destination_file = "/workspace/" + target_file

files = os.listdir(self._config.workspace_dir)
with tarfile.open(
os.path.join(self._config.workspace_dir, "ctx.tar.gz"), mode="w:gz"
) as archive:

with tarfile.open(source_file, mode="w:gz") as archive:
for f in files:
archive.add(f)

Expand All @@ -152,9 +159,6 @@ def _copy_ctx(self):
_preload_content=False,
)

source_file = os.path.join(self._config.workspace_dir, "ctx.tar.gz")
destination_file = "/workspace/ctx.tar.gz"

with open(source_file, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())

Expand All @@ -177,7 +181,7 @@ def _copy_ctx(self):
response.close()

# extract the archive inside the pod
exec_command = ["tar", "-zxvf", "/workspace/ctx.tar.gz"]
exec_command = ["tar", "-zxvf", destination_file]
response = stream(
self._kclient.connect_get_namespaced_pod_exec,
self._init_pod_name,
Expand Down

0 comments on commit b66140f

Please sign in to comment.