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

Commit

Permalink
[runtime] decompress the framework when the size is large (#3820)
Browse files Browse the repository at this point in the history
FC will compress the framework when it's size is large.
Since we need the FC spec in runtime, decompress here.

Also update the python from 2.7 to 3.7
  • Loading branch information
Binyang2014 authored Nov 11, 2019
1 parent eb24c98 commit b290ae1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
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

0 comments on commit b290ae1

Please sign in to comment.