Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

[runtime] decompress the framework when the size is large #3820

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/kube-runtime/build/kube-runtime.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ COPY GOPATH/src/github.com/microsoft/runtime/ ${PROJECT_DIR}
RUN ${PROJECT_DIR}/build/runtime/go-build.sh && \
mv ${PROJECT_DIR}/dist/runtime/ ${INSTALL_DIR}

FROM python:2.7-alpine3.8
FROM python:3.7-alpine

RUN pip install PyYAML

Expand Down
2 changes: 1 addition & 1 deletion src/kube-runtime/src/init.d/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def run_script(script_path, parameters, plugin_scripts):
line = proc.stdout.readline()
if not line:
break
line = line.encode("UTF-8").strip()
line = line.decode("utf-8").strip()
logger.info(line)
proc.wait()
if proc.returncode:
Expand Down
21 changes: 18 additions & 3 deletions src/kube-runtime/src/init.d/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

from __future__ import print_function

import os
import sys
import argparse
import base64
import collections
import logging
import argparse
import gzip
import json
import os
import sys
import yaml

logger = logging.getLogger(__name__)
Expand All @@ -33,6 +35,14 @@ def export(k, v):
print("export {}='{}'".format(k, v))


def decompressField(field):
if not field:
return
data = gzip.decompress(base64.b64decode(field))
obj = json.loads(data)
return obj


def generate_runtime_env(framework):
"""Generate runtime env variables for tasks.

Expand Down Expand Up @@ -68,7 +78,12 @@ def generate_runtime_env(framework):
}
logger.info("task roles: {}".format(taskroles))

# decompress taskRoleStatuses for the large framework
taskrole_instances = []
if not framework["status"]["attemptStatus"]["taskRoleStatuses"]:
framework["status"]["attemptStatus"]["taskRoleStatuses"] = decompressField(
framework["status"]["attemptStatus"]["taskRoleStatusesCompressed"])

for taskrole in framework["status"]["attemptStatus"]["taskRoleStatuses"]:
name = taskrole["name"]
ports = taskroles[name]["ports"]
Expand Down