Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add readiness and liveniness probes #126

Merged
merged 5 commits into from
Mar 24, 2018
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ data/

*.tgz
/fission-workflows-bundle
/wfcli
/wfcli
__pycache__/
*.pyc
22 changes: 12 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ cache:
apt: true
directories:
- ${HOME}/.helm/
- ${HOME}/testbin/
- /tmp/fission-workflow-ci/bin
- ${GOPATH}/bin/
- ${GOPATH}/pkg/

env:
- KUBECONFIG=${HOME}/.kube/config PATH=$HOME/testbin:${PATH} BIN_DIR=${HOME}/testbin
- KUBECONFIG=${HOME}/.kube/config PATH=/tmp/fission-workflow-ci/bin:${PATH} BIN_DIR=/tmp/fission-workflow-ci/bin

services:
- docker
Expand All @@ -28,28 +28,30 @@ before_install:

install:
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
- sudo apt-get -y install google-cloud-sdk
- sudo apt-get -y install coreutils
- test/e2e/travis-kube-setup.sh
- sudo apt-get -y install coreutils google-cloud-sdk
- test/e2e/install-clients.sh
# Needed for some integration tests
- glide -h > /dev/null || go get github.com/Masterminds/glide
- nats-streaming-server -h > /dev/null || go get github.com/nats-io/nats-streaming-server
- glide -h >/dev/null 2>&1 || go get github.com/Masterminds/glide
- nats-streaming-server -h >/dev/null 2>&1 || go get github.com/nats-io/nats-streaming-server # TODO remove the need for this

before_script:
- cd ${TRAVIS_BUILD_DIR}
# Static code analysis
- hack/verify-govet.sh
- hack/verify-gofmt.sh
- hack/verify-govet.sh
# Build
- glide install -v
- build/build-linux.sh
- test/e2e/travis-setup.sh

script:
# Unit and Integration tests
- test/runtests.sh
# End-to-end tests
# TODO no need to rebuild (tag images with test ID and check if they exist before starting to rebuild)
- test/e2e/travis-buildtest.sh
- test/e2e/buildtest.sh

after_script:
- test/e2e/cleanup.sh

notifications:
slack:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ See the [compilation guide](./compiling.md).

This is an early release for community participation and user
feedback. It is under active development; none of the interfaces are
stable yet. It should not be used in production.
stable yet. It should not be used in production!

Contributions are welcome in whatever form, including testing,
examples, use cases, or adding features. For an overview of current
Expand Down
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# To run (from repo root): docker build -t fission -f ./build/Dockerfile .
ARG NOBUILD
ARG GOLANG_VERSION=1.9.4
ARG GOLANG_VERSION=1.10.0
FROM golang:$GOLANG_VERSION AS builder
ARG NOBUILD

WORKDIR /go/src/github.com/fission/fission-workflows

Expand Down
5 changes: 2 additions & 3 deletions build/build-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Builders
ARG BUNDLE_IMAGE=fission-workflows-bundle
ARG BUNDLE_TAG=latest
ARG FISSION_BUILDER_IMAGE=fission/builder
ARG FISSION_TAG=0.4.1
ARG FISSION_TAG=0.6.0

# Builders
FROM $BUNDLE_IMAGE:$BUNDLE_TAG as workflows-bundle

FROM $FISSION_BUILDER_IMAGE:$FISSION_TAG

COPY --from=workflows-bundle /wfcli /usr/local/bin/wfcli
Expand Down
18 changes: 7 additions & 11 deletions build/docker.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
#!/usr/bin/env bash

set -e
set -eo pipefail

#
# Builds all docker images. Usage docker.sh [<repo>] [<tag>]
#
BUILD_ROOT=$(dirname $0)

IMAGE_REPO=$1
if [ -z "$IMAGE_REPO" ]; then
IMAGE_REPO=fission
fi

IMAGE_TAG=$2
if [ -z "$IMAGE_TAG" ]; then
IMAGE_TAG=latest
fi
IMAGE_REPO=${1:-fission}
IMAGE_TAG=${2:-latest}

# Build bundle images
bundleImage=${IMAGE_REPO}/fission-workflows-bundle
Expand All @@ -33,20 +25,24 @@ if [ ! -z "$NOBUILD" ]; then
fi
echo "Building bundle..."
docker build --tag="${bundleImage}:${IMAGE_TAG}" -f ${BUILD_ROOT}/Dockerfile \
--no-cache \
--build-arg NOBUILD="${NOBUILD}" .
popd

# Build bundle-dependent images
echo "Building Fission runtime env..."
docker build --tag="${IMAGE_REPO}/workflow-env:${IMAGE_TAG}" ${BUILD_ROOT}/runtime-env/ \
--no-cache \
--build-arg BUNDLE_IMAGE=${bundleImage} \
--build-arg BUNDLE_TAG=${IMAGE_TAG}
echo "Building Fission build env..."
docker build --tag="${IMAGE_REPO}/workflow-build-env:${IMAGE_TAG}" ${BUILD_ROOT}/build-env/ \
--no-cache \
--build-arg BUNDLE_IMAGE=${bundleImage} \
--build-arg BUNDLE_TAG=${IMAGE_TAG}
echo "Building wfcli..."
docker build --tag="${IMAGE_REPO}/wfcli:${IMAGE_TAG}" ${BUILD_ROOT}/wfcli/ \
--no-cache \
--build-arg BUNDLE_IMAGE=${bundleImage} \
--build-arg BUNDLE_TAG=${IMAGE_TAG}

Expand Down
5 changes: 2 additions & 3 deletions build/runtime-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Builders
ARG BUNDLE_IMAGE=fission-workflows-bundle
ARG BUNDLE_TAG=latest
ARG FISSION_BUILDER_IMAGE=fission/builder
ARG FISSION_TAG=0.4.1
ARG FISSION_TAG=0.6.0

# Builders
FROM $BUNDLE_IMAGE:$BUNDLE_TAG as workflows-bundle

FROM scratch

COPY --from=workflows-bundle /fission-workflows-bundle /fission-workflows-bundle
Expand Down
13 changes: 13 additions & 0 deletions charts/fission-workflows/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ spec:
value: "{{ .Values.fnenv.fission.executor }}.{{ .Values.fnenv.fission.ns }}"
- name: FNENV_FISSION_CONTROLLER
value: "{{ .Values.fnenv.fission.controller }}.{{ .Values.fnenv.fission.ns }}"
readinessProbe:
httpGet:
path: "/healthz"
port: 8080
initialDelaySeconds: 1
periodSeconds: 1
failureThreshold: 30
livenessProbe:
httpGet:
path: "/healthz"
port: 8080
initialDelaySeconds: 30
periodSeconds: 5
---
# TODO remove this service once all functionality is accessible through Fission
apiVersion: v1
Expand Down
9 changes: 3 additions & 6 deletions cmd/fission-workflows-bundle/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ func Run(ctx context.Context, opts *Options) error {
es = natsEs
esPub = natsEs
}
if es == nil {
panic("no event store provided")
}

// Caches
wfiCache := getWorkflowInvocationCache(ctx, esPub)
Expand Down Expand Up @@ -290,14 +287,14 @@ func runHttpGateway(ctx context.Context, gwSrv *http.Server, adminApiAddr string
mux := grpcruntime.NewServeMux()
grpcOpts := []grpc.DialOption{grpc.WithInsecure()}
if adminApiAddr != "" {
err := apiserver.RegisterWorkflowAPIHandlerFromEndpoint(ctx, mux, adminApiAddr, grpcOpts)
err := apiserver.RegisterAdminAPIHandlerFromEndpoint(ctx, mux, adminApiAddr, grpcOpts)
if err != nil {
panic(err)
}
}

if wfApiAddr != "" {
err := apiserver.RegisterAdminAPIHandlerFromEndpoint(ctx, mux, wfApiAddr, grpcOpts)
err := apiserver.RegisterWorkflowAPIHandlerFromEndpoint(ctx, mux, wfApiAddr, grpcOpts)
if err != nil {
panic(err)
}
Expand All @@ -310,7 +307,7 @@ func runHttpGateway(ctx context.Context, gwSrv *http.Server, adminApiAddr string
}
}

gwSrv.Handler = handlers.LoggingHandler(os.Stdout, mux)
gwSrv.Handler = mux
go func() {
err := gwSrv.ListenAndServe()
log.WithField("err", err).Info("HTTP Gateway exited")
Expand Down
2 changes: 1 addition & 1 deletion cmd/wfcli/invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var cmdInvocation = cli.Command{
Usage: "get <workflow-invocation-id> <task-invocation-id>",
Flags: []cli.Flag{
cli.DurationFlag{
Name: "history, h",
Name: "history",
Usage: "Amount history (non-active invocations) to show.",
Value: time.Duration(1) * time.Hour,
},
Expand Down
21 changes: 16 additions & 5 deletions cmd/wfcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,37 @@ import (
"strings"
"text/tabwriter"

"github.com/fission/fission-workflows/pkg/version"
"github.com/urfave/cli"
)

// This is a prototype of the CLI (and will be integrated into the Fission CLI eventually).
func main() {
// fetch the FISSION_URL env variable. If not set, port-forward to controller.
var value string
fissionUrl := os.Getenv("FISSION_URL")
if len(fissionUrl) == 0 {
fissionNamespace := getFissionNamespace()
kubeConfig := getKubeConfigPath()
localPort := setupPortForward(kubeConfig, fissionNamespace, "application=fission-api")
value = "http://127.0.0.1:" + localPort
fmt.Printf("Forwarded Fission API to %s.\n", value)
} else {
value = fissionUrl
}

app := cli.NewApp()
app.Author = "Erwin van Eyk"
app.Email = "[email protected]"
app.Version = version.VERSION
app.EnableBashCompletion = true
app.Usage = "Fission Workflows CLI"
app.Description = "CLI for Fission Workflows"
app.HideVersion = true
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "url, u",
Value: "http://localhost:31313",
Value: value,
EnvVar: "FISSION_URL",
Usage: "Url to the Fission apiserver",
},
Expand Down Expand Up @@ -60,10 +75,6 @@ func table(writer io.Writer, headings []string, rows [][]string) {
}
}

//func createTransportClient(baseUrl *url.URL) *httptransport.Runtime {
// return httptransport.New(baseUrl.Host, "/proxy/workflows-apiserver/", []string{baseUrl.Scheme})
//}

func fail(msg ...interface{}) {
for _, line := range msg {
fmt.Fprintln(os.Stderr, line)
Expand Down
Loading