Add builder manager support (#308)

This change orchestrates function builds.

Environments (in v2) define a builder image, just like they do a runtime image. The builder image contains a build script that's invoked with source and deployment paths (as env vars).

The buildermgr watches for environments with build images defined, and creates build deployments and services.

Functions can define source and deployment. Buildermgr watches for functions with source code (and build status == pending) and invokes the environment's builder when appropriate. It captures logs from the build and sets the build status (success/failure) and build lots into the PackageStatus.
This commit is contained in:
Ta-Ching Chen
2017-09-25 07:53:09 -07:00
committed by Soam Vasani
parent a720377f3c
commit e587eca08f
40 changed files with 1827 additions and 176 deletions
+2 -2
View File
@@ -6,6 +6,6 @@ RUN pip3 install --upgrade pip
RUN rm -r /root/.cache
ADD defaultBuildCmd /usr/local/bin/build
ADD builder /
ADD builder /builder
EXPOSE 8000
EXPOSE 8001
-11
View File
@@ -1,11 +0,0 @@
#!/bin/sh
set -e
builderDir=${GOPATH}/src/github.com/fission/fission/builder/cmd
pushd ${builderDir}
GOOS=linux GOARCH=386 go build -o builder .
popd
cp ${builderDir}/builder .
docker build -t python-builder .
docker tag python-builder fission/python-builder:$tag
docker push fission/python-builder:$tag
+16 -2
View File
@@ -3,21 +3,35 @@
import logging
import sys
import imp
import os
from flask import Flask, request, abort, g
app = Flask(__name__)
codepath = '/userfunc/user'
userfunc = None
@app.route('/specialize', methods=['POST'])
def load():
global userfunc
# load user function from codepath
codepath = '/userfunc/user'
userfunc = (imp.load_source('user', codepath)).main
return ""
@app.route('/v2/specialize', methods=['POST'])
def loadv2():
global userfunc
body = request.get_json()
filepath = body['filepath']
functionName = body['functionName']
# add filepath into syspath for module import
sys.path.append(filepath)
fn, path, desc = imp.find_module('user', [filepath])
mod = imp.load_module('user', fn, path, desc)
userfunc = getattr(mod, functionName)
return ""
@app.route('/', methods=['GET', 'POST', 'PUT', 'HEAD', 'OPTIONS', 'DELETE'])
def f():
if userfunc == None: