Skip to content

Commit

Permalink
Merge pull request #132 from fission/fission-0.6.1
Browse files Browse the repository at this point in the history
* bump fission 0.6.0 -> 0.6.1

* Speed up builds in travis by using 

* Changed wfcli to use consistent client connections with Fission only when needed

* Fixed bug in httpclient: crashing on empty response body

* Moved Fission proxy path prefix to wfcli client
  • Loading branch information
erwinvaneyk authored Mar 26, 2018
2 parents e2cf04e + 46192e8 commit 1f1d4c6
Show file tree
Hide file tree
Showing 22 changed files with 268 additions and 211 deletions.
1 change: 1 addition & 0 deletions .Dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ vendor
local
Docs
data
api
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ cache:
apt: true
directories:
- ${HOME}/.helm/
- ${HOME}/.glide/
- /tmp/fission-workflow-ci/bin
- ${GOPATH}/bin/
- ${GOPATH}/pkg/

env:
- KUBECONFIG=${HOME}/.kube/config PATH=/tmp/fission-workflow-ci/bin:${PATH} BIN_DIR=/tmp/fission-workflow-ci/bin
global:
- KUBECONFIG=${HOME}/.kube/config
- PATH=/tmp/fission-workflow-ci/bin:${PATH}
- BIN_DIR=/tmp/fission-workflow-ci/bin
- FISSION_VERSION=0.6.1
- HELM_VERSION=2.8.2
- KUBECTL_VERSION=1.9.6

services:
- docker
Expand Down Expand Up @@ -48,7 +55,7 @@ script:
# Unit and Integration tests
- test/runtests.sh
# End-to-end tests
- test/e2e/buildtest.sh
- NOBUILD=y test/e2e/buildtest.sh

after_script:
- test/e2e/cleanup.sh
Expand Down
1 change: 1 addition & 0 deletions build/build-linux.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh

rm -f ./fission-workflows-bundle ./wfcli
GOOS=linux GOARCH=386 go build github.com/fission/fission-workflows/cmd/fission-workflows-bundle/
GOOS=linux GOARCH=386 go build github.com/fission/fission-workflows/cmd/wfcli/
19 changes: 10 additions & 9 deletions charts/fission-workflows/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,16 @@ spec:
version: 2
runtime:
image: "{{ .Values.envImage }}:{{.Values.tag}}"
env:
- name: ES_NATS_URL
value: "nats://{{ .Values.nats.authToken }}@{{ .Values.nats.location }}.{{ .Values.fnenv.fission.ns }}:{{ .Values.nats.port }}"
- name: ES_NATS_CLUSTER
value: "{{ .Values.nats.cluster }}"
- name: FNENV_FISSION_CONTROLLER
value: "{{ .Values.fnenv.fission.controller }}.{{ .Values.fnenv.fission.ns }}"
- name: FNENV_FISSION_EXECUTOR
value: "{{ .Values.fnenv.fission.executor }}.{{ .Values.fnenv.fission.ns }}"
container:
env:
- name: ES_NATS_URL
value: "nats://{{ .Values.nats.authToken }}@{{ .Values.nats.location }}.{{ .Values.fnenv.fission.ns }}:{{ .Values.nats.port }}"
- name: ES_NATS_CLUSTER
value: "{{ .Values.nats.cluster }}"
- name: FNENV_FISSION_CONTROLLER
value: "{{ .Values.fnenv.fission.controller }}.{{ .Values.fnenv.fission.ns }}"
- name: FNENV_FISSION_EXECUTOR
value: "{{ .Values.fnenv.fission.executor }}.{{ .Values.fnenv.fission.ns }}"
builder:
image: "{{ .Values.buildEnvImage }}:{{.Values.tag}}"
command: "defaultBuild"
Expand Down
28 changes: 10 additions & 18 deletions cmd/wfcli/admin.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package main

import (
"context"
"net/http"

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

Expand All @@ -16,31 +12,27 @@ var cmdAdmin = cli.Command{
cmdVersion,
{
Name: "halt",
Usage: "Stop the workflow engine from evaluating anything",
Action: func(c *cli.Context) error {
ctx := context.TODO()
url := parseUrl(c.GlobalString("url"))
admin := httpclient.NewAdminApi(url.String(), http.Client{})
err := admin.Halt(ctx)
Usage: "Stop the Workflow engine from evaluating anything",
Action: commandContext(func(ctx Context) error {
client := getClient(ctx)
err := client.Admin.Halt(ctx)
if err != nil {
panic(err)
}
return nil
},
}),
},
{
Name: "resume",
Usage: "Resume the workflow engine evaluations",
Action: func(c *cli.Context) error {
ctx := context.TODO()
url := parseUrl(c.GlobalString("url"))
admin := httpclient.NewAdminApi(url.String(), http.Client{})
err := admin.Resume(ctx)
Usage: "Resume the Workflow engine evaluations",
Action: commandContext(func(ctx Context) error {
client := getClient(ctx)
err := client.Admin.Resume(ctx)
if err != nil {
panic(err)
}
return nil
},
}),
},
},
}
12 changes: 6 additions & 6 deletions cmd/wfcli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
var cmdConfig = cli.Command{
Name: "config",
Usage: "Print wfcli config",
Action: func(c *cli.Context) error {
Action: commandContext(func(ctx Context) error {
fmt.Println("cli:")
for _, flag := range c.GlobalFlagNames() {
fmt.Printf(" %s: %v\n", flag, c.GlobalGeneric(flag))
for _, flag := range ctx.GlobalFlagNames() {
fmt.Printf(" %s: %v\n", flag, ctx.GlobalGeneric(flag))
}
for _, flag := range c.FlagNames() {
fmt.Printf(" %s: %v\n", flag, c.Generic(flag))
for _, flag := range ctx.FlagNames() {
fmt.Printf(" %s: %v\n", flag, ctx.Generic(flag))
}
return nil
},
}),
}
103 changes: 40 additions & 63 deletions cmd/wfcli/invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"net/http"
"os"
"sort"
"time"
Expand All @@ -17,34 +16,29 @@ import (

var cmdInvocation = cli.Command{
Name: "invocation",
Aliases: []string{"wi", "invocations", "workflow-invocation", "wfi"},
Usage: "Workflow Invocation-related commands",
Aliases: []string{"wi", "invocations", "Workflow-Invocation", "wfi"},
Usage: "Workflow invocation-related commands",
Subcommands: []cli.Command{
{
Name: "get",
Usage: "get <workflow-invocation-id> <task-invocation-id>",
Usage: "get <Workflow-Invocation-id> <task-Invocation-id>",
Flags: []cli.Flag{
cli.DurationFlag{
Name: "history",
Usage: "Amount history (non-active invocations) to show.",
Value: time.Duration(1) * time.Hour,
},
},
Action: func(c *cli.Context) error {
//u := parseUrl(c.GlobalString("url"))
//client := createTransportClient(u)
//wfiApi := workflow_invocation_api.New(client, strfmt.Default)
ctx := context.TODO()
url := parseUrl(c.GlobalString("url"))
wfiApi := httpclient.NewInvocationApi(url.String(), http.Client{})
switch c.NArg() {
Action: commandContext(func(ctx Context) error {
client := getClient(ctx)
switch ctx.NArg() {
case 0:
since := c.Duration("history")
invocationsList(os.Stdout, wfiApi, time.Now().Add(-since))
since := ctx.Duration("history")
invocationsList(os.Stdout, client.Invocation, time.Now().Add(-since))
case 1:
// Get Workflow invocation
wfiId := c.Args().Get(0)
wfi, err := wfiApi.Get(ctx, wfiId)
// Get Workflow Invocation
wfiId := ctx.Args().Get(0)
wfi, err := client.Invocation.Get(ctx, wfiId)
if err != nil {
panic(err)
}
Expand All @@ -56,15 +50,15 @@ var cmdInvocation = cli.Command{
case 2:
fallthrough
default:
wfiId := c.Args().Get(0)
taskId := c.Args().Get(1)
wfi, err := wfiApi.Get(ctx, wfiId)
wfiId := ctx.Args().Get(0)
taskId := ctx.Args().Get(1)
wfi, err := client.Invocation.Get(ctx, wfiId)
if err != nil {
panic(err)
}
ti, ok := wfi.Status.Tasks[taskId]
if !ok {
fmt.Println("Task invocation not found.")
fmt.Println("Task Invocation not found.")
return nil
}
b, err := yaml.Marshal(ti)
Expand All @@ -75,30 +69,25 @@ var cmdInvocation = cli.Command{
}

return nil
},
}),
},
{
Name: "cancel",
Usage: "cancel <workflow-invocation-id>",
Action: func(c *cli.Context) error {
wfiId := c.Args().Get(0)
//u := parseUrl(c.GlobalString("url"))
//client := createTransportClient(u)
//wfiApi := workflow_invocation_api.New(client, strfmt.Default)
ctx := context.TODO()
url := parseUrl(c.GlobalString("url"))
wfiApi := httpclient.NewInvocationApi(url.String(), http.Client{})
err := wfiApi.Cancel(ctx, wfiId)
Usage: "cancel <Workflow-Invocation-id>",
Action: commandContext(func(ctx Context) error {
client := getClient(ctx)
wfiId := ctx.Args().Get(0)
err := client.Invocation.Cancel(ctx, wfiId)
if err != nil {
panic(err)
}
return nil
},
}),
},
{
// TODO support input
Name: "invoke",
Usage: "invoke <workflow-id>",
Usage: "invoke <Workflow-id>",
Flags: []cli.Flag{
cli.StringSliceFlag{
Name: "input, i",
Expand All @@ -109,20 +98,15 @@ var cmdInvocation = cli.Command{
Usage: "Invoke synchronously",
},
},
Action: func(c *cli.Context) error {
wfId := c.Args().Get(0)
//u := parseUrl(c.GlobalString("url"))
//client := createTransportClient(u)
//wfiApi := workflow_invocation_api.New(client, strfmt.Default)
ctx := context.TODO()
url := parseUrl(c.GlobalString("url"))
wfiApi := httpclient.NewInvocationApi(url.String(), http.Client{})
Action: commandContext(func(ctx Context) error {
client := getClient(ctx)
wfId := ctx.Args().Get(0)
spec := &types.WorkflowInvocationSpec{
WorkflowId: wfId,
Inputs: map[string]*types.TypedValue{},
}
if c.Bool("sync") {
resp, err := wfiApi.InvokeSync(ctx, spec)
if ctx.Bool("sync") {
resp, err := client.Invocation.InvokeSync(ctx, spec)
if err != nil {
panic(err)
}
Expand All @@ -132,39 +116,32 @@ var cmdInvocation = cli.Command{
}
fmt.Println(string(bs))
} else {
resp, err := wfiApi.Invoke(ctx, spec)
resp, err := client.Invocation.Invoke(ctx, spec)
if err != nil {
panic(err)
}
fmt.Println(resp.Id)
}
return nil
},
}),
},
{
Name: "status",
Usage: "status <workflow-invocation-id> ",
Action: func(c *cli.Context) error {
if c.NArg() < 1 {
fmt.Println("Need workflow invocation id")
Usage: "status <Workflow-Invocation-id> ",
Action: commandContext(func(ctx Context) error {
if ctx.NArg() < 1 {
fmt.Println("Need Workflow Invocation id")
return nil
}
wfiId := c.Args().Get(0)
//u := parseUrl(c.GlobalString("url"))
//client := createTransportClient(u)
//wfApi := workflow_api.New(client, strfmt.Default)
//wfiApi := workflow_invocation_api.New(client, strfmt.Default)
ctx := context.TODO()
url := parseUrl(c.GlobalString("url"))
wfiApi := httpclient.NewInvocationApi(url.String(), http.Client{})
wfApi := httpclient.NewWorkflowApi(url.String(), http.Client{})

wfi, err := wfiApi.Get(ctx, wfiId)
client := getClient(ctx)
wfiId := ctx.Args().Get(0)

wfi, err := client.Invocation.Get(ctx, wfiId)
if err != nil {
panic(err)
}

wf, err := wfApi.Get(ctx, wfi.Spec.WorkflowId)
wf, err := client.Workflow.Get(ctx, wfi.Spec.WorkflowId)
if err != nil {
panic(err)
}
Expand All @@ -190,7 +167,7 @@ var cmdInvocation = cli.Command{

table(os.Stdout, []string{"TASK", "STATUS", "STARTED", "UPDATED"}, rows)
return nil
},
}),
},
},
}
Expand Down
Loading

0 comments on commit 1f1d4c6

Please sign in to comment.