Move packages to proejct/pkg to follow go project folder structure convention (#1190)
This commit is contained in:
+5
-5
@@ -1,9 +1,9 @@
|
||||
# Binaries
|
||||
fission-bundle/fission-bundle
|
||||
fission/fission
|
||||
environments/fetcher/cmd/fetcher
|
||||
builder/cmd/builder
|
||||
preupgradechecks/pre-upgrade-checks
|
||||
cmd/fission-bundle/fission-bundle
|
||||
cmd/fission-cli/fission
|
||||
cmd/fetcher/fetcher
|
||||
cmd/builder/builder
|
||||
cmd/preupgradechecks/pre-upgrade-checks
|
||||
|
||||
# Logs
|
||||
test/logs/
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ services:
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
|
||||
- sudo apt-get -y install apache2-utils parallel
|
||||
- sudo apt-get -y install apache2-utils parallel realpath
|
||||
- sudo sysctl net.ipv6.conf.all.disable_ipv6=0
|
||||
|
||||
install:
|
||||
@@ -38,7 +38,7 @@ before_script:
|
||||
- helm lint charts/fission-all/ charts/fission-core/
|
||||
- go mod download
|
||||
- go mod vendor
|
||||
- go build -o fission/fission fission/*.go
|
||||
- go build -o cmd/fission-cli/fission ./cmd/fission-cli/
|
||||
- hack/runtests.sh
|
||||
|
||||
script:
|
||||
|
||||
@@ -20,21 +20,21 @@ ARCH ?= amd64
|
||||
OS ?= linux
|
||||
|
||||
test:
|
||||
go test -v $(shell go list ./... | grep -v /examples/ | grep -v /environments/)
|
||||
go test -v $(go list ./... | grep -v /examples/ | grep -v /environments/)
|
||||
|
||||
build: build-bundle build-client
|
||||
|
||||
build-client:
|
||||
go build -o fission/fission ./fission/*.go
|
||||
go build -o cmd/fission-cli/fission ./cmd/fission-cli/
|
||||
|
||||
build-bundle:
|
||||
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o fission-bundle/fission-bundle ./fission-bundle/*.go
|
||||
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o cmd/fission-bundle/fission-bundle ./cmd/fission-bundle/
|
||||
|
||||
build-image:
|
||||
docker build --rm --tag "$(IMAGE):$(VERSION)" fission-bundle
|
||||
docker build --rm --tag "$(IMAGE):$(VERSION)" cmd/fission-bundle/
|
||||
|
||||
install:
|
||||
go install ./fission
|
||||
go install ./cmd/fission-cli/
|
||||
|
||||
image: build-bundle build-image
|
||||
|
||||
|
||||
@@ -12,15 +12,15 @@ ARG BUILDDATE=unknown
|
||||
|
||||
ARG GOPKG=github.com/fission/fission
|
||||
COPY . /go/src/${GOPKG}
|
||||
WORKDIR /go/src/${GOPKG}/builder/cmd
|
||||
WORKDIR /go/src/${GOPKG}/cmd/builder
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-o /go/bin/builder \
|
||||
-gcflags=-trimpath=$GOPATH \
|
||||
-asmflags=-trimpath=$GOPATH \
|
||||
-ldflags "-X github.com/fission/fission.GitCommit=${GITCOMMIT} -X github.com/fission/fission.BuildDate=${BUILDDATE} -X github.com/fission/fission.Version=${BUILDVERSION}"
|
||||
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
|
||||
|
||||
FROM alpine:3.5
|
||||
COPY --from=fission-builder /go/bin/builder /
|
||||
EXPOSE 8001
|
||||
|
||||
ENTRYPOINT ["/builder"]
|
||||
ENTRYPOINT ["/builder"]
|
||||
@@ -14,41 +14,24 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
package app
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
builder "github.com/fission/fission/builder"
|
||||
builder "github.com/fission/fission/pkg/builder"
|
||||
)
|
||||
|
||||
// Usage: builder <shared volume path>
|
||||
func main() {
|
||||
logger, err := zap.NewProduction()
|
||||
if err != nil {
|
||||
log.Fatalf("can't initialize zap logger: %v", err)
|
||||
}
|
||||
defer logger.Sync()
|
||||
|
||||
dir := os.Args[1]
|
||||
if _, err := os.Stat(dir); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
err = os.MkdirAll(dir, os.ModeDir|0700)
|
||||
if err != nil {
|
||||
logger.Fatal("error creating directory", zap.Error(err), zap.String("directory", dir))
|
||||
}
|
||||
}
|
||||
}
|
||||
builder := builder.MakeBuilder(logger, dir)
|
||||
func Run(logger *zap.Logger, shareVolume string) error {
|
||||
builder := builder.MakeBuilder(logger, shareVolume)
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", builder.Handler)
|
||||
mux.HandleFunc("/version", builder.VersionHandler)
|
||||
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
http.ListenAndServe(":8001", mux)
|
||||
return http.ListenAndServe(":8001", mux)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright 2018 The Fission Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission/cmd/builder/app"
|
||||
)
|
||||
|
||||
// Usage: builder <shared volume path>
|
||||
func main() {
|
||||
logger, err := zap.NewProduction()
|
||||
if err != nil {
|
||||
log.Fatalf("can't initialize zap logger: %v", err)
|
||||
}
|
||||
defer logger.Sync()
|
||||
|
||||
shareVolume := os.Args[1]
|
||||
if _, err := os.Stat(shareVolume); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
err = os.MkdirAll(shareVolume, os.ModeDir|0700)
|
||||
if err != nil {
|
||||
logger.Fatal("error creating directory: %v", zap.Error(err), zap.String("directory", shareVolume))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = app.Run(logger, shareVolume)
|
||||
logger.Error("error running builder", zap.Error(err))
|
||||
}
|
||||
+3
-3
@@ -12,15 +12,15 @@ ARG BUILDDATE=unknown
|
||||
|
||||
ARG GOPKG=github.com/fission/fission
|
||||
COPY . /go/src/${GOPKG}
|
||||
WORKDIR /go/src/${GOPKG}/environments/fetcher/cmd
|
||||
WORKDIR /go/src/${GOPKG}/cmd/fetcher
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-o /go/bin/fetcher \
|
||||
-gcflags=-trimpath=$GOPATH \
|
||||
-asmflags=-trimpath=$GOPATH \
|
||||
-ldflags "-X github.com/fission/fission.GitCommit=${GITCOMMIT} -X github.com/fission/fission.BuildDate=${BUILDDATE} -X github.com/fission/fission.Version=${BUILDVERSION}"
|
||||
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
|
||||
|
||||
FROM alpine:3.4
|
||||
COPY --from=builder /go/bin/fetcher /
|
||||
EXPOSE 8000
|
||||
|
||||
ENTRYPOINT ["/fetcher"]
|
||||
ENTRYPOINT ["/fetcher"]
|
||||
@@ -1,11 +1,10 @@
|
||||
package main
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
@@ -14,8 +13,8 @@ import (
|
||||
"go.opencensus.io/trace"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/environments/fetcher"
|
||||
"github.com/fission/fission/pkg/fetcher"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
func registerTraceExporter(collectorEndpoint string) error {
|
||||
@@ -41,14 +40,7 @@ func registerTraceExporter(collectorEndpoint string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Usage: fetcher <shared volume path>
|
||||
func main() {
|
||||
logger, err := zap.NewProduction()
|
||||
if err != nil {
|
||||
log.Fatalf("can't initialize zap logger: %v", err)
|
||||
}
|
||||
defer logger.Sync()
|
||||
|
||||
func Run(logger *zap.Logger) {
|
||||
flag.Usage = fetcherUsage
|
||||
collectorEndpoint := flag.String("jaeger-collector-endpoint", "", "")
|
||||
specializeOnStart := flag.Bool("specialize-on-startup", false, "Flag to activate specialize process at pod starup")
|
||||
@@ -86,7 +78,7 @@ func main() {
|
||||
// do specialization in other goroutine to prevent blocking in newdeploy
|
||||
go func() {
|
||||
if *specializeOnStart {
|
||||
var specializeReq fission.FunctionSpecializeRequest
|
||||
var specializeReq types.FunctionSpecializeRequest
|
||||
|
||||
err := json.Unmarshal([]byte(*specializePayload), &specializeReq)
|
||||
if err != nil {
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2018 The Fission Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission/cmd/fetcher/app"
|
||||
)
|
||||
|
||||
// Usage: fetcher <shared volume path>
|
||||
func main() {
|
||||
logger, err := zap.NewProduction()
|
||||
if err != nil {
|
||||
log.Fatalf("can't initialize zap logger: %v", err)
|
||||
}
|
||||
defer logger.Sync()
|
||||
|
||||
app.Run(logger)
|
||||
}
|
||||
+3
-3
@@ -13,16 +13,16 @@ ARG BUILDDATE=unknown
|
||||
ARG GOPKG=github.com/fission/fission
|
||||
COPY . /go/src/${GOPKG}
|
||||
RUN rm -f /go/src/${GOPKG}/Dockerfile*
|
||||
WORKDIR /go/src/${GOPKG}/fission-bundle
|
||||
WORKDIR /go/src/${GOPKG}/cmd/fission-bundle
|
||||
ENV GO111MODULE=on
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -mod vendor \
|
||||
-o /go/bin/fission-bundle \
|
||||
-gcflags=-trimpath=$GOPATH \
|
||||
-asmflags=-trimpath=$GOPATH \
|
||||
-ldflags "-X github.com/fission/fission.GitCommit=${GITCOMMIT} -X github.com/fission/fission.BuildDate=${BUILDDATE} -X github.com/fission/fission.Version=${BUILDVERSION}"
|
||||
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
|
||||
|
||||
FROM alpine:3.4
|
||||
RUN apk add --update ca-certificates
|
||||
COPY --from=builder /go/bin/fission-bundle /
|
||||
|
||||
ENTRYPOINT ["/fission-bundle"]
|
||||
ENTRYPOINT ["/fission-bundle"]
|
||||
@@ -12,16 +12,16 @@ import (
|
||||
"go.opencensus.io/trace"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/buildermgr"
|
||||
"github.com/fission/fission/controller"
|
||||
"github.com/fission/fission/executor"
|
||||
"github.com/fission/fission/kubewatcher"
|
||||
functionLogger "github.com/fission/fission/logger"
|
||||
"github.com/fission/fission/mqtrigger"
|
||||
"github.com/fission/fission/router"
|
||||
"github.com/fission/fission/storagesvc"
|
||||
"github.com/fission/fission/timer"
|
||||
"github.com/fission/fission/pkg/buildermgr"
|
||||
"github.com/fission/fission/pkg/controller"
|
||||
"github.com/fission/fission/pkg/executor"
|
||||
"github.com/fission/fission/pkg/info"
|
||||
"github.com/fission/fission/pkg/kubewatcher"
|
||||
functionLogger "github.com/fission/fission/pkg/logger"
|
||||
messagequeue "github.com/fission/fission/pkg/mqtrigger"
|
||||
"github.com/fission/fission/pkg/router"
|
||||
"github.com/fission/fission/pkg/storagesvc"
|
||||
"github.com/fission/fission/pkg/timer"
|
||||
)
|
||||
|
||||
func runController(logger *zap.Logger, port int) {
|
||||
@@ -214,7 +214,7 @@ Options:
|
||||
}
|
||||
defer logger.Sync()
|
||||
|
||||
version := fmt.Sprintf("Fission Bundle Version: %v", fission.BuildInfo().String())
|
||||
version := fmt.Sprintf("Fission Bundle Version: %v", info.BuildInfo().String())
|
||||
arguments, err := docopt.Parse(usage, nil, true, version, false)
|
||||
if err != nil {
|
||||
logger.Fatal("Could not parse command line arguments", zap.Error(err))
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 2018 The Fission Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
fcli "github.com/fission/fission/pkg/fission-cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fcli.NewCliApp().Run(os.Args)
|
||||
}
|
||||
+3
-3
@@ -12,12 +12,12 @@ ARG BUILDDATE=unknown
|
||||
|
||||
ARG GOPKG=github.com/fission/fission
|
||||
COPY . /go/src/${GOPKG}
|
||||
WORKDIR /go/src/${GOPKG}/preupgradechecks
|
||||
WORKDIR /go/src/${GOPKG}/cmd/preupgradechecks
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a \
|
||||
-o /go/bin/pre-upgrade-checks \
|
||||
-gcflags=-trimpath=$GOPATH \
|
||||
-asmflags=-trimpath=$GOPATH \
|
||||
-ldflags "-X github.com/fission/fission.GitCommit=${GITCOMMIT} -X github.com/fission/fission.BuildDate=${BUILDDATE} -X github.com/fission/fission.Version=${BUILDVERSION}"
|
||||
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=${GITCOMMIT} -X github.com/fission/fission/pkg/info.BuildDate=${BUILDDATE} -X github.com/fission/fission/pkg/info.Version=${BUILDVERSION}"
|
||||
|
||||
|
||||
FROM alpine:3.4
|
||||
@@ -25,4 +25,4 @@ RUN apk add --update ca-certificates
|
||||
COPY --from=builder /go/bin/pre-upgrade-checks /
|
||||
|
||||
ENTRYPOINT ["/pre-upgrade-checks"]
|
||||
EXPOSE 8001
|
||||
EXPOSE 8001
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/docopt/docopt-go"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/pkg/info"
|
||||
)
|
||||
|
||||
func getStringArgWithDefault(arg interface{}, defaultValue string) string {
|
||||
@@ -47,7 +47,7 @@ Options:
|
||||
--fn-pod-namespace=<podNamespace> Namespace where function pods get deployed.
|
||||
--envbuilder-namespace=<envBuilderNamespace> Namespace where builder env pods are deployed.`
|
||||
|
||||
arguments, err := docopt.Parse(usage, nil, true, fission.BuildInfo().String(), false)
|
||||
arguments, err := docopt.Parse(usage, nil, true, info.BuildInfo().String(), false)
|
||||
if err != nil {
|
||||
logger.Fatal("Could not parse command line arguments", zap.Error(err))
|
||||
}
|
||||
@@ -27,8 +27,10 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -43,7 +45,7 @@ type (
|
||||
)
|
||||
|
||||
const (
|
||||
MaxRetries = 5
|
||||
maxRetries = 5
|
||||
FunctionCRD = "functions.fission.io"
|
||||
)
|
||||
|
||||
@@ -66,7 +68,7 @@ func makePreUpgradeTaskClient(logger *zap.Logger, fnPodNs, envBuilderNs string)
|
||||
// IsFissionReInstall checks if there is atleast one fission CRD, i.e. function in this case, on this cluster.
|
||||
// We need this to find out if fission had been previously installed on this cluster
|
||||
func (client *PreUpgradeTaskClient) IsFissionReInstall() bool {
|
||||
for i := 0; i < MaxRetries; i++ {
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
_, err := client.apiExtClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(FunctionCRD, metav1.GetOptions{})
|
||||
if err != nil && k8serrors.IsNotFound(err) {
|
||||
return false
|
||||
@@ -86,9 +88,9 @@ func (client *PreUpgradeTaskClient) VerifyFunctionSpecReferences() {
|
||||
|
||||
var result *multierror.Error
|
||||
var err error
|
||||
var fList *crd.FunctionList
|
||||
var fList *fv1.FunctionList
|
||||
|
||||
for i := 0; i < MaxRetries; i++ {
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
fList, err = client.fissionClient.Functions(metav1.NamespaceAll).List(metav1.ListOptions{})
|
||||
if err == nil {
|
||||
break
|
||||
@@ -98,7 +100,7 @@ func (client *PreUpgradeTaskClient) VerifyFunctionSpecReferences() {
|
||||
if err != nil {
|
||||
client.logger.Fatal("error listing functions after max retries",
|
||||
zap.Error(err),
|
||||
zap.Int("max_retries", MaxRetries))
|
||||
zap.Int("max_retries", maxRetries))
|
||||
}
|
||||
|
||||
// check that all secrets, configmaps, packages are in the same namespace
|
||||
@@ -134,7 +136,7 @@ func (client *PreUpgradeTaskClient) VerifyFunctionSpecReferences() {
|
||||
// deleteClusterRoleBinding deletes the clusterRoleBinding passed as an argument to it.
|
||||
// If its not present, it just ignores and returns no errors
|
||||
func (client *PreUpgradeTaskClient) deleteClusterRoleBinding(clusterRoleBinding string) (err error) {
|
||||
for i := 0; i < MaxRetries; i++ {
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
err = client.k8sClient.RbacV1beta1().ClusterRoleBindings().Delete(clusterRoleBinding, &metav1.DeleteOptions{})
|
||||
if err != nil && k8serrors.IsNotFound(err) || err == nil {
|
||||
return nil
|
||||
@@ -187,34 +189,34 @@ func (client *PreUpgradeTaskClient) SetupRoleBindings() {
|
||||
|
||||
// the fact that we're here implies that there had been a prior installation of fission and objects are present still
|
||||
// so, we go ahead and create the role-bindings necessary for the fission-fetcher and fission-builder Service Accounts.
|
||||
err := fission.SetupRoleBinding(client.logger, client.k8sClient, fission.PackageGetterRB, metav1.NamespaceDefault, fission.PackageGetterCR, fission.ClusterRole, fission.FissionFetcherSA, client.fnPodNs)
|
||||
err := utils.SetupRoleBinding(client.logger, client.k8sClient, types.PackageGetterRB, metav1.NamespaceDefault, types.PackageGetterCR, types.ClusterRole, types.FissionFetcherSA, client.fnPodNs)
|
||||
if err != nil {
|
||||
client.logger.Fatal("error setting up rolebinding for service account",
|
||||
zap.Error(err),
|
||||
zap.String("role_binding", fission.PackageGetterRB),
|
||||
zap.String("service_account", fission.FissionFetcherSA),
|
||||
zap.String("role_binding", types.PackageGetterRB),
|
||||
zap.String("service_account", types.FissionFetcherSA),
|
||||
zap.String("service_account_namespace", client.fnPodNs))
|
||||
}
|
||||
|
||||
err = fission.SetupRoleBinding(client.logger, client.k8sClient, fission.PackageGetterRB, metav1.NamespaceDefault, fission.PackageGetterCR, fission.ClusterRole, fission.FissionBuilderSA, client.envBuilderNs)
|
||||
err = utils.SetupRoleBinding(client.logger, client.k8sClient, types.PackageGetterRB, metav1.NamespaceDefault, types.PackageGetterCR, types.ClusterRole, types.FissionBuilderSA, client.envBuilderNs)
|
||||
if err != nil {
|
||||
client.logger.Fatal("error setting up rolebinding for service account",
|
||||
zap.Error(err),
|
||||
zap.String("role_binding", fission.PackageGetterRB),
|
||||
zap.String("service_account", fission.FissionBuilderSA),
|
||||
zap.String("role_binding", types.PackageGetterRB),
|
||||
zap.String("service_account", types.FissionBuilderSA),
|
||||
zap.String("service_account_namespace", client.envBuilderNs))
|
||||
}
|
||||
|
||||
err = fission.SetupRoleBinding(client.logger, client.k8sClient, fission.SecretConfigMapGetterRB, metav1.NamespaceDefault, fission.SecretConfigMapGetterCR, fission.ClusterRole, fission.FissionFetcherSA, client.fnPodNs)
|
||||
err = utils.SetupRoleBinding(client.logger, client.k8sClient, types.SecretConfigMapGetterRB, metav1.NamespaceDefault, types.SecretConfigMapGetterCR, types.ClusterRole, types.FissionFetcherSA, client.fnPodNs)
|
||||
if err != nil {
|
||||
client.logger.Fatal("error setting up rolebinding for service account",
|
||||
zap.Error(err),
|
||||
zap.String("role_binding", fission.SecretConfigMapGetterRB),
|
||||
zap.String("service_account", fission.FissionFetcherSA),
|
||||
zap.String("role_binding", types.SecretConfigMapGetterRB),
|
||||
zap.String("service_account", types.FissionFetcherSA),
|
||||
zap.String("service_account_namespace", client.fnPodNs))
|
||||
}
|
||||
|
||||
client.logger.Info("created rolebindings in default namespace",
|
||||
zap.Strings("role_bindings", []string{fission.PackageGetterRB, fission.SecretConfigMapGetterRB}))
|
||||
zap.Strings("role_bindings", []string{types.PackageGetterRB, types.SecretConfigMapGetterRB}))
|
||||
return
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 The Fission Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package crd
|
||||
|
||||
import (
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
Package = fv1.Package
|
||||
PackageList = fv1.PackageList
|
||||
Function = fv1.Function
|
||||
FunctionList = fv1.FunctionList
|
||||
Environment = fv1.Environment
|
||||
EnvironmentList = fv1.EnvironmentList
|
||||
HTTPTrigger = fv1.HTTPTrigger
|
||||
HTTPTriggerList = fv1.HTTPTriggerList
|
||||
KubernetesWatchTrigger = fv1.KubernetesWatchTrigger
|
||||
KubernetesWatchTriggerList = fv1.KubernetesWatchTriggerList
|
||||
TimeTrigger = fv1.TimeTrigger
|
||||
TimeTriggerList = fv1.TimeTriggerList
|
||||
MessageQueueTrigger = fv1.MessageQueueTrigger
|
||||
MessageQueueTriggerList = fv1.MessageQueueTriggerList
|
||||
Recorder = fv1.Recorder
|
||||
RecorderList = fv1.RecorderList
|
||||
CanaryConfig = fv1.CanaryConfig
|
||||
CanaryConfigList = fv1.CanaryConfigList
|
||||
)
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
tag=$1
|
||||
if [ -z "$tag" ]
|
||||
then
|
||||
tag=latest
|
||||
fi
|
||||
|
||||
. build.sh
|
||||
|
||||
docker build -t fission-bundle .
|
||||
docker tag fission-bundle fission/fission-bundle:$tag
|
||||
docker push fission/fission-bundle:$tag
|
||||
@@ -21,6 +21,7 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/blend/go-sdk v1.1.1 h1:R7PcwuIxYvrGc/r9TLLfMpajIboTjqs/HyQouzgJ7mQ=
|
||||
github.com/blend/go-sdk v1.1.1/go.mod h1:IP1XHXFveOXHRnojRJO7XvqWGqyzevtXND9AdSztAe8=
|
||||
github.com/bsm/sarama-cluster v2.1.15+incompatible h1:RkV6WiNRnqEEbp81druK8zYhmnIgdOjqSVi0+9Cnl2A=
|
||||
github.com/bsm/sarama-cluster v2.1.15+incompatible/go.mod h1:r7ao+4tTNXvWm+VRpRJchr2kQhqxgmAp2iEX5W96gMM=
|
||||
@@ -33,6 +34,7 @@ github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9/go.mod h1:GgB8SF9nRG
|
||||
github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda h1:NyywMz59neOoVRFDz+ccfKWxn784fiHMDnZSy6T+JXY=
|
||||
github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
|
||||
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg=
|
||||
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
||||
github.com/docopt/docopt-go v0.0.0-20160216232012-784ddc588536 h1:rHnpq7uNlix5l7tWZ55iJcHHrxCPnOVF4FGb7qOT2Jc=
|
||||
github.com/docopt/docopt-go v0.0.0-20160216232012-784ddc588536/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
||||
@@ -47,6 +49,7 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1
|
||||
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
@@ -56,7 +59,9 @@ github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/example v0.0.0-20170904185048-46695d81d1fa h1:iqCQC2Z53KkwGgTN9szyL4q0OQHmuNjeoNnMT6lk66k=
|
||||
github.com/golang/example v0.0.0-20170904185048-46695d81d1fa/go.mod h1:tO/5UvQ/uKigUjQBPqzstj6uxd3fUIjddi19DxGJeWg=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
@@ -106,6 +111,7 @@ github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3 h1:/UewZcckqhvnnS
|
||||
github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
@@ -173,12 +179,15 @@ github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4=
|
||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/ulikunitz/xz v0.0.0-20180703112113-636d36a76670 h1:HQWT4ta3wW5GZ790GaqLCS+w1dvuA3rMfEQxLi+UOYU=
|
||||
github.com/ulikunitz/xz v0.0.0-20180703112113-636d36a76670/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
|
||||
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/wcharczuk/go-chart v2.0.1+incompatible h1:0pz39ZAycJFF7ju/1mepnk26RLVLBCWz1STcD3doU0A=
|
||||
github.com/wcharczuk/go-chart v2.0.1+incompatible/go.mod h1:PF5tmL4EIx/7Wf+hEkpCqYi5He4u90sw+0+6FhrryuE=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.opencensus.io v0.18.0 h1:Mk5rgZcggtbvtAun5aJzAtjKKN/t0R3jJPlWILlv938=
|
||||
@@ -193,6 +202,7 @@ go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o=
|
||||
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/image v0.0.0-20190321063152-3fc05d484e9f h1:FO4MZ3N56GnxbqxGKqh+YTzUWQ2sDwtFQEZgLOxh9Jc=
|
||||
golang.org/x/image v0.0.0-20190321063152-3fc05d484e9f/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@@ -230,6 +240,7 @@ google.golang.org/api v0.0.0-20181220000619-583d854617af/go.mod h1:4mhQ8q/RsB7i+
|
||||
google.golang.org/api v0.0.0-20190123234818-8001663557ac h1:cb/4gikrQnypAmwdJ80ZtUI2bY4iWg6PNxlMSW+iOoQ=
|
||||
google.golang.org/api v0.0.0-20190123234818-8001663557ac/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk=
|
||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
|
||||
+13
-20
@@ -3,7 +3,7 @@
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
DIR=$(realpath $(dirname $0))/../
|
||||
DIR=`realpath $(dirname $0)/../`
|
||||
BUILDDIR=$(realpath $DIR)/build
|
||||
|
||||
# Build CLI binaries for mac/linux/windows
|
||||
@@ -26,7 +26,7 @@ build_cli() {
|
||||
local gitcommit=$5
|
||||
arch="amd64" # parameterize if/when we need to
|
||||
|
||||
pushd $DIR/fission
|
||||
pushd $DIR/cmd/fission-cli
|
||||
|
||||
if [ "$osName" == "windows" ]
|
||||
then
|
||||
@@ -35,7 +35,8 @@ build_cli() {
|
||||
binary=fission-cli-${osName}
|
||||
fi
|
||||
|
||||
GOOS=$os GOARCH=$arch go build -gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -ldflags "-X github.com/fission/fission.GitCommit=$gitcommit -X github.com/fission/fission.BuildDate=$date -X github.com/fission/fission.Version=$version" -o $binary .
|
||||
GOOS=$os GOARCH=$arch go build -gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH \
|
||||
-ldflags "-X github.com/fission/fission/pkg/info.GitCommit=$gitcommit -X github.com/fission/fission/pkg/info.BuildDate=$date -X github.com/fission/fission/pkg/info.Version=$version" -o $binary .
|
||||
|
||||
outdir=$BUILDDIR/cli/$osName/
|
||||
mkdir -p $outdir
|
||||
@@ -52,8 +53,9 @@ build_fission_bundle_image() {
|
||||
|
||||
local tag=fission/fission-bundle:$version
|
||||
|
||||
docker build -t $tag -f $ROOT/fission-bundle/Dockerfile.fission-bundle --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version .
|
||||
docker tag $tag fission/fission-bundle:latest
|
||||
docker build -t $tag -f $DIR/cmd/fission-bundle/Dockerfile.fission-bundle --build-arg GITCOMMIT=$gitcommit \
|
||||
--build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version $DIR
|
||||
docker tag $tag fission/fission-bundle:latest
|
||||
}
|
||||
|
||||
build_fetcher_image() {
|
||||
@@ -62,12 +64,9 @@ build_fetcher_image() {
|
||||
local gitcommit=$3
|
||||
local tag=fission/fetcher:$version
|
||||
|
||||
pushd $DIR/environments/fetcher/cmd
|
||||
|
||||
docker build -t $tag -f $ROOT/environments/fetcher/cmd/Dockerfile.fission-fetcher --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version .
|
||||
docker build -t $tag -f $DIR/cmd/fetcher/Dockerfile.fission-fetcher --build-arg GITCOMMIT=$gitcommit \
|
||||
--build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version $DIR
|
||||
docker tag $tag fission/fetcher:latest
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
push_fetcher_image() {
|
||||
@@ -81,12 +80,9 @@ build_builder_image() {
|
||||
local gitcommit=$3
|
||||
local tag=fission/builder:$version
|
||||
|
||||
pushd $DIR/builder/cmd
|
||||
|
||||
docker build -t $tag -f $ROOT/builder/cmd/Dockerfile.fission-builder --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version .
|
||||
docker build -t $tag -f $DIR/cmd/builder/Dockerfile.fission-builder --build-arg GITCOMMIT=$gitcommit \
|
||||
--build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version $DIR
|
||||
docker tag $tag fission/builder:latest
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
build_env_image() {
|
||||
@@ -126,12 +122,9 @@ build_pre_upgrade_checks_image() {
|
||||
|
||||
local tag=fission/pre-upgrade-checks:$version
|
||||
|
||||
pushd $DIR/preupgradechecks
|
||||
|
||||
docker build -t $tag -f $ROOT/preupgradechecks/Dockerfile.fission-preupgradechecks --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version .
|
||||
docker build -t $tag -f $DIR/cmd/preupgradechecks/Dockerfile.fission-preupgradechecks \
|
||||
--build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version $DIR
|
||||
docker tag $tag fission/pre-upgrade-checks:latest
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
build_all_envs() {
|
||||
|
||||
@@ -325,6 +325,7 @@ fi
|
||||
release_environment_check $version $chartsrepo
|
||||
|
||||
go mod vendor
|
||||
|
||||
# Build release-builder image
|
||||
docker build -t fission-release-builder -f $GOPATH/src/github.com/fission/fission/hack/Dockerfile .
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/pkg/info"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -74,7 +74,7 @@ func MakeBuilder(logger *zap.Logger, sharedVolumePath string) *Builder {
|
||||
|
||||
func (builder *Builder) VersionHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
fmt.Fprintf(w, fission.BuildInfo().String())
|
||||
fmt.Fprintf(w, info.BuildInfo().String())
|
||||
}
|
||||
|
||||
func (builder *Builder) Handler(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -27,8 +27,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission"
|
||||
builder "github.com/fission/fission/builder"
|
||||
builder "github.com/fission/fission/pkg/builder"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -61,7 +61,7 @@ func (c *Client) Build(req *builder.PackageBuildRequest) (*builder.PackageBuildR
|
||||
if resp.StatusCode == 200 {
|
||||
break
|
||||
}
|
||||
err = fission.MakeErrorFromHTTP(resp)
|
||||
err = ferror.MakeErrorFromHTTP(resp)
|
||||
}
|
||||
|
||||
if i < maxRetries-1 {
|
||||
@@ -88,5 +88,5 @@ func (c *Client) Build(req *builder.PackageBuildRequest) (*builder.PackageBuildR
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pkgBuildResp, fission.MakeErrorFromHTTP(resp)
|
||||
return &pkgBuildResp, ferror.MakeErrorFromHTTP(resp)
|
||||
}
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
fetcherConfig "github.com/fission/fission/environments/fetcher/config"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
fetcherConfig "github.com/fission/fission/pkg/fetcher/config"
|
||||
)
|
||||
|
||||
// Start the buildermgr service.
|
||||
@@ -26,11 +26,13 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/builder"
|
||||
builderClient "github.com/fission/fission/builder/client"
|
||||
"github.com/fission/fission/crd"
|
||||
fetcherClient "github.com/fission/fission/environments/fetcher/client"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/builder"
|
||||
builderClient "github.com/fission/fission/pkg/builder/client"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
fetcherClient "github.com/fission/fission/pkg/fetcher/client"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
// buildPackage helps to build source package into deployment package.
|
||||
@@ -41,14 +43,14 @@ import (
|
||||
// 4. Return upload response and build logs.
|
||||
// *. Return build logs and error if any one of steps above failed.
|
||||
func buildPackage(ctx context.Context, logger *zap.Logger, fissionClient *crd.FissionClient, envBuilderNamespace string,
|
||||
storageSvcUrl string, pkg *crd.Package) (uploadResp *fission.ArchiveUploadResponse, buildLogs string, err error) {
|
||||
storageSvcUrl string, pkg *fv1.Package) (uploadResp *types.ArchiveUploadResponse, buildLogs string, err error) {
|
||||
|
||||
env, err := fissionClient.Environments(pkg.Spec.Environment.Namespace).Get(pkg.Spec.Environment.Name)
|
||||
if err != nil {
|
||||
e := "error getting environment CRD info"
|
||||
logger.Error(e, zap.Error(err))
|
||||
e = fmt.Sprintf("%s: %v", e, err)
|
||||
return nil, e, fission.MakeError(http.StatusInternalServerError, e)
|
||||
return nil, e, ferror.MakeError(http.StatusInternalServerError, e)
|
||||
}
|
||||
|
||||
svcName := fmt.Sprintf("%v-%v.%v", env.Metadata.Name, env.Metadata.ResourceVersion, envBuilderNamespace)
|
||||
@@ -56,8 +58,8 @@ func buildPackage(ctx context.Context, logger *zap.Logger, fissionClient *crd.Fi
|
||||
fetcherC := fetcherClient.MakeClient(logger, fmt.Sprintf("http://%v:8000", svcName))
|
||||
builderC := builderClient.MakeClient(logger, fmt.Sprintf("http://%v:8001", svcName))
|
||||
|
||||
fetchReq := &fission.FunctionFetchRequest{
|
||||
FetchType: fission.FETCH_SOURCE,
|
||||
fetchReq := &types.FunctionFetchRequest{
|
||||
FetchType: types.FETCH_SOURCE,
|
||||
Package: pkg.Metadata,
|
||||
Filename: srcPkgFilename,
|
||||
KeepArchive: false,
|
||||
@@ -69,7 +71,7 @@ func buildPackage(ctx context.Context, logger *zap.Logger, fissionClient *crd.Fi
|
||||
e := "error fetching source package"
|
||||
logger.Error(e, zap.Error(err))
|
||||
e = fmt.Sprintf("%s: %v", e, err)
|
||||
return nil, e, fission.MakeError(http.StatusInternalServerError, e)
|
||||
return nil, e, ferror.MakeError(http.StatusInternalServerError, e)
|
||||
}
|
||||
|
||||
buildCmd := pkg.Spec.BuildCommand
|
||||
@@ -92,14 +94,14 @@ func buildPackage(ctx context.Context, logger *zap.Logger, fissionClient *crd.Fi
|
||||
buildLogs = buildResp.BuildLogs
|
||||
}
|
||||
buildLogs += fmt.Sprintf("%v\n", e)
|
||||
return nil, buildLogs, fission.MakeError(http.StatusInternalServerError, e)
|
||||
return nil, buildLogs, ferror.MakeError(http.StatusInternalServerError, e)
|
||||
}
|
||||
|
||||
logger.Info("build succeed", zap.String("source_package", srcPkgFilename), zap.String("deployment_package", buildResp.ArtifactFilename))
|
||||
|
||||
archivePackage := !env.Spec.KeepArchive
|
||||
|
||||
uploadReq := &fission.ArchiveUploadRequest{
|
||||
uploadReq := &types.ArchiveUploadRequest{
|
||||
Filename: buildResp.ArtifactFilename,
|
||||
StorageSvcUrl: storageSvcUrl,
|
||||
ArchivePackage: archivePackage,
|
||||
@@ -111,24 +113,24 @@ func buildPackage(ctx context.Context, logger *zap.Logger, fissionClient *crd.Fi
|
||||
if err != nil {
|
||||
e := fmt.Sprintf("Error uploading deployment package: %v", err)
|
||||
buildResp.BuildLogs += fmt.Sprintf("%v\n", e)
|
||||
return nil, buildResp.BuildLogs, fission.MakeError(http.StatusInternalServerError, e)
|
||||
return nil, buildResp.BuildLogs, ferror.MakeError(http.StatusInternalServerError, e)
|
||||
}
|
||||
|
||||
return uploadResp, buildResp.BuildLogs, nil
|
||||
}
|
||||
|
||||
func updatePackage(logger *zap.Logger, fissionClient *crd.FissionClient,
|
||||
pkg *crd.Package, status fission.BuildStatus, buildLogs string,
|
||||
uploadResp *fission.ArchiveUploadResponse) (*crd.Package, error) {
|
||||
pkg *fv1.Package, status fv1.BuildStatus, buildLogs string,
|
||||
uploadResp *types.ArchiveUploadResponse) (*fv1.Package, error) {
|
||||
|
||||
pkg.Status = fission.PackageStatus{
|
||||
pkg.Status = fv1.PackageStatus{
|
||||
BuildStatus: status,
|
||||
BuildLog: buildLogs,
|
||||
}
|
||||
|
||||
if uploadResp != nil {
|
||||
pkg.Spec.Deployment = fission.Archive{
|
||||
Type: fission.ArchiveTypeUrl,
|
||||
pkg.Spec.Deployment = fv1.Archive{
|
||||
Type: types.ArchiveTypeUrl,
|
||||
URL: uploadResp.ArchiveDownloadUrl,
|
||||
Checksum: uploadResp.Checksum,
|
||||
}
|
||||
@@ -32,10 +32,12 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fetcherConfig "github.com/fission/fission/environments/fetcher/config"
|
||||
"github.com/fission/fission/executor/util"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/executor/util"
|
||||
fetcherConfig "github.com/fission/fission/pkg/fetcher/config"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
type requestType int
|
||||
@@ -65,8 +67,8 @@ type (
|
||||
|
||||
envwRequest struct {
|
||||
requestType
|
||||
env *crd.Environment
|
||||
envList []crd.Environment
|
||||
env *fv1.Environment
|
||||
envList []fv1.Environment
|
||||
respChan chan envwResponse
|
||||
}
|
||||
|
||||
@@ -106,7 +108,7 @@ func makeEnvironmentWatcher(
|
||||
useIstio = istio
|
||||
}
|
||||
|
||||
builderImagePullPolicy := fission.GetImagePullPolicy(os.Getenv("BUILDER_IMAGE_PULL_POLICY"))
|
||||
builderImagePullPolicy := utils.GetImagePullPolicy(os.Getenv("BUILDER_IMAGE_PULL_POLICY"))
|
||||
|
||||
envWatcher := &environmentWatcher{
|
||||
logger: logger.Named("environment_watcher"),
|
||||
@@ -151,7 +153,7 @@ func (envw *environmentWatcher) watchEnvironments() {
|
||||
ResourceVersion: rv,
|
||||
})
|
||||
if err != nil {
|
||||
if fission.IsNetworkError(err) {
|
||||
if utils.IsNetworkError(err) {
|
||||
envw.logger.Error("encountered network error, retrying later", zap.Error(err))
|
||||
time.Sleep(5 * time.Second)
|
||||
continue
|
||||
@@ -171,7 +173,7 @@ func (envw *environmentWatcher) watchEnvironments() {
|
||||
time.Sleep(time.Second)
|
||||
break
|
||||
}
|
||||
env := ev.Object.(*crd.Environment)
|
||||
env := ev.Object.(*fv1.Environment)
|
||||
rv = env.Metadata.ResourceVersion
|
||||
envw.sync()
|
||||
}
|
||||
@@ -183,7 +185,7 @@ func (envw *environmentWatcher) sync() {
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
envList, err := envw.fissionClient.Environments(metav1.NamespaceAll).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
if fission.IsNetworkError(err) {
|
||||
if utils.IsNetworkError(err) {
|
||||
envw.logger.Error("error syncing environment CRD resources due to network error, retrying later", zap.Error(err))
|
||||
time.Sleep(50 * time.Duration(2*i) * time.Millisecond)
|
||||
continue
|
||||
@@ -236,7 +238,7 @@ func (envw *environmentWatcher) service() {
|
||||
req.respChan <- envwResponse{builderInfo: builderInfo}
|
||||
|
||||
case CLEANUP_BUILDERS:
|
||||
latestEnvList := make(map[string]*crd.Environment)
|
||||
latestEnvList := make(map[string]*fv1.Environment)
|
||||
for i := range req.envList {
|
||||
env := req.envList[i]
|
||||
// In order to support backward compatibility, for all builder images created in default
|
||||
@@ -298,7 +300,7 @@ func (envw *environmentWatcher) service() {
|
||||
}
|
||||
}
|
||||
|
||||
func (envw *environmentWatcher) getEnvBuilder(env *crd.Environment) (*builderInfo, error) {
|
||||
func (envw *environmentWatcher) getEnvBuilder(env *fv1.Environment) (*builderInfo, error) {
|
||||
respChan := make(chan envwResponse)
|
||||
envw.requestChan <- envwRequest{
|
||||
requestType: GET_BUILDER,
|
||||
@@ -309,14 +311,14 @@ func (envw *environmentWatcher) getEnvBuilder(env *crd.Environment) (*builderInf
|
||||
return resp.builderInfo, resp.err
|
||||
}
|
||||
|
||||
func (envw *environmentWatcher) cleanupEnvBuilders(envs []crd.Environment) {
|
||||
func (envw *environmentWatcher) cleanupEnvBuilders(envs []fv1.Environment) {
|
||||
envw.requestChan <- envwRequest{
|
||||
requestType: CLEANUP_BUILDERS,
|
||||
envList: envs,
|
||||
}
|
||||
}
|
||||
|
||||
func (envw *environmentWatcher) createBuilder(env *crd.Environment, ns string) (*builderInfo, error) {
|
||||
func (envw *environmentWatcher) createBuilder(env *fv1.Environment, ns string) (*builderInfo, error) {
|
||||
var svc *apiv1.Service
|
||||
var deploy *v1beta1.Deployment
|
||||
|
||||
@@ -345,9 +347,9 @@ func (envw *environmentWatcher) createBuilder(env *crd.Environment, ns string) (
|
||||
// there should be only one deploy in deployList
|
||||
if len(deployList) == 0 {
|
||||
// create builder SA in this ns, if not already created
|
||||
_, err := fission.SetupSA(envw.kubernetesClient, fission.FissionBuilderSA, ns)
|
||||
_, err := utils.SetupSA(envw.kubernetesClient, types.FissionBuilderSA, ns)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error creating %q in ns: %s", fission.FissionBuilderSA, ns)
|
||||
return nil, errors.Wrapf(err, "error creating %q in ns: %s", types.FissionBuilderSA, ns)
|
||||
}
|
||||
|
||||
deploy, err = envw.createBuilderDeployment(env, ns)
|
||||
@@ -432,7 +434,7 @@ func (envw *environmentWatcher) getBuilderServiceList(sel map[string]string, ns
|
||||
return svcList.Items, nil
|
||||
}
|
||||
|
||||
func (envw *environmentWatcher) createBuilderService(env *crd.Environment, ns string) (*apiv1.Service, error) {
|
||||
func (envw *environmentWatcher) createBuilderService(env *fv1.Environment, ns string) (*apiv1.Service, error) {
|
||||
name := fmt.Sprintf("%v-%v", env.Metadata.Name, env.Metadata.ResourceVersion)
|
||||
sel := envw.getLabels(env.Metadata.Name, ns, env.Metadata.ResourceVersion)
|
||||
service := apiv1.Service{
|
||||
@@ -485,7 +487,7 @@ func (envw *environmentWatcher) getBuilderDeploymentList(sel map[string]string,
|
||||
return deployList.Items, nil
|
||||
}
|
||||
|
||||
func (envw *environmentWatcher) createBuilderDeployment(env *crd.Environment, ns string) (*v1beta1.Deployment, error) {
|
||||
func (envw *environmentWatcher) createBuilderDeployment(env *fv1.Environment, ns string) (*v1beta1.Deployment, error) {
|
||||
name := fmt.Sprintf("%v-%v", env.Metadata.Name, env.Metadata.ResourceVersion)
|
||||
sel := envw.getLabels(env.Metadata.Name, ns, env.Metadata.ResourceVersion)
|
||||
var replicas int32 = 1
|
||||
@@ -29,9 +29,11 @@ import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/cache"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/cache"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -73,10 +75,10 @@ func makePackageWatcher(logger *zap.Logger, fissionClient *crd.FissionClient, k8
|
||||
// 5. Update package resource in package ref of functions that share the same package
|
||||
// 6. Update package status to succeed state
|
||||
// *. Update package status to failed state,if any one of steps above failed/time out
|
||||
func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *crd.Package) {
|
||||
func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *fv1.Package) {
|
||||
|
||||
// Ignore non-pending state packages.
|
||||
if srcpkg.Status.BuildStatus != fission.BuildStatusPending {
|
||||
if srcpkg.Status.BuildStatus != fv1.BuildStatusPending {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,7 +92,7 @@ func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *crd.Package)
|
||||
|
||||
pkgw.logger.Info("starting build for package", zap.String("package_name", srcpkg.Metadata.Name), zap.String("resource_version", srcpkg.Metadata.ResourceVersion))
|
||||
|
||||
pkg, err := updatePackage(pkgw.logger, pkgw.fissionClient, srcpkg, fission.BuildStatusRunning, "", nil)
|
||||
pkg, err := updatePackage(pkgw.logger, pkgw.fissionClient, srcpkg, fv1.BuildStatusRunning, "", nil)
|
||||
if err != nil {
|
||||
pkgw.logger.Error("error setting package pending state", zap.Error(err))
|
||||
return
|
||||
@@ -101,7 +103,7 @@ func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *crd.Package)
|
||||
e := "environment does not exist"
|
||||
pkgw.logger.Error(e, zap.String("environment", pkg.Spec.Environment.Name))
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg,
|
||||
fission.BuildStatusFailed, fmt.Sprintf("%s: %q", e, pkg.Spec.Environment.Name), nil)
|
||||
fv1.BuildStatusFailed, fmt.Sprintf("%s: %q", e, pkg.Spec.Environment.Name), nil)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -155,17 +157,17 @@ func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *crd.Package)
|
||||
// Add the package getter rolebinding to builder sa
|
||||
// we continue here if role binding was not setup succeesffully. this is because without this, the fetcher wont be able to fetch the source pkg into the container and
|
||||
// the build will fail eventually
|
||||
err := fission.SetupRoleBinding(pkgw.logger, pkgw.k8sClient, fission.PackageGetterRB, pkg.Metadata.Namespace, fission.PackageGetterCR, fission.ClusterRole, fission.FissionBuilderSA, builderNs)
|
||||
err := utils.SetupRoleBinding(pkgw.logger, pkgw.k8sClient, types.PackageGetterRB, pkg.Metadata.Namespace, types.PackageGetterCR, types.ClusterRole, types.FissionBuilderSA, builderNs)
|
||||
if err != nil {
|
||||
pkgw.logger.Error("error setting up role binding for package",
|
||||
zap.Error(err),
|
||||
zap.String("role_binding", fission.PackageGetterRB),
|
||||
zap.String("role_binding", types.PackageGetterRB),
|
||||
zap.String("package_name", pkg.Metadata.Name),
|
||||
zap.String("package_namespace", pkg.Metadata.Namespace))
|
||||
continue
|
||||
} else {
|
||||
pkgw.logger.Info("setup rolebinding for sa package",
|
||||
zap.String("sa", fmt.Sprintf("%s.%s", fission.FissionBuilderSA, builderNs)),
|
||||
zap.String("sa", fmt.Sprintf("%s.%s", types.FissionBuilderSA, builderNs)),
|
||||
zap.String("package", fmt.Sprintf("%s.%s", pkg.Metadata.Name, pkg.Metadata.Namespace)))
|
||||
}
|
||||
|
||||
@@ -173,7 +175,7 @@ func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *crd.Package)
|
||||
uploadResp, buildLogs, err := buildPackage(ctx, pkgw.logger, pkgw.fissionClient, builderNs, pkgw.storageSvcUrl, pkg)
|
||||
if err != nil {
|
||||
pkgw.logger.Error("error building package", zap.Error(err), zap.String("package_name", pkg.Metadata.Name))
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg, fission.BuildStatusFailed, buildLogs, nil)
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg, types.BuildStatusFailed, buildLogs, nil)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -185,7 +187,7 @@ func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *crd.Package)
|
||||
e := "error getting function list"
|
||||
pkgw.logger.Error(e, zap.Error(err))
|
||||
buildLogs += fmt.Sprintf("%s: %v\n", e, err)
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg, fission.BuildStatusFailed, buildLogs, nil)
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg, fv1.BuildStatusFailed, buildLogs, nil)
|
||||
}
|
||||
|
||||
// A package may be used by multiple functions. Update
|
||||
@@ -201,17 +203,17 @@ func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *crd.Package)
|
||||
e := "error updating function package resource version"
|
||||
pkgw.logger.Error(e, zap.Error(err))
|
||||
buildLogs += fmt.Sprintf("%s: %v\n", e, err)
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg, fission.BuildStatusFailed, buildLogs, nil)
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg, fv1.BuildStatusFailed, buildLogs, nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_, err = updatePackage(pkgw.logger, pkgw.fissionClient, pkg,
|
||||
fission.BuildStatusSucceeded, buildLogs, uploadResp)
|
||||
types.BuildStatusSucceeded, buildLogs, uploadResp)
|
||||
if err != nil {
|
||||
pkgw.logger.Error("error updating package info", zap.Error(err), zap.String("package_name", pkg.Metadata.Name))
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg, fission.BuildStatusFailed, buildLogs, nil)
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg, types.BuildStatusFailed, buildLogs, nil)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -221,7 +223,7 @@ func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *crd.Package)
|
||||
}
|
||||
// build timeout
|
||||
updatePackage(pkgw.logger, pkgw.fissionClient, pkg,
|
||||
fission.BuildStatusFailed, "Build timeout due to environment builder not ready", nil)
|
||||
types.BuildStatusFailed, "Build timeout due to environment builder not ready", nil)
|
||||
|
||||
pkgw.logger.Error("max retries exceeded in building source package, timeout due to environment builder not ready",
|
||||
zap.String("package", fmt.Sprintf("%s.%s", pkg.Metadata.Name, pkg.Metadata.Namespace)))
|
||||
@@ -233,13 +235,13 @@ func (pkgw *packageWatcher) watchPackages(fissionClient *crd.FissionClient,
|
||||
kubernetesClient *kubernetes.Clientset, builderNamespace string) {
|
||||
buildCache := cache.MakeCache(0, 0)
|
||||
lw := k8sCache.NewListWatchFromClient(pkgw.fissionClient.GetCrdClient(), "packages", apiv1.NamespaceAll, fields.Everything())
|
||||
pkgStore, controller := k8sCache.NewInformer(lw, &crd.Package{}, 60*time.Second, k8sCache.ResourceEventHandlerFuncs{
|
||||
pkgStore, controller := k8sCache.NewInformer(lw, &fv1.Package{}, 60*time.Second, k8sCache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
pkg := obj.(*crd.Package)
|
||||
pkg := obj.(*fv1.Package)
|
||||
go pkgw.build(buildCache, pkg)
|
||||
},
|
||||
UpdateFunc: func(oldObj, newObj interface{}) {
|
||||
pkg := newObj.(*crd.Package)
|
||||
pkg := newObj.(*fv1.Package)
|
||||
go pkgw.build(buildCache, pkg)
|
||||
},
|
||||
})
|
||||
Vendored
+5
-5
@@ -20,7 +20,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/fission/fission"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
type requestType int
|
||||
@@ -94,10 +94,10 @@ func (c *Cache) service() {
|
||||
case GET:
|
||||
val, ok := c.cache[req.key]
|
||||
if !ok {
|
||||
resp.error = fission.MakeError(fission.ErrorNotFound,
|
||||
resp.error = ferror.MakeError(ferror.ErrorNotFound,
|
||||
fmt.Sprintf("key '%v' not found", req.key))
|
||||
} else if c.IsOld(val) {
|
||||
resp.error = fission.MakeError(fission.ErrorNotFound,
|
||||
resp.error = ferror.MakeError(ferror.ErrorNotFound,
|
||||
fmt.Sprintf("key '%v' expired (atime %v)", req.key, val.atime))
|
||||
delete(c.cache, req.key)
|
||||
} else {
|
||||
@@ -113,7 +113,7 @@ func (c *Cache) service() {
|
||||
val := c.cache[req.key]
|
||||
val.atime = time.Now()
|
||||
resp.existingValue = val.value
|
||||
resp.error = fission.MakeError(fission.ErrorNameExists, "key already exists")
|
||||
resp.error = ferror.MakeError(ferror.ErrorNameExists, "key already exists")
|
||||
} else {
|
||||
c.cache[req.key] = &Value{
|
||||
value: req.value,
|
||||
@@ -139,7 +139,7 @@ func (c *Cache) service() {
|
||||
}
|
||||
req.responseChannel <- resp
|
||||
default:
|
||||
resp.error = fission.MakeError(fission.ErrorInvalidArgument,
|
||||
resp.error = ferror.MakeError(ferror.ErrorInvalidArgument,
|
||||
fmt.Sprintf("invalid request type: %v", req.requestType))
|
||||
req.responseChannel <- resp
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/cache"
|
||||
"github.com/fission/fission/pkg/cache"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -33,8 +33,13 @@ import (
|
||||
"k8s.io/client-go/rest"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
const (
|
||||
maxRetries = 10
|
||||
)
|
||||
|
||||
type canaryConfigMgr struct {
|
||||
@@ -99,23 +104,23 @@ func MakeCanaryConfigMgr(logger *zap.Logger, fissionClient *crd.FissionClient, k
|
||||
func (canaryCfgMgr *canaryConfigMgr) initCanaryConfigController() (k8sCache.Store, k8sCache.Controller) {
|
||||
resyncPeriod := 30 * time.Second
|
||||
listWatch := k8sCache.NewListWatchFromClient(canaryCfgMgr.crdClient, "canaryconfigs", metav1.NamespaceAll, fields.Everything())
|
||||
store, controller := k8sCache.NewInformer(listWatch, &crd.CanaryConfig{}, resyncPeriod,
|
||||
store, controller := k8sCache.NewInformer(listWatch, &fv1.CanaryConfig{}, resyncPeriod,
|
||||
k8sCache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
canaryConfig := obj.(*crd.CanaryConfig)
|
||||
if canaryConfig.Status.Status == fission.CanaryConfigStatusPending {
|
||||
canaryConfig := obj.(*fv1.CanaryConfig)
|
||||
if canaryConfig.Status.Status == types.CanaryConfigStatusPending {
|
||||
go canaryCfgMgr.addCanaryConfig(canaryConfig)
|
||||
}
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
canaryConfig := obj.(*crd.CanaryConfig)
|
||||
canaryConfig := obj.(*fv1.CanaryConfig)
|
||||
go canaryCfgMgr.deleteCanaryConfig(canaryConfig)
|
||||
},
|
||||
UpdateFunc: func(oldObj interface{}, newObj interface{}) {
|
||||
oldConfig := oldObj.(*crd.CanaryConfig)
|
||||
newConfig := newObj.(*crd.CanaryConfig)
|
||||
oldConfig := oldObj.(*fv1.CanaryConfig)
|
||||
newConfig := newObj.(*fv1.CanaryConfig)
|
||||
if oldConfig.Metadata.ResourceVersion != newConfig.Metadata.ResourceVersion &&
|
||||
newConfig.Status.Status == fission.CanaryConfigStatusPending {
|
||||
newConfig.Status.Status == types.CanaryConfigStatusPending {
|
||||
canaryCfgMgr.logger.Info("update canary config invoked",
|
||||
zap.String("name", newConfig.Metadata.Name),
|
||||
zap.String("namespace", newConfig.Metadata.Namespace),
|
||||
@@ -135,7 +140,7 @@ func (canaryCfgMgr *canaryConfigMgr) Run(ctx context.Context) {
|
||||
canaryCfgMgr.logger.Info("started canary configmgr controller")
|
||||
}
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) addCanaryConfig(canaryConfig *crd.CanaryConfig) {
|
||||
func (canaryCfgMgr *canaryConfigMgr) addCanaryConfig(canaryConfig *fv1.CanaryConfig) {
|
||||
canaryCfgMgr.logger.Info("addCanaryConfig called", zap.String("canary_config", canaryConfig.Metadata.Name))
|
||||
|
||||
// for each canary config, create a ticker with increment interval
|
||||
@@ -171,7 +176,7 @@ func (canaryCfgMgr *canaryConfigMgr) addCanaryConfig(canaryConfig *crd.CanaryCon
|
||||
canaryCfgMgr.processCanaryConfig(&ctx, canaryConfig, ticker)
|
||||
}
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) processCanaryConfig(ctx *context.Context, canaryConfig *crd.CanaryConfig, ticker *time.Ticker) {
|
||||
func (canaryCfgMgr *canaryConfigMgr) processCanaryConfig(ctx *context.Context, canaryConfig *fv1.CanaryConfig, ticker *time.Ticker) {
|
||||
quit := make(chan struct{})
|
||||
|
||||
for {
|
||||
@@ -222,7 +227,7 @@ func (canaryCfgMgr *canaryConfigMgr) processCanaryConfig(ctx *context.Context, c
|
||||
}
|
||||
}
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) RollForwardOrBack(canaryConfig *crd.CanaryConfig, quit chan struct{}, ticker *time.Ticker) {
|
||||
func (canaryCfgMgr *canaryConfigMgr) RollForwardOrBack(canaryConfig *fv1.CanaryConfig, quit chan struct{}, ticker *time.Ticker) {
|
||||
// handle race between delete event and notification on ticker.C
|
||||
_, err := canaryCfgMgr.canaryCfgCancelFuncMap.lookup(&canaryConfig.Metadata)
|
||||
if err != nil {
|
||||
@@ -258,7 +263,7 @@ func (canaryCfgMgr *canaryConfigMgr) RollForwardOrBack(canaryConfig *crd.CanaryC
|
||||
}
|
||||
|
||||
// handle a race between ticker.Stop and receiving a notification on ticker.C
|
||||
if canaryConfig.Status.Status != fission.CanaryConfigStatusPending {
|
||||
if canaryConfig.Status.Status != types.CanaryConfigStatusPending {
|
||||
canaryCfgMgr.logger.Info("no need of processing the config, not pending anymore",
|
||||
zap.String("name", canaryConfig.Metadata.Name),
|
||||
zap.String("namespace", canaryConfig.Metadata.Namespace),
|
||||
@@ -266,7 +271,7 @@ func (canaryCfgMgr *canaryConfigMgr) RollForwardOrBack(canaryConfig *crd.CanaryC
|
||||
return
|
||||
}
|
||||
|
||||
if triggerObj.Spec.FunctionReference.Type == fission.FunctionReferenceTypeFunctionWeights &&
|
||||
if triggerObj.Spec.FunctionReference.Type == types.FunctionReferenceTypeFunctionWeights &&
|
||||
triggerObj.Spec.FunctionReference.FunctionWeights[canaryConfig.Spec.NewFunction] != 0 {
|
||||
failurePercent, err := canaryCfgMgr.promClient.GetFunctionFailurePercentage(triggerObj.Spec.RelativeURL, triggerObj.Spec.Method,
|
||||
canaryConfig.Spec.NewFunction, canaryConfig.Metadata.Namespace, canaryConfig.Spec.WeightIncrementDuration)
|
||||
@@ -331,7 +336,7 @@ func (canaryCfgMgr *canaryConfigMgr) RollForwardOrBack(canaryConfig *crd.CanaryC
|
||||
// update the status of canary config as done processing, we dont care if we arent able to update because
|
||||
// resync takes care of the update
|
||||
err = canaryCfgMgr.updateCanaryConfigStatusWithRetries(canaryConfig.Metadata.Name, canaryConfig.Metadata.Namespace,
|
||||
fission.CanaryConfigStatusSucceeded)
|
||||
types.CanaryConfigStatusSucceeded)
|
||||
if err != nil {
|
||||
// cant do much after max retries other than logging it.
|
||||
canaryCfgMgr.logger.Error("error updating canary config after max retries",
|
||||
@@ -351,7 +356,7 @@ func (canaryCfgMgr *canaryConfigMgr) RollForwardOrBack(canaryConfig *crd.CanaryC
|
||||
}
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) updateHttpTriggerWithRetries(triggerName, triggerNamespace string, fnWeights map[string]int) (err error) {
|
||||
for i := 0; i < fission.MaxRetries; i++ {
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
triggerObj, err := canaryCfgMgr.fissionClient.HTTPTriggers(triggerNamespace).Get(triggerName)
|
||||
if err != nil {
|
||||
e := "error getting http trigger object"
|
||||
@@ -386,7 +391,7 @@ func (canaryCfgMgr *canaryConfigMgr) updateHttpTriggerWithRetries(triggerName, t
|
||||
}
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) updateCanaryConfigStatusWithRetries(cfgName, cfgNamespace string, status string) (err error) {
|
||||
for i := 0; i < fission.MaxRetries; i++ {
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
canaryCfgObj, err := canaryCfgMgr.fissionClient.CanaryConfigs(cfgNamespace).Get(cfgName)
|
||||
if err != nil {
|
||||
e := "error getting http canary config object"
|
||||
@@ -431,7 +436,7 @@ func (canaryCfgMgr *canaryConfigMgr) updateCanaryConfigStatusWithRetries(cfgName
|
||||
return err
|
||||
}
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) rollback(canaryConfig *crd.CanaryConfig, trigger *crd.HTTPTrigger) error {
|
||||
func (canaryCfgMgr *canaryConfigMgr) rollback(canaryConfig *fv1.CanaryConfig, trigger *fv1.HTTPTrigger) error {
|
||||
functionWeights := trigger.Spec.FunctionReference.FunctionWeights
|
||||
functionWeights[canaryConfig.Spec.NewFunction] = 0
|
||||
functionWeights[canaryConfig.Spec.OldFunction] = 100
|
||||
@@ -439,12 +444,12 @@ func (canaryCfgMgr *canaryConfigMgr) rollback(canaryConfig *crd.CanaryConfig, tr
|
||||
err := canaryCfgMgr.updateHttpTriggerWithRetries(trigger.Metadata.Name, trigger.Metadata.Namespace, functionWeights)
|
||||
|
||||
err = canaryCfgMgr.updateCanaryConfigStatusWithRetries(canaryConfig.Metadata.Name, canaryConfig.Metadata.Namespace,
|
||||
fission.CanaryConfigStatusFailed)
|
||||
types.CanaryConfigStatusFailed)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) rollForward(canaryConfig *crd.CanaryConfig, trigger *crd.HTTPTrigger) (bool, error) {
|
||||
func (canaryCfgMgr *canaryConfigMgr) rollForward(canaryConfig *fv1.CanaryConfig, trigger *fv1.HTTPTrigger) (bool, error) {
|
||||
doneProcessingCanaryConfig := false
|
||||
|
||||
functionWeights := trigger.Spec.FunctionReference.FunctionWeights
|
||||
@@ -469,9 +474,9 @@ func (canaryCfgMgr *canaryConfigMgr) rollForward(canaryConfig *crd.CanaryConfig,
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) reSyncCanaryConfigs() {
|
||||
for _, obj := range canaryCfgMgr.canaryConfigStore.List() {
|
||||
canaryConfig := obj.(*crd.CanaryConfig)
|
||||
canaryConfig := obj.(*fv1.CanaryConfig)
|
||||
_, err := canaryCfgMgr.canaryCfgCancelFuncMap.lookup(&canaryConfig.Metadata)
|
||||
if err != nil && canaryConfig.Status.Status == fission.CanaryConfigStatusPending {
|
||||
if err != nil && canaryConfig.Status.Status == types.CanaryConfigStatusPending {
|
||||
canaryCfgMgr.logger.Info("adding canary config from resync loop",
|
||||
zap.String("name", canaryConfig.Metadata.Name),
|
||||
zap.String("namespace", canaryConfig.Metadata.Namespace),
|
||||
@@ -483,7 +488,7 @@ func (canaryCfgMgr *canaryConfigMgr) reSyncCanaryConfigs() {
|
||||
}
|
||||
}
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) deleteCanaryConfig(canaryConfig *crd.CanaryConfig) {
|
||||
func (canaryCfgMgr *canaryConfigMgr) deleteCanaryConfig(canaryConfig *fv1.CanaryConfig) {
|
||||
canaryCfgMgr.logger.Info("delete event received for canary config",
|
||||
zap.String("name", canaryConfig.Metadata.Name),
|
||||
zap.String("namespace", canaryConfig.Metadata.Namespace),
|
||||
@@ -503,7 +508,7 @@ func (canaryCfgMgr *canaryConfigMgr) deleteCanaryConfig(canaryConfig *crd.Canary
|
||||
(*canaryProcessingInfo.CancelFunc)()
|
||||
}
|
||||
|
||||
func (canaryCfgMgr *canaryConfigMgr) updateCanaryConfig(oldCanaryConfig *crd.CanaryConfig, newCanaryConfig *crd.CanaryConfig) {
|
||||
func (canaryCfgMgr *canaryConfigMgr) updateCanaryConfig(oldCanaryConfig *fv1.CanaryConfig, newCanaryConfig *fv1.CanaryConfig) {
|
||||
// before removing the object from cache, we need to get it's cancel func and cancel it
|
||||
canaryCfgMgr.deleteCanaryConfig(oldCanaryConfig)
|
||||
|
||||
@@ -30,9 +30,11 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/fission/logdb"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
"github.com/fission/fission/pkg/fission-cli/logdb"
|
||||
"github.com/fission/fission/pkg/info"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
var podNamespace string
|
||||
@@ -119,7 +121,7 @@ func (api *API) respondWithError(w http.ResponseWriter, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
code, msg := fission.GetHTTPError(err)
|
||||
code, msg := ferror.GetHTTPError(err)
|
||||
api.logger.Error(msg, zap.Int("code", code))
|
||||
http.Error(w, msg, code)
|
||||
}
|
||||
@@ -168,11 +170,11 @@ func (api *API) getLogDBConfig(dbType string) logDBConfig {
|
||||
|
||||
func (api *API) HomeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
fmt.Fprintf(w, fission.ApiInfo().String())
|
||||
fmt.Fprintf(w, info.ApiInfo().String())
|
||||
}
|
||||
|
||||
func (api *API) ApiVersionMismatchHandler(w http.ResponseWriter, r *http.Request) {
|
||||
err := fission.MakeError(fission.ErrorNotFound, "Fission server supports API v2 only -- v1 is not supported. Please upgrade your Fission client/CLI.")
|
||||
err := ferror.MakeError(ferror.ErrorNotFound, "Fission server supports API v2 only -- v1 is not supported. Please upgrade your Fission client/CLI.")
|
||||
api.respondWithError(w, err)
|
||||
}
|
||||
|
||||
@@ -272,7 +274,7 @@ func (api *API) Serve(port int) {
|
||||
address := fmt.Sprintf(":%v", port)
|
||||
|
||||
api.logger.Info("server started", zap.Int("port", port))
|
||||
r.Use(fission.LoggingMiddleware(api.logger))
|
||||
r.Use(utils.LoggingMiddleware(api.logger))
|
||||
err := http.ListenAndServe(address, r)
|
||||
api.logger.Fatal("done listening", zap.Error(err))
|
||||
}
|
||||
@@ -32,9 +32,9 @@ import (
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/controller/client"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
var g struct {
|
||||
@@ -55,16 +55,16 @@ func assert(c bool, msg string) {
|
||||
|
||||
func assertNameReuseFailure(err error, name string) {
|
||||
assert(err != nil, "recreating "+name+" with same name must fail")
|
||||
fe, ok := err.(fission.Error)
|
||||
fe, ok := err.(ferror.Error)
|
||||
assert(ok, "error must be a fission Error")
|
||||
assert(fe.Code == fission.ErrorNameExists, "error must be a name exists error")
|
||||
assert(fe.Code == ferror.ErrorNameExists, "error must be a name exists error")
|
||||
}
|
||||
|
||||
func assertNotFoundFailure(err error, name string) {
|
||||
assert(err != nil, "requesting a non-existent "+name+" must fail")
|
||||
fe, ok := err.(fission.Error)
|
||||
fe, ok := err.(ferror.Error)
|
||||
assert(ok, "error must be a fission Error")
|
||||
if fe.Code != fission.ErrorNotFound {
|
||||
if fe.Code != ferror.ErrorNotFound {
|
||||
log.Fatalf("error must be a not found error: %v", fe)
|
||||
}
|
||||
}
|
||||
@@ -76,19 +76,19 @@ func assertCronSpecFails(err error) {
|
||||
}
|
||||
|
||||
func TestFunctionApi(t *testing.T) {
|
||||
testFunc := &crd.Function{
|
||||
testFunc := &fv1.Function{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.FunctionSpec{
|
||||
Environment: fission.EnvironmentReference{
|
||||
Spec: fv1.FunctionSpec{
|
||||
Environment: fv1.EnvironmentReference{
|
||||
Name: "nodejs",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Package: fission.FunctionPackageRef{
|
||||
Package: fv1.FunctionPackageRef{
|
||||
FunctionName: "xxx",
|
||||
PackageRef: fission.PackageRef{
|
||||
PackageRef: fv1.PackageRef{
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
Name: "xxx",
|
||||
ResourceVersion: "12345",
|
||||
@@ -143,16 +143,16 @@ func TestFunctionApi(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHTTPTriggerApi(t *testing.T) {
|
||||
testTrigger := &crd.HTTPTrigger{
|
||||
testTrigger := &fv1.HTTPTrigger{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.HTTPTriggerSpec{
|
||||
Spec: fv1.HTTPTriggerSpec{
|
||||
Method: http.MethodGet,
|
||||
RelativeURL: "/hello",
|
||||
FunctionReference: fission.FunctionReference{
|
||||
Type: fission.FunctionReferenceTypeFunctionName,
|
||||
FunctionReference: fv1.FunctionReference{
|
||||
Type: fv1.FunctionReferenceTypeFunctionName,
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
@@ -199,13 +199,13 @@ func TestHTTPTriggerApi(t *testing.T) {
|
||||
|
||||
func TestEnvironmentApi(t *testing.T) {
|
||||
|
||||
testEnv := &crd.Environment{
|
||||
testEnv := &fv1.Environment{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.EnvironmentSpec{
|
||||
Runtime: fission.Runtime{
|
||||
Spec: fv1.EnvironmentSpec{
|
||||
Runtime: fv1.Runtime{
|
||||
Image: "gcr.io/xyz",
|
||||
},
|
||||
Resources: v1.ResourceRequirements{},
|
||||
@@ -245,16 +245,16 @@ func TestEnvironmentApi(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWatchApi(t *testing.T) {
|
||||
testWatch := &crd.KubernetesWatchTrigger{
|
||||
testWatch := &fv1.KubernetesWatchTrigger{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "xxx",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.KubernetesWatchTriggerSpec{
|
||||
Spec: fv1.KubernetesWatchTriggerSpec{
|
||||
Namespace: "default",
|
||||
Type: "pod",
|
||||
FunctionReference: fission.FunctionReference{
|
||||
Type: fission.FunctionReferenceTypeFunctionName,
|
||||
FunctionReference: fv1.FunctionReference{
|
||||
Type: fv1.FunctionReferenceTypeFunctionName,
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
@@ -290,15 +290,15 @@ func TestWatchApi(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTimeTriggerApi(t *testing.T) {
|
||||
testTrigger := &crd.TimeTrigger{
|
||||
testTrigger := &fv1.TimeTrigger{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "xxx",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.TimeTriggerSpec{
|
||||
Spec: fv1.TimeTriggerSpec{
|
||||
Cron: "0 30 * * * *",
|
||||
FunctionReference: fission.FunctionReference{
|
||||
Type: fission.FunctionReferenceTypeFunctionName,
|
||||
FunctionReference: fv1.FunctionReference{
|
||||
Type: fv1.FunctionReferenceTypeFunctionName,
|
||||
Name: "asdf",
|
||||
},
|
||||
},
|
||||
@@ -26,15 +26,15 @@ import (
|
||||
"go.uber.org/zap"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
config "github.com/fission/fission/featureconfig"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
config "github.com/fission/fission/pkg/featureconfig"
|
||||
)
|
||||
|
||||
func (a *API) CanaryConfigApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
featureErr := a.featureStatus[config.CanaryFeature]
|
||||
if len(featureErr) > 0 {
|
||||
a.respondWithError(w, fission.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
a.respondWithError(w, ferror.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func (a *API) CanaryConfigApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var canaryCfg crd.CanaryConfig
|
||||
var canaryCfg fv1.CanaryConfig
|
||||
err = json.Unmarshal(body, &canaryCfg)
|
||||
if err != nil {
|
||||
a.logger.Error("failed to unmarshal request body", zap.Error(err), zap.Binary("body", body))
|
||||
@@ -71,7 +71,7 @@ func (a *API) CanaryConfigApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *API) CanaryConfigApiGet(w http.ResponseWriter, r *http.Request) {
|
||||
featureErr := a.featureStatus[config.CanaryFeature]
|
||||
if len(featureErr) > 0 {
|
||||
a.respondWithError(w, fission.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
a.respondWithError(w, ferror.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func (a *API) CanaryConfigApiGet(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *API) CanaryConfigApiList(w http.ResponseWriter, r *http.Request) {
|
||||
featureErr := a.featureStatus[config.CanaryFeature]
|
||||
if len(featureErr) > 0 {
|
||||
a.respondWithError(w, fission.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
a.respondWithError(w, ferror.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ func (a *API) CanaryConfigApiList(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *API) CanaryConfigApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
featureErr := a.featureStatus[config.CanaryFeature]
|
||||
if len(featureErr) > 0 {
|
||||
a.respondWithError(w, fission.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
a.respondWithError(w, ferror.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func (a *API) CanaryConfigApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var c crd.CanaryConfig
|
||||
var c fv1.CanaryConfig
|
||||
err = json.Unmarshal(body, &c)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -163,7 +163,7 @@ func (a *API) CanaryConfigApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *API) CanaryConfigApiDelete(w http.ResponseWriter, r *http.Request) {
|
||||
featureErr := a.featureStatus[config.CanaryFeature]
|
||||
if len(featureErr) > 0 {
|
||||
a.respondWithError(w, fission.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
a.respondWithError(w, ferror.MakeError(http.StatusInternalServerError, fmt.Sprintf("Error enabling canary feature: %v", featureErr)))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
func (c *Client) CanaryConfigCreate(canaryConf *crd.CanaryConfig) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) CanaryConfigCreate(canaryConf *fv1.CanaryConfig) (*metav1.ObjectMeta, error) {
|
||||
reqbody, err := json.Marshal(canaryConf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -53,7 +53,7 @@ func (c *Client) CanaryConfigCreate(canaryConf *crd.CanaryConfig) (*metav1.Objec
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func (c *Client) CanaryConfigGet(m *metav1.ObjectMeta) (*crd.CanaryConfig, error) {
|
||||
func (c *Client) CanaryConfigGet(m *metav1.ObjectMeta) (*fv1.CanaryConfig, error) {
|
||||
relativeUrl := fmt.Sprintf("canaryconfigs/%v", m.Name)
|
||||
relativeUrl += fmt.Sprintf("?namespace=%v", m.Namespace)
|
||||
|
||||
@@ -68,7 +68,7 @@ func (c *Client) CanaryConfigGet(m *metav1.ObjectMeta) (*crd.CanaryConfig, error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var canaryCfg crd.CanaryConfig
|
||||
var canaryCfg fv1.CanaryConfig
|
||||
err = json.Unmarshal(body, &canaryCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -77,7 +77,7 @@ func (c *Client) CanaryConfigGet(m *metav1.ObjectMeta) (*crd.CanaryConfig, error
|
||||
return &canaryCfg, nil
|
||||
}
|
||||
|
||||
func (c *Client) CanaryConfigUpdate(canaryConf *crd.CanaryConfig) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) CanaryConfigUpdate(canaryConf *fv1.CanaryConfig) (*metav1.ObjectMeta, error) {
|
||||
reqbody, err := json.Marshal(canaryConf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -110,7 +110,7 @@ func (c *Client) CanaryConfigDelete(m *metav1.ObjectMeta) error {
|
||||
return c.delete(relativeUrl)
|
||||
}
|
||||
|
||||
func (c *Client) CanaryConfigList(ns string) ([]crd.CanaryConfig, error) {
|
||||
func (c *Client) CanaryConfigList(ns string) ([]fv1.CanaryConfig, error) {
|
||||
relativeUrl := fmt.Sprintf("canaryconfigs?namespace=%v", ns)
|
||||
resp, err := http.Get(c.url(relativeUrl))
|
||||
if err != nil {
|
||||
@@ -123,7 +123,7 @@ func (c *Client) CanaryConfigList(ns string) ([]crd.CanaryConfig, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
canaryCfgs := make([]crd.CanaryConfig, 0)
|
||||
canaryCfgs := make([]fv1.CanaryConfig, 0)
|
||||
err = json.Unmarshal(body, &canaryCfgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -25,7 +25,8 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/fission/fission"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
"github.com/fission/fission/pkg/info"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -77,7 +78,7 @@ func (c *Client) url(relativeUrl string) string {
|
||||
|
||||
func (c *Client) handleResponse(resp *http.Response) ([]byte, error) {
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, fission.MakeErrorFromHTTP(resp)
|
||||
return nil, ferror.MakeErrorFromHTTP(resp)
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
return body, err
|
||||
@@ -85,13 +86,13 @@ func (c *Client) handleResponse(resp *http.Response) ([]byte, error) {
|
||||
|
||||
func (c *Client) handleCreateResponse(resp *http.Response) ([]byte, error) {
|
||||
if resp.StatusCode != 201 {
|
||||
return nil, fission.MakeErrorFromHTTP(resp)
|
||||
return nil, ferror.MakeErrorFromHTTP(resp)
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
return body, err
|
||||
}
|
||||
|
||||
func (c *Client) ServerInfo() (*fission.ServerInfo, error) {
|
||||
func (c *Client) ServerInfo() (*info.ServerInfo, error) {
|
||||
url := fmt.Sprintf(c.Url)
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
@@ -104,7 +105,7 @@ func (c *Client) ServerInfo() (*fission.ServerInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := &fission.ServerInfo{}
|
||||
info := &info.ServerInfo{}
|
||||
err = json.Unmarshal(body, info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -24,11 +24,10 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
func (c *Client) EnvironmentCreate(env *crd.Environment) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) EnvironmentCreate(env *fv1.Environment) (*metav1.ObjectMeta, error) {
|
||||
err := env.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("Environment", err)
|
||||
@@ -59,7 +58,7 @@ func (c *Client) EnvironmentCreate(env *crd.Environment) (*metav1.ObjectMeta, er
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func (c *Client) EnvironmentGet(m *metav1.ObjectMeta) (*crd.Environment, error) {
|
||||
func (c *Client) EnvironmentGet(m *metav1.ObjectMeta) (*fv1.Environment, error) {
|
||||
relativeUrl := fmt.Sprintf("environments/%v", m.Name)
|
||||
relativeUrl += fmt.Sprintf("?namespace=%v", m.Namespace)
|
||||
|
||||
@@ -74,7 +73,7 @@ func (c *Client) EnvironmentGet(m *metav1.ObjectMeta) (*crd.Environment, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var env crd.Environment
|
||||
var env fv1.Environment
|
||||
err = json.Unmarshal(body, &env)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -83,7 +82,7 @@ func (c *Client) EnvironmentGet(m *metav1.ObjectMeta) (*crd.Environment, error)
|
||||
return &env, nil
|
||||
}
|
||||
|
||||
func (c *Client) EnvironmentUpdate(env *crd.Environment) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) EnvironmentUpdate(env *fv1.Environment) (*metav1.ObjectMeta, error) {
|
||||
err := env.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("Environment", err)
|
||||
@@ -121,7 +120,7 @@ func (c *Client) EnvironmentDelete(m *metav1.ObjectMeta) error {
|
||||
return c.delete(relativeUrl)
|
||||
}
|
||||
|
||||
func (c *Client) EnvironmentList(ns string) ([]crd.Environment, error) {
|
||||
func (c *Client) EnvironmentList(ns string) ([]fv1.Environment, error) {
|
||||
relativeUrl := fmt.Sprintf("environments?namespace=%v", ns)
|
||||
resp, err := http.Get(c.url(relativeUrl))
|
||||
if err != nil {
|
||||
@@ -134,7 +133,7 @@ func (c *Client) EnvironmentList(ns string) ([]crd.Environment, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
envs := make([]crd.Environment, 0)
|
||||
envs := make([]fv1.Environment, 0)
|
||||
err = json.Unmarshal(body, &envs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -24,11 +24,10 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
func (c *Client) FunctionCreate(f *crd.Function) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) FunctionCreate(f *fv1.Function) (*metav1.ObjectMeta, error) {
|
||||
err := f.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("Function", err)
|
||||
@@ -59,7 +58,7 @@ func (c *Client) FunctionCreate(f *crd.Function) (*metav1.ObjectMeta, error) {
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func (c *Client) FunctionGet(m *metav1.ObjectMeta) (*crd.Function, error) {
|
||||
func (c *Client) FunctionGet(m *metav1.ObjectMeta) (*fv1.Function, error) {
|
||||
relativeUrl := fmt.Sprintf("functions/%v", m.Name)
|
||||
relativeUrl += fmt.Sprintf("?namespace=%v", m.Namespace)
|
||||
|
||||
@@ -74,7 +73,7 @@ func (c *Client) FunctionGet(m *metav1.ObjectMeta) (*crd.Function, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var f crd.Function
|
||||
var f fv1.Function
|
||||
err = json.Unmarshal(body, &f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -97,7 +96,7 @@ func (c *Client) FunctionGetRawDeployment(m *metav1.ObjectMeta) ([]byte, error)
|
||||
return c.handleResponse(resp)
|
||||
}
|
||||
|
||||
func (c *Client) FunctionUpdate(f *crd.Function) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) FunctionUpdate(f *fv1.Function) (*metav1.ObjectMeta, error) {
|
||||
err := f.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("Function", err)
|
||||
@@ -134,7 +133,7 @@ func (c *Client) FunctionDelete(m *metav1.ObjectMeta) error {
|
||||
return c.delete(relativeUrl)
|
||||
}
|
||||
|
||||
func (c *Client) FunctionList(functionNamespace string) ([]crd.Function, error) {
|
||||
func (c *Client) FunctionList(functionNamespace string) ([]fv1.Function, error) {
|
||||
relativeUrl := fmt.Sprintf("functions?namespace=%v", functionNamespace)
|
||||
resp, err := http.Get(c.url(relativeUrl))
|
||||
if err != nil {
|
||||
@@ -147,7 +146,7 @@ func (c *Client) FunctionList(functionNamespace string) ([]crd.Function, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
funcs := make([]crd.Function, 0)
|
||||
funcs := make([]fv1.Function, 0)
|
||||
err = json.Unmarshal(body, &funcs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -24,11 +24,10 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
func (c *Client) HTTPTriggerCreate(t *crd.HTTPTrigger) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) HTTPTriggerCreate(t *fv1.HTTPTrigger) (*metav1.ObjectMeta, error) {
|
||||
err := t.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("HTTPTrigger", err)
|
||||
@@ -59,7 +58,7 @@ func (c *Client) HTTPTriggerCreate(t *crd.HTTPTrigger) (*metav1.ObjectMeta, erro
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func (c *Client) HTTPTriggerGet(m *metav1.ObjectMeta) (*crd.HTTPTrigger, error) {
|
||||
func (c *Client) HTTPTriggerGet(m *metav1.ObjectMeta) (*fv1.HTTPTrigger, error) {
|
||||
relativeUrl := fmt.Sprintf("triggers/http/%v", m.Name)
|
||||
relativeUrl += fmt.Sprintf("?namespace=%v", m.Namespace)
|
||||
|
||||
@@ -74,7 +73,7 @@ func (c *Client) HTTPTriggerGet(m *metav1.ObjectMeta) (*crd.HTTPTrigger, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var t crd.HTTPTrigger
|
||||
var t fv1.HTTPTrigger
|
||||
err = json.Unmarshal(body, &t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -83,7 +82,7 @@ func (c *Client) HTTPTriggerGet(m *metav1.ObjectMeta) (*crd.HTTPTrigger, error)
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func (c *Client) HTTPTriggerUpdate(t *crd.HTTPTrigger) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) HTTPTriggerUpdate(t *fv1.HTTPTrigger) (*metav1.ObjectMeta, error) {
|
||||
err := t.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("HTTPTrigger", err)
|
||||
@@ -120,7 +119,7 @@ func (c *Client) HTTPTriggerDelete(m *metav1.ObjectMeta) error {
|
||||
return c.delete(relativeUrl)
|
||||
}
|
||||
|
||||
func (c *Client) HTTPTriggerList(triggerNamespace string) ([]crd.HTTPTrigger, error) {
|
||||
func (c *Client) HTTPTriggerList(triggerNamespace string) ([]fv1.HTTPTrigger, error) {
|
||||
relativeUrl := fmt.Sprintf("triggers/http?namespace=%v", triggerNamespace)
|
||||
resp, err := http.Get(c.url(relativeUrl))
|
||||
if err != nil {
|
||||
@@ -133,7 +132,7 @@ func (c *Client) HTTPTriggerList(triggerNamespace string) ([]crd.HTTPTrigger, er
|
||||
return nil, err
|
||||
}
|
||||
|
||||
triggers := make([]crd.HTTPTrigger, 0)
|
||||
triggers := make([]fv1.HTTPTrigger, 0)
|
||||
err = json.Unmarshal(body, &triggers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
+8
-9
@@ -24,12 +24,11 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (c *Client) WatchCreate(w *crd.KubernetesWatchTrigger) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) WatchCreate(w *fv1.KubernetesWatchTrigger) (*metav1.ObjectMeta, error) {
|
||||
err := w.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("KubernetesWatchTrigger", err)
|
||||
@@ -60,7 +59,7 @@ func (c *Client) WatchCreate(w *crd.KubernetesWatchTrigger) (*metav1.ObjectMeta,
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func (c *Client) WatchGet(m *metav1.ObjectMeta) (*crd.KubernetesWatchTrigger, error) {
|
||||
func (c *Client) WatchGet(m *metav1.ObjectMeta) (*fv1.KubernetesWatchTrigger, error) {
|
||||
relativeUrl := fmt.Sprintf("watches/%v", m.Name)
|
||||
relativeUrl += fmt.Sprintf("?namespace=%v", m.Namespace)
|
||||
|
||||
@@ -75,7 +74,7 @@ func (c *Client) WatchGet(m *metav1.ObjectMeta) (*crd.KubernetesWatchTrigger, er
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var w crd.KubernetesWatchTrigger
|
||||
var w fv1.KubernetesWatchTrigger
|
||||
err = json.Unmarshal(body, &w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -84,8 +83,8 @@ func (c *Client) WatchGet(m *metav1.ObjectMeta) (*crd.KubernetesWatchTrigger, er
|
||||
return &w, nil
|
||||
}
|
||||
|
||||
func (c *Client) WatchUpdate(w *crd.KubernetesWatchTrigger) (*metav1.ObjectMeta, error) {
|
||||
return nil, fission.MakeError(fission.ErrorNotImplmented,
|
||||
func (c *Client) WatchUpdate(w *fv1.KubernetesWatchTrigger) (*metav1.ObjectMeta, error) {
|
||||
return nil, ferror.MakeError(ferror.ErrorNotImplmented,
|
||||
"watch update not implemented")
|
||||
}
|
||||
|
||||
@@ -95,7 +94,7 @@ func (c *Client) WatchDelete(m *metav1.ObjectMeta) error {
|
||||
return c.delete(relativeUrl)
|
||||
}
|
||||
|
||||
func (c *Client) WatchList(ns string) ([]crd.KubernetesWatchTrigger, error) {
|
||||
func (c *Client) WatchList(ns string) ([]fv1.KubernetesWatchTrigger, error) {
|
||||
relativeUrl := fmt.Sprintf("watches?namespace=%v", ns)
|
||||
resp, err := http.Get(c.url(relativeUrl))
|
||||
if err != nil {
|
||||
@@ -108,7 +107,7 @@ func (c *Client) WatchList(ns string) ([]crd.KubernetesWatchTrigger, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
watches := make([]crd.KubernetesWatchTrigger, 0)
|
||||
watches := make([]fv1.KubernetesWatchTrigger, 0)
|
||||
err = json.Unmarshal(body, &watches)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -24,11 +24,10 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
func (c *Client) MessageQueueTriggerCreate(t *crd.MessageQueueTrigger) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) MessageQueueTriggerCreate(t *fv1.MessageQueueTrigger) (*metav1.ObjectMeta, error) {
|
||||
err := t.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("MessageQueueTrigger", err)
|
||||
@@ -59,7 +58,7 @@ func (c *Client) MessageQueueTriggerCreate(t *crd.MessageQueueTrigger) (*metav1.
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func (c *Client) MessageQueueTriggerGet(m *metav1.ObjectMeta) (*crd.MessageQueueTrigger, error) {
|
||||
func (c *Client) MessageQueueTriggerGet(m *metav1.ObjectMeta) (*fv1.MessageQueueTrigger, error) {
|
||||
relativeUrl := fmt.Sprintf("triggers/messagequeue/%v", m.Name)
|
||||
relativeUrl += fmt.Sprintf("?namespace=%v", m.Namespace)
|
||||
|
||||
@@ -74,7 +73,7 @@ func (c *Client) MessageQueueTriggerGet(m *metav1.ObjectMeta) (*crd.MessageQueue
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var t crd.MessageQueueTrigger
|
||||
var t fv1.MessageQueueTrigger
|
||||
err = json.Unmarshal(body, &t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -83,7 +82,7 @@ func (c *Client) MessageQueueTriggerGet(m *metav1.ObjectMeta) (*crd.MessageQueue
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func (c *Client) MessageQueueTriggerUpdate(mqTrigger *crd.MessageQueueTrigger) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) MessageQueueTriggerUpdate(mqTrigger *fv1.MessageQueueTrigger) (*metav1.ObjectMeta, error) {
|
||||
err := mqTrigger.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("MessageQueueTrigger", err)
|
||||
@@ -120,7 +119,7 @@ func (c *Client) MessageQueueTriggerDelete(m *metav1.ObjectMeta) error {
|
||||
return c.delete(relativeUrl)
|
||||
}
|
||||
|
||||
func (c *Client) MessageQueueTriggerList(mqType string, ns string) ([]crd.MessageQueueTrigger, error) {
|
||||
func (c *Client) MessageQueueTriggerList(mqType string, ns string) ([]fv1.MessageQueueTrigger, error) {
|
||||
relativeUrl := "triggers/messagequeue"
|
||||
if len(mqType) > 0 {
|
||||
// TODO remove this, replace with field selector
|
||||
@@ -138,7 +137,7 @@ func (c *Client) MessageQueueTriggerList(mqType string, ns string) ([]crd.Messag
|
||||
return nil, err
|
||||
}
|
||||
|
||||
triggers := make([]crd.MessageQueueTrigger, 0)
|
||||
triggers := make([]fv1.MessageQueueTrigger, 0)
|
||||
err = json.Unmarshal(body, &triggers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -24,11 +24,10 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
func (c *Client) PackageCreate(f *crd.Package) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) PackageCreate(f *fv1.Package) (*metav1.ObjectMeta, error) {
|
||||
err := f.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("Package", err)
|
||||
@@ -59,7 +58,7 @@ func (c *Client) PackageCreate(f *crd.Package) (*metav1.ObjectMeta, error) {
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func (c *Client) PackageGet(m *metav1.ObjectMeta) (*crd.Package, error) {
|
||||
func (c *Client) PackageGet(m *metav1.ObjectMeta) (*fv1.Package, error) {
|
||||
relativeUrl := fmt.Sprintf("packages/%v", m.Name)
|
||||
relativeUrl += fmt.Sprintf("?namespace=%v", m.Namespace)
|
||||
|
||||
@@ -74,7 +73,7 @@ func (c *Client) PackageGet(m *metav1.ObjectMeta) (*crd.Package, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var f crd.Package
|
||||
var f fv1.Package
|
||||
err = json.Unmarshal(body, &f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -83,7 +82,7 @@ func (c *Client) PackageGet(m *metav1.ObjectMeta) (*crd.Package, error) {
|
||||
return &f, nil
|
||||
}
|
||||
|
||||
func (c *Client) PackageUpdate(f *crd.Package) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) PackageUpdate(f *fv1.Package) (*metav1.ObjectMeta, error) {
|
||||
err := f.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("Package", err)
|
||||
@@ -120,7 +119,7 @@ func (c *Client) PackageDelete(m *metav1.ObjectMeta) error {
|
||||
return c.delete(relativeUrl)
|
||||
}
|
||||
|
||||
func (c *Client) PackageList(pkgNamespace string) ([]crd.Package, error) {
|
||||
func (c *Client) PackageList(pkgNamespace string) ([]fv1.Package, error) {
|
||||
relativeUrl := fmt.Sprintf("packages?namespace=%v", pkgNamespace)
|
||||
resp, err := http.Get(c.url(relativeUrl))
|
||||
if err != nil {
|
||||
@@ -133,7 +132,7 @@ func (c *Client) PackageList(pkgNamespace string) ([]crd.Package, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
funcs := make([]crd.Package, 0)
|
||||
funcs := make([]fv1.Package, 0)
|
||||
err = json.Unmarshal(body, &funcs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -24,12 +24,11 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/redis/build/gen"
|
||||
"github.com/fission/fission/pkg/redis/build/gen"
|
||||
)
|
||||
|
||||
func (c *Client) RecorderCreate(r *crd.Recorder) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) RecorderCreate(r *fv1.Recorder) (*metav1.ObjectMeta, error) {
|
||||
err := r.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("Recorder", err)
|
||||
@@ -60,7 +59,7 @@ func (c *Client) RecorderCreate(r *crd.Recorder) (*metav1.ObjectMeta, error) {
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func (c *Client) RecorderGet(m *metav1.ObjectMeta) (*crd.Recorder, error) {
|
||||
func (c *Client) RecorderGet(m *metav1.ObjectMeta) (*fv1.Recorder, error) {
|
||||
relativeUrl := fmt.Sprintf("recorders/%v", m.Name)
|
||||
relativeUrl += fmt.Sprintf("?namespace=%v", m.Namespace)
|
||||
|
||||
@@ -75,7 +74,7 @@ func (c *Client) RecorderGet(m *metav1.ObjectMeta) (*crd.Recorder, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r crd.Recorder
|
||||
var r fv1.Recorder
|
||||
err = json.Unmarshal(body, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -84,7 +83,7 @@ func (c *Client) RecorderGet(m *metav1.ObjectMeta) (*crd.Recorder, error) {
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (c *Client) RecorderUpdate(recorder *crd.Recorder) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) RecorderUpdate(recorder *fv1.Recorder) (*metav1.ObjectMeta, error) {
|
||||
err := recorder.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("Recorder", err)
|
||||
@@ -121,7 +120,7 @@ func (c *Client) RecorderDelete(m *metav1.ObjectMeta) error {
|
||||
return c.delete(relativeUrl)
|
||||
}
|
||||
|
||||
func (c *Client) RecorderList(ns string) ([]crd.Recorder, error) {
|
||||
func (c *Client) RecorderList(ns string) ([]fv1.Recorder, error) {
|
||||
relativeUrl := "recorders"
|
||||
|
||||
resp, err := http.Get(c.url(relativeUrl))
|
||||
@@ -135,7 +134,7 @@ func (c *Client) RecorderList(ns string) ([]crd.Recorder, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
recorders := make([]crd.Recorder, 0)
|
||||
recorders := make([]fv1.Recorder, 0)
|
||||
err = json.Unmarshal(body, &recorders)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -24,11 +24,10 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
func (c *Client) TimeTriggerCreate(t *crd.TimeTrigger) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) TimeTriggerCreate(t *fv1.TimeTrigger) (*metav1.ObjectMeta, error) {
|
||||
err := t.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("TimeTrigger", err)
|
||||
@@ -59,7 +58,7 @@ func (c *Client) TimeTriggerCreate(t *crd.TimeTrigger) (*metav1.ObjectMeta, erro
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func (c *Client) TimeTriggerGet(m *metav1.ObjectMeta) (*crd.TimeTrigger, error) {
|
||||
func (c *Client) TimeTriggerGet(m *metav1.ObjectMeta) (*fv1.TimeTrigger, error) {
|
||||
relativeUrl := fmt.Sprintf("triggers/time/%v", m.Name)
|
||||
relativeUrl += fmt.Sprintf("?namespace=%v", m.Namespace)
|
||||
|
||||
@@ -74,7 +73,7 @@ func (c *Client) TimeTriggerGet(m *metav1.ObjectMeta) (*crd.TimeTrigger, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var t crd.TimeTrigger
|
||||
var t fv1.TimeTrigger
|
||||
err = json.Unmarshal(body, &t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -83,7 +82,7 @@ func (c *Client) TimeTriggerGet(m *metav1.ObjectMeta) (*crd.TimeTrigger, error)
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func (c *Client) TimeTriggerUpdate(t *crd.TimeTrigger) (*metav1.ObjectMeta, error) {
|
||||
func (c *Client) TimeTriggerUpdate(t *fv1.TimeTrigger) (*metav1.ObjectMeta, error) {
|
||||
err := t.Validate()
|
||||
if err != nil {
|
||||
return nil, fv1.AggregateValidationErrors("TimeTrigger", err)
|
||||
@@ -120,7 +119,7 @@ func (c *Client) TimeTriggerDelete(m *metav1.ObjectMeta) error {
|
||||
return c.delete(relativeUrl)
|
||||
}
|
||||
|
||||
func (c *Client) TimeTriggerList(ns string) ([]crd.TimeTrigger, error) {
|
||||
func (c *Client) TimeTriggerList(ns string) ([]fv1.TimeTrigger, error) {
|
||||
relativeUrl := fmt.Sprintf("triggers/time?namespace=%v", ns)
|
||||
resp, err := http.Get(c.url(relativeUrl))
|
||||
if err != nil {
|
||||
@@ -133,7 +132,7 @@ func (c *Client) TimeTriggerList(ns string) ([]crd.TimeTrigger, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
triggers := make([]crd.TimeTrigger, 0)
|
||||
triggers := make([]fv1.TimeTrigger, 0)
|
||||
err = json.Unmarshal(body, &triggers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -23,9 +23,9 @@ import (
|
||||
"go.uber.org/zap"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/fission/fission/canaryconfigmgr"
|
||||
"github.com/fission/fission/crd"
|
||||
config "github.com/fission/fission/featureconfig"
|
||||
"github.com/fission/fission/pkg/canaryconfigmgr"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
config "github.com/fission/fission/pkg/featureconfig"
|
||||
)
|
||||
|
||||
func ConfigCanaryFeature(context context.Context, logger *zap.Logger, fissionClient *crd.FissionClient, kubeClient *kubernetes.Clientset, featureConfig *config.FeatureConfig, featureStatus map[string]string) error {
|
||||
@@ -21,14 +21,14 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
func Start(logger *zap.Logger, port int, unitTestFlag bool) {
|
||||
cLogger := logger.Named("controller")
|
||||
// setup a signal handler for SIGTERM
|
||||
fission.SetupStackTraceHandler()
|
||||
utils.SetupStackTraceHandler()
|
||||
|
||||
fc, kc, apiExtClient, err := crd.MakeFissionClient()
|
||||
if err != nil {
|
||||
@@ -19,7 +19,7 @@ package controller
|
||||
import (
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
)
|
||||
|
||||
func makeCRDBackedAPI(logger *zap.Logger) (*API, error) {
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
"go.uber.org/zap"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (a *API) EnvironmentApiList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -57,7 +57,7 @@ func (a *API) EnvironmentApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var env crd.Environment
|
||||
var env fv1.Environment
|
||||
err = json.Unmarshal(body, &env)
|
||||
if err != nil {
|
||||
a.logger.Error("failed to unmarshal request body", zap.Error(err), zap.Binary("body", body))
|
||||
@@ -122,7 +122,7 @@ func (a *API) EnvironmentApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var env crd.Environment
|
||||
var env fv1.Environment
|
||||
err = json.Unmarshal(body, &env)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -130,7 +130,7 @@ func (a *API) EnvironmentApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if name != env.Metadata.Name {
|
||||
err = fission.MakeError(fission.ErrorInvalidArgument, "Environment name doesn't match URL")
|
||||
err = ferror.MakeError(ferror.ErrorInvalidArgument, "Environment name doesn't match URL")
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -32,8 +32,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (a *API) getIstioServiceLabels(fnName string) map[string]string {
|
||||
@@ -70,7 +70,7 @@ func (a *API) FunctionApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var f crd.Function
|
||||
var f fv1.Function
|
||||
err = json.Unmarshal(body, &f)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -132,7 +132,7 @@ func (a *API) FunctionApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var f crd.Function
|
||||
var f fv1.Function
|
||||
err = json.Unmarshal(body, &f)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -140,7 +140,7 @@ func (a *API) FunctionApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if name != f.Metadata.Name {
|
||||
err = fission.MakeError(fission.ErrorInvalidArgument, "Function name doesn't match URL")
|
||||
err = ferror.MakeError(ferror.ErrorInvalidArgument, "Function name doesn't match URL")
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (a *API) HTTPTriggerApiList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -51,7 +51,7 @@ func (a *API) HTTPTriggerApiList(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// checkHTTPTriggerDuplicates checks whether the tuple (Method, Host, URL) is duplicate or not.
|
||||
func (a *API) checkHTTPTriggerDuplicates(t *crd.HTTPTrigger) error {
|
||||
func (a *API) checkHTTPTriggerDuplicates(t *fv1.HTTPTrigger) error {
|
||||
triggers, err := a.fissionClient.HTTPTriggers(metav1.NamespaceAll).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -62,7 +62,7 @@ func (a *API) checkHTTPTriggerDuplicates(t *crd.HTTPTrigger) error {
|
||||
continue
|
||||
}
|
||||
if ht.Spec.RelativeURL == t.Spec.RelativeURL && ht.Spec.Method == t.Spec.Method && ht.Spec.Host == t.Spec.Host {
|
||||
return fission.MakeError(fission.ErrorNameExists,
|
||||
return ferror.MakeError(ferror.ErrorNameExists,
|
||||
fmt.Sprintf("HTTPTrigger with same Host, URL & method already exists (%v)",
|
||||
ht.Metadata.Name))
|
||||
}
|
||||
@@ -77,7 +77,7 @@ func (a *API) HTTPTriggerApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var t crd.HTTPTrigger
|
||||
var t fv1.HTTPTrigger
|
||||
err = json.Unmarshal(body, &t)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -147,7 +147,7 @@ func (a *API) HTTPTriggerApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var t crd.HTTPTrigger
|
||||
var t fv1.HTTPTrigger
|
||||
err = json.Unmarshal(body, &t)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -155,7 +155,7 @@ func (a *API) HTTPTriggerApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if name != t.Metadata.Name {
|
||||
err = fission.MakeError(fission.ErrorInvalidArgument, "HTTPTrigger name doesn't match URL")
|
||||
err = ferror.MakeError(ferror.ErrorInvalidArgument, "HTTPTrigger name doesn't match URL")
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (a *API) MessageQueueTriggerApiList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -55,7 +55,7 @@ func (a *API) MessageQueueTriggerApiCreate(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
var mqTrigger crd.MessageQueueTrigger
|
||||
var mqTrigger fv1.MessageQueueTrigger
|
||||
err = json.Unmarshal(body, &mqTrigger)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -115,7 +115,7 @@ func (a *API) MessageQueueTriggerApiUpdate(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
var mqTrigger crd.MessageQueueTrigger
|
||||
var mqTrigger fv1.MessageQueueTrigger
|
||||
err = json.Unmarshal(body, &mqTrigger)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -123,7 +123,7 @@ func (a *API) MessageQueueTriggerApiUpdate(w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
|
||||
if name != mqTrigger.Metadata.Name {
|
||||
err = fission.MakeError(fission.ErrorInvalidArgument, "Message queue trigger name doesn't match URL")
|
||||
err = ferror.MakeError(ferror.ErrorInvalidArgument, "Message queue trigger name doesn't match URL")
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -23,11 +23,12 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
"github.com/gorilla/mux"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (a *API) PackageApiList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -57,7 +58,7 @@ func (a *API) PackageApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var f crd.Package
|
||||
var f fv1.Package
|
||||
err = json.Unmarshal(body, &f)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -65,15 +66,15 @@ func (a *API) PackageApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Ensure size limits
|
||||
if len(f.Spec.Source.Literal) > int(fission.ArchiveLiteralSizeLimit) {
|
||||
err := fission.MakeError(fission.ErrorInvalidArgument,
|
||||
fmt.Sprintf("Package literal larger than %s", humanize.Bytes(uint64(fission.ArchiveLiteralSizeLimit))))
|
||||
if len(f.Spec.Source.Literal) > int(types.ArchiveLiteralSizeLimit) {
|
||||
err := ferror.MakeError(ferror.ErrorInvalidArgument,
|
||||
fmt.Sprintf("Package literal larger than %s", humanize.Bytes(uint64(types.ArchiveLiteralSizeLimit))))
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
if len(f.Spec.Deployment.Literal) > int(fission.ArchiveLiteralSizeLimit) {
|
||||
err := fission.MakeError(fission.ErrorInvalidArgument,
|
||||
fmt.Sprintf("Package literal larger than %s", humanize.Bytes(uint64(fission.ArchiveLiteralSizeLimit))))
|
||||
if len(f.Spec.Deployment.Literal) > int(types.ArchiveLiteralSizeLimit) {
|
||||
err := ferror.MakeError(ferror.ErrorInvalidArgument,
|
||||
fmt.Sprintf("Package literal larger than %s", humanize.Bytes(uint64(types.ArchiveLiteralSizeLimit))))
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -139,7 +140,7 @@ func (a *API) PackageApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var f crd.Package
|
||||
var f fv1.Package
|
||||
err = json.Unmarshal(body, &f)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -147,7 +148,7 @@ func (a *API) PackageApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if name != f.Metadata.Name {
|
||||
err = fission.MakeError(fission.ErrorInvalidArgument, "Package name doesn't match URL")
|
||||
err = ferror.MakeError(ferror.ErrorInvalidArgument, "Package name doesn't match URL")
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (a *API) RecorderApiList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -50,7 +50,7 @@ func (a *API) RecorderApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var recorder crd.Recorder
|
||||
var recorder fv1.Recorder
|
||||
err = json.Unmarshal(body, &recorder)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -103,7 +103,7 @@ func (a *API) RecorderApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var recorder crd.Recorder
|
||||
var recorder fv1.Recorder
|
||||
err = json.Unmarshal(body, &recorder)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -111,7 +111,7 @@ func (a *API) RecorderApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if name != recorder.Metadata.Name {
|
||||
err = fission.MakeError(fission.ErrorInvalidArgument, "Recorder name doesn't match URL")
|
||||
err = ferror.MakeError(ferror.ErrorInvalidArgument, "Recorder name doesn't match URL")
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/redis"
|
||||
"github.com/fission/fission/pkg/redis"
|
||||
)
|
||||
|
||||
func (a *API) RecordsApiListAll(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/fission/fission/redis"
|
||||
"github.com/fission/fission/pkg/redis"
|
||||
)
|
||||
|
||||
func (a *API) ReplayByReqUID(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
"github.com/robfig/cron"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (a *API) TimeTriggerApiList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -57,7 +57,7 @@ func (a *API) TimeTriggerApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var t crd.TimeTrigger
|
||||
var t fv1.TimeTrigger
|
||||
err = json.Unmarshal(body, &t)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -67,7 +67,7 @@ func (a *API) TimeTriggerApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
// validate
|
||||
_, err = cron.Parse(t.Spec.Cron)
|
||||
if err != nil {
|
||||
err = fission.MakeError(fission.ErrorInvalidArgument, "TimeTrigger cron spec is not valid")
|
||||
err = ferror.MakeError(ferror.ErrorInvalidArgument, "TimeTrigger cron spec is not valid")
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func (a *API) TimeTriggerApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var t crd.TimeTrigger
|
||||
var t fv1.TimeTrigger
|
||||
err = json.Unmarshal(body, &t)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -136,14 +136,14 @@ func (a *API) TimeTriggerApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if name != t.Metadata.Name {
|
||||
err = fission.MakeError(fission.ErrorInvalidArgument, "TimeTrigger name doesn't match URL")
|
||||
err = ferror.MakeError(ferror.ErrorInvalidArgument, "TimeTrigger name doesn't match URL")
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = cron.Parse(t.Spec.Cron)
|
||||
if err != nil {
|
||||
err = fission.MakeError(fission.ErrorInvalidArgument, "TimeTrigger cron spec is not valid")
|
||||
err = ferror.MakeError(ferror.ErrorInvalidArgument, "TimeTrigger cron spec is not valid")
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (a *API) WatchApiList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -56,7 +56,7 @@ func (a *API) WatchApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var watch crd.KubernetesWatchTrigger
|
||||
var watch fv1.KubernetesWatchTrigger
|
||||
err = json.Unmarshal(body, &watch)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
@@ -112,7 +112,7 @@ func (a *API) WatchApiGet(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (a *API) WatchApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
a.respondWithError(w, fission.MakeError(fission.ErrorNotImplmented,
|
||||
a.respondWithError(w, ferror.MakeError(ferror.ErrorNotImplmented,
|
||||
"Not implemented"))
|
||||
}
|
||||
|
||||
@@ -21,15 +21,17 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
CanaryConfigInterface interface {
|
||||
Create(*CanaryConfig) (*CanaryConfig, error)
|
||||
Get(name string) (*CanaryConfig, error)
|
||||
Update(*CanaryConfig) (*CanaryConfig, error)
|
||||
Create(*fv1.CanaryConfig) (*fv1.CanaryConfig, error)
|
||||
Get(name string) (*fv1.CanaryConfig, error)
|
||||
Update(*fv1.CanaryConfig) (*fv1.CanaryConfig, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*CanaryConfigList, error)
|
||||
List(opts metav1.ListOptions) (*fv1.CanaryConfigList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ func MakeCanaryConfigInterface(crdClient *rest.RESTClient, namespace string) Can
|
||||
}
|
||||
}
|
||||
|
||||
func (c *canaryConfigClient) Create(f *CanaryConfig) (*CanaryConfig, error) {
|
||||
var result CanaryConfig
|
||||
func (c *canaryConfigClient) Create(f *fv1.CanaryConfig) (*fv1.CanaryConfig, error) {
|
||||
var result fv1.CanaryConfig
|
||||
err := c.client.Post().
|
||||
Resource("canaryconfigs").
|
||||
Namespace(c.namespace).
|
||||
@@ -59,8 +61,8 @@ func (c *canaryConfigClient) Create(f *CanaryConfig) (*CanaryConfig, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *canaryConfigClient) Get(name string) (*CanaryConfig, error) {
|
||||
var result CanaryConfig
|
||||
func (c *canaryConfigClient) Get(name string) (*fv1.CanaryConfig, error) {
|
||||
var result fv1.CanaryConfig
|
||||
err := c.client.Get().
|
||||
Resource("canaryconfigs").
|
||||
Namespace(c.namespace).
|
||||
@@ -72,8 +74,8 @@ func (c *canaryConfigClient) Get(name string) (*CanaryConfig, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *canaryConfigClient) Update(f *CanaryConfig) (*CanaryConfig, error) {
|
||||
var result CanaryConfig
|
||||
func (c *canaryConfigClient) Update(f *fv1.CanaryConfig) (*fv1.CanaryConfig, error) {
|
||||
var result fv1.CanaryConfig
|
||||
err := c.client.Put().
|
||||
Resource("canaryconfigs").
|
||||
Namespace(c.namespace).
|
||||
@@ -96,8 +98,8 @@ func (c *canaryConfigClient) Delete(name string, opts *metav1.DeleteOptions) err
|
||||
Error()
|
||||
}
|
||||
|
||||
func (c *canaryConfigClient) List(opts metav1.ListOptions) (*CanaryConfigList, error) {
|
||||
var result CanaryConfigList
|
||||
func (c *canaryConfigClient) List(opts metav1.ListOptions) (*fv1.CanaryConfigList, error) {
|
||||
var result fv1.CanaryConfigList
|
||||
err := c.client.Get().
|
||||
Namespace(c.namespace).
|
||||
Resource("canaryconfigs").
|
||||
@@ -31,6 +31,8 @@ import (
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -106,64 +108,64 @@ func configureClient(config *rest.Config) {
|
||||
func(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&Function{},
|
||||
&FunctionList{},
|
||||
&fv1.Function{},
|
||||
&fv1.FunctionList{},
|
||||
&metav1.ListOptions{},
|
||||
&metav1.DeleteOptions{},
|
||||
)
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&Environment{},
|
||||
&EnvironmentList{},
|
||||
&fv1.Environment{},
|
||||
&fv1.EnvironmentList{},
|
||||
&metav1.ListOptions{},
|
||||
&metav1.DeleteOptions{},
|
||||
)
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&HTTPTrigger{},
|
||||
&HTTPTriggerList{},
|
||||
&fv1.HTTPTrigger{},
|
||||
&fv1.HTTPTriggerList{},
|
||||
&metav1.ListOptions{},
|
||||
&metav1.DeleteOptions{},
|
||||
)
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&KubernetesWatchTrigger{},
|
||||
&KubernetesWatchTriggerList{},
|
||||
&fv1.KubernetesWatchTrigger{},
|
||||
&fv1.KubernetesWatchTriggerList{},
|
||||
&metav1.ListOptions{},
|
||||
&metav1.DeleteOptions{},
|
||||
)
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&TimeTrigger{},
|
||||
&TimeTriggerList{},
|
||||
&fv1.TimeTrigger{},
|
||||
&fv1.TimeTriggerList{},
|
||||
&metav1.ListOptions{},
|
||||
&metav1.DeleteOptions{},
|
||||
)
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&MessageQueueTrigger{},
|
||||
&MessageQueueTriggerList{},
|
||||
&fv1.MessageQueueTrigger{},
|
||||
&fv1.MessageQueueTriggerList{},
|
||||
&metav1.ListOptions{},
|
||||
&metav1.DeleteOptions{},
|
||||
)
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&Package{},
|
||||
&PackageList{},
|
||||
&fv1.Package{},
|
||||
&fv1.PackageList{},
|
||||
&metav1.ListOptions{},
|
||||
&metav1.DeleteOptions{},
|
||||
)
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&Recorder{},
|
||||
&RecorderList{},
|
||||
&fv1.Recorder{},
|
||||
&fv1.RecorderList{},
|
||||
&metav1.ListOptions{},
|
||||
&metav1.DeleteOptions{},
|
||||
)
|
||||
scheme.AddKnownTypes(
|
||||
groupversion,
|
||||
&CanaryConfig{},
|
||||
&CanaryConfigList{},
|
||||
&fv1.CanaryConfig{},
|
||||
&fv1.CanaryConfigList{},
|
||||
&metav1.ListOptions{},
|
||||
&metav1.DeleteOptions{},
|
||||
)
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
"github.com/fission/fission"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
func panicIf(err error) {
|
||||
@@ -37,24 +37,24 @@ func panicIf(err error) {
|
||||
|
||||
func functionTests(crdClient *rest.RESTClient) {
|
||||
// sample function object
|
||||
function := &Function{
|
||||
function := &fv1.Function{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Function",
|
||||
APIVersion: "fission.io/v1",
|
||||
APIVersion: "fv1.io/v1",
|
||||
},
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "hello",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.FunctionSpec{
|
||||
Package: fission.FunctionPackageRef{
|
||||
PackageRef: fission.PackageRef{
|
||||
Spec: fv1.FunctionSpec{
|
||||
Package: fv1.FunctionPackageRef{
|
||||
PackageRef: fv1.PackageRef{
|
||||
Name: "foo",
|
||||
Namespace: "bar",
|
||||
},
|
||||
FunctionName: "hello",
|
||||
},
|
||||
Environment: fission.EnvironmentReference{
|
||||
Environment: fv1.EnvironmentReference{
|
||||
Name: "xxx",
|
||||
},
|
||||
},
|
||||
@@ -122,7 +122,7 @@ func functionTests(crdClient *rest.RESTClient) {
|
||||
log.Panicf("Didn't get watch event")
|
||||
}
|
||||
case ev := <-wi.ResultChan():
|
||||
wf, ok := ev.Object.(*Function)
|
||||
wf, ok := ev.Object.(*fv1.Function)
|
||||
if !ok {
|
||||
log.Panicf("Can't cast to Function")
|
||||
}
|
||||
@@ -137,20 +137,20 @@ func functionTests(crdClient *rest.RESTClient) {
|
||||
|
||||
func environmentTests(crdClient *rest.RESTClient) {
|
||||
// sample environment object
|
||||
environment := &Environment{
|
||||
environment := &fv1.Environment{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Environment",
|
||||
APIVersion: "fission.io/v1",
|
||||
APIVersion: "fv1.io/v1",
|
||||
},
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "hello",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.EnvironmentSpec{
|
||||
Runtime: fission.Runtime{
|
||||
Spec: fv1.EnvironmentSpec{
|
||||
Runtime: fv1.Runtime{
|
||||
Image: "xxx",
|
||||
},
|
||||
Builder: fission.Builder{
|
||||
Builder: fv1.Builder{
|
||||
Image: "yyy",
|
||||
Command: "zzz",
|
||||
},
|
||||
@@ -215,7 +215,7 @@ func environmentTests(crdClient *rest.RESTClient) {
|
||||
log.Panicf("Didn't get watch event")
|
||||
}
|
||||
case ev := <-wi.ResultChan():
|
||||
obj, ok := ev.Object.(*Environment)
|
||||
obj, ok := ev.Object.(*fv1.Environment)
|
||||
if !ok {
|
||||
log.Panicf("Can't cast to Environment")
|
||||
}
|
||||
@@ -230,20 +230,20 @@ func environmentTests(crdClient *rest.RESTClient) {
|
||||
|
||||
func httpTriggerTests(crdClient *rest.RESTClient) {
|
||||
// sample httpTrigger object
|
||||
httpTrigger := &HTTPTrigger{
|
||||
httpTrigger := &fv1.HTTPTrigger{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "HTTPTrigger",
|
||||
APIVersion: "fission.io/v1",
|
||||
APIVersion: "fv1.io/v1",
|
||||
},
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "hello",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.HTTPTriggerSpec{
|
||||
Spec: fv1.HTTPTriggerSpec{
|
||||
RelativeURL: "/hi",
|
||||
Method: "GET",
|
||||
FunctionReference: fission.FunctionReference{
|
||||
Type: fission.FunctionReferenceTypeFunctionName,
|
||||
FunctionReference: fv1.FunctionReference{
|
||||
Type: fv1.FunctionReferenceTypeFunctionName,
|
||||
Name: "hello",
|
||||
},
|
||||
},
|
||||
@@ -307,7 +307,7 @@ func httpTriggerTests(crdClient *rest.RESTClient) {
|
||||
log.Panicf("Didn't get watch event")
|
||||
}
|
||||
case ev := <-wi.ResultChan():
|
||||
obj, ok := ev.Object.(*HTTPTrigger)
|
||||
obj, ok := ev.Object.(*fv1.HTTPTrigger)
|
||||
if !ok {
|
||||
log.Panicf("Can't cast to HTTPTrigger")
|
||||
}
|
||||
@@ -322,23 +322,23 @@ func httpTriggerTests(crdClient *rest.RESTClient) {
|
||||
|
||||
func kubernetesWatchTriggerTests(crdClient *rest.RESTClient) {
|
||||
// sample kubernetesWatchTrigger object
|
||||
kubernetesWatchTrigger := &KubernetesWatchTrigger{
|
||||
kubernetesWatchTrigger := &fv1.KubernetesWatchTrigger{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "KubernetesWatchTrigger",
|
||||
APIVersion: "fission.io/v1",
|
||||
APIVersion: "fv1.io/v1",
|
||||
},
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "hello",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: fission.KubernetesWatchTriggerSpec{
|
||||
Spec: fv1.KubernetesWatchTriggerSpec{
|
||||
Namespace: "foo",
|
||||
Type: "pod",
|
||||
LabelSelector: map[string]string{
|
||||
"x": "y",
|
||||
},
|
||||
FunctionReference: fission.FunctionReference{
|
||||
Type: fission.FunctionReferenceTypeFunctionName,
|
||||
FunctionReference: fv1.FunctionReference{
|
||||
Type: fv1.FunctionReferenceTypeFunctionName,
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
@@ -402,7 +402,7 @@ func kubernetesWatchTriggerTests(crdClient *rest.RESTClient) {
|
||||
log.Panicf("Didn't get watch event")
|
||||
}
|
||||
case ev := <-wi.ResultChan():
|
||||
obj, ok := ev.Object.(*KubernetesWatchTrigger)
|
||||
obj, ok := ev.Object.(*fv1.KubernetesWatchTrigger)
|
||||
if !ok {
|
||||
log.Panicf("Can't cast to KubernetesWatchTrigger")
|
||||
}
|
||||
@@ -21,15 +21,17 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
EnvironmentInterface interface {
|
||||
Create(*Environment) (*Environment, error)
|
||||
Get(name string) (*Environment, error)
|
||||
Update(*Environment) (*Environment, error)
|
||||
Create(*fv1.Environment) (*fv1.Environment, error)
|
||||
Get(name string) (*fv1.Environment, error)
|
||||
Update(*fv1.Environment) (*fv1.Environment, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*EnvironmentList, error)
|
||||
List(opts metav1.ListOptions) (*fv1.EnvironmentList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ func MakeEnvironmentInterface(crdClient *rest.RESTClient, namespace string) Envi
|
||||
}
|
||||
}
|
||||
|
||||
func (ec *environmentClient) Create(e *Environment) (*Environment, error) {
|
||||
var result Environment
|
||||
func (ec *environmentClient) Create(e *fv1.Environment) (*fv1.Environment, error) {
|
||||
var result fv1.Environment
|
||||
err := ec.client.Post().
|
||||
Resource("environments").
|
||||
Namespace(ec.namespace).
|
||||
@@ -59,8 +61,8 @@ func (ec *environmentClient) Create(e *Environment) (*Environment, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (ec *environmentClient) Get(name string) (*Environment, error) {
|
||||
var result Environment
|
||||
func (ec *environmentClient) Get(name string) (*fv1.Environment, error) {
|
||||
var result fv1.Environment
|
||||
err := ec.client.Get().
|
||||
Resource("environments").
|
||||
Namespace(ec.namespace).
|
||||
@@ -72,8 +74,8 @@ func (ec *environmentClient) Get(name string) (*Environment, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (ec *environmentClient) Update(e *Environment) (*Environment, error) {
|
||||
var result Environment
|
||||
func (ec *environmentClient) Update(e *fv1.Environment) (*fv1.Environment, error) {
|
||||
var result fv1.Environment
|
||||
err := ec.client.Put().
|
||||
Resource("environments").
|
||||
Namespace(ec.namespace).
|
||||
@@ -96,8 +98,8 @@ func (ec *environmentClient) Delete(name string, opts *metav1.DeleteOptions) err
|
||||
Error()
|
||||
}
|
||||
|
||||
func (ec *environmentClient) List(opts metav1.ListOptions) (*EnvironmentList, error) {
|
||||
var result EnvironmentList
|
||||
func (ec *environmentClient) List(opts metav1.ListOptions) (*fv1.EnvironmentList, error) {
|
||||
var result fv1.EnvironmentList
|
||||
err := ec.client.Get().
|
||||
Namespace(ec.namespace).
|
||||
Resource("environments").
|
||||
@@ -21,15 +21,17 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
FunctionInterface interface {
|
||||
Create(*Function) (*Function, error)
|
||||
Get(name string) (*Function, error)
|
||||
Update(*Function) (*Function, error)
|
||||
Create(*fv1.Function) (*fv1.Function, error)
|
||||
Get(name string) (*fv1.Function, error)
|
||||
Update(*fv1.Function) (*fv1.Function, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*FunctionList, error)
|
||||
List(opts metav1.ListOptions) (*fv1.FunctionList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ func MakeFunctionInterface(crdClient *rest.RESTClient, namespace string) Functio
|
||||
}
|
||||
}
|
||||
|
||||
func (fc *functionClient) Create(f *Function) (*Function, error) {
|
||||
var result Function
|
||||
func (fc *functionClient) Create(f *fv1.Function) (*fv1.Function, error) {
|
||||
var result fv1.Function
|
||||
err := fc.client.Post().
|
||||
Resource("functions").
|
||||
Namespace(fc.namespace).
|
||||
@@ -59,8 +61,8 @@ func (fc *functionClient) Create(f *Function) (*Function, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (fc *functionClient) Get(name string) (*Function, error) {
|
||||
var result Function
|
||||
func (fc *functionClient) Get(name string) (*fv1.Function, error) {
|
||||
var result fv1.Function
|
||||
err := fc.client.Get().
|
||||
Resource("functions").
|
||||
Namespace(fc.namespace).
|
||||
@@ -72,8 +74,8 @@ func (fc *functionClient) Get(name string) (*Function, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (fc *functionClient) Update(f *Function) (*Function, error) {
|
||||
var result Function
|
||||
func (fc *functionClient) Update(f *fv1.Function) (*fv1.Function, error) {
|
||||
var result fv1.Function
|
||||
err := fc.client.Put().
|
||||
Resource("functions").
|
||||
Namespace(fc.namespace).
|
||||
@@ -96,8 +98,8 @@ func (fc *functionClient) Delete(name string, opts *metav1.DeleteOptions) error
|
||||
Error()
|
||||
}
|
||||
|
||||
func (fc *functionClient) List(opts metav1.ListOptions) (*FunctionList, error) {
|
||||
var result FunctionList
|
||||
func (fc *functionClient) List(opts metav1.ListOptions) (*fv1.FunctionList, error) {
|
||||
var result fv1.FunctionList
|
||||
err := fc.client.Get().
|
||||
Namespace(fc.namespace).
|
||||
Resource("functions").
|
||||
@@ -21,15 +21,17 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
HTTPTriggerInterface interface {
|
||||
Create(*HTTPTrigger) (*HTTPTrigger, error)
|
||||
Get(name string) (*HTTPTrigger, error)
|
||||
Update(*HTTPTrigger) (*HTTPTrigger, error)
|
||||
Create(*fv1.HTTPTrigger) (*fv1.HTTPTrigger, error)
|
||||
Get(name string) (*fv1.HTTPTrigger, error)
|
||||
Update(*fv1.HTTPTrigger) (*fv1.HTTPTrigger, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*HTTPTriggerList, error)
|
||||
List(opts metav1.ListOptions) (*fv1.HTTPTriggerList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ func MakeHTTPTriggerInterface(crdClient *rest.RESTClient, namespace string) HTTP
|
||||
}
|
||||
}
|
||||
|
||||
func (c *httpTriggerClient) Create(obj *HTTPTrigger) (*HTTPTrigger, error) {
|
||||
var result HTTPTrigger
|
||||
func (c *httpTriggerClient) Create(obj *fv1.HTTPTrigger) (*fv1.HTTPTrigger, error) {
|
||||
var result fv1.HTTPTrigger
|
||||
err := c.client.Post().
|
||||
Resource("httptriggers").
|
||||
Namespace(c.namespace).
|
||||
@@ -59,8 +61,8 @@ func (c *httpTriggerClient) Create(obj *HTTPTrigger) (*HTTPTrigger, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *httpTriggerClient) Get(name string) (*HTTPTrigger, error) {
|
||||
var result HTTPTrigger
|
||||
func (c *httpTriggerClient) Get(name string) (*fv1.HTTPTrigger, error) {
|
||||
var result fv1.HTTPTrigger
|
||||
err := c.client.Get().
|
||||
Resource("httptriggers").
|
||||
Namespace(c.namespace).
|
||||
@@ -72,8 +74,8 @@ func (c *httpTriggerClient) Get(name string) (*HTTPTrigger, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *httpTriggerClient) Update(obj *HTTPTrigger) (*HTTPTrigger, error) {
|
||||
var result HTTPTrigger
|
||||
func (c *httpTriggerClient) Update(obj *fv1.HTTPTrigger) (*fv1.HTTPTrigger, error) {
|
||||
var result fv1.HTTPTrigger
|
||||
err := c.client.Put().
|
||||
Resource("httptriggers").
|
||||
Namespace(c.namespace).
|
||||
@@ -96,8 +98,8 @@ func (c *httpTriggerClient) Delete(name string, opts *metav1.DeleteOptions) erro
|
||||
Error()
|
||||
}
|
||||
|
||||
func (c *httpTriggerClient) List(opts metav1.ListOptions) (*HTTPTriggerList, error) {
|
||||
var result HTTPTriggerList
|
||||
func (c *httpTriggerClient) List(opts metav1.ListOptions) (*fv1.HTTPTriggerList, error) {
|
||||
var result fv1.HTTPTriggerList
|
||||
err := c.client.Get().
|
||||
Namespace(c.namespace).
|
||||
Resource("httptriggers").
|
||||
@@ -21,15 +21,17 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
KubernetesWatchTriggerInterface interface {
|
||||
Create(*KubernetesWatchTrigger) (*KubernetesWatchTrigger, error)
|
||||
Get(name string) (*KubernetesWatchTrigger, error)
|
||||
Update(*KubernetesWatchTrigger) (*KubernetesWatchTrigger, error)
|
||||
Create(*fv1.KubernetesWatchTrigger) (*fv1.KubernetesWatchTrigger, error)
|
||||
Get(name string) (*fv1.KubernetesWatchTrigger, error)
|
||||
Update(*fv1.KubernetesWatchTrigger) (*fv1.KubernetesWatchTrigger, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*KubernetesWatchTriggerList, error)
|
||||
List(opts metav1.ListOptions) (*fv1.KubernetesWatchTriggerList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ func MakeKubernetesWatchTriggerInterface(crdClient *rest.RESTClient, namespace s
|
||||
}
|
||||
}
|
||||
|
||||
func (c *kubernetesWatchTriggerClient) Create(obj *KubernetesWatchTrigger) (*KubernetesWatchTrigger, error) {
|
||||
var result KubernetesWatchTrigger
|
||||
func (c *kubernetesWatchTriggerClient) Create(obj *fv1.KubernetesWatchTrigger) (*fv1.KubernetesWatchTrigger, error) {
|
||||
var result fv1.KubernetesWatchTrigger
|
||||
err := c.client.Post().
|
||||
Resource("kuberneteswatchtriggers").
|
||||
Namespace(c.namespace).
|
||||
@@ -59,8 +61,8 @@ func (c *kubernetesWatchTriggerClient) Create(obj *KubernetesWatchTrigger) (*Kub
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *kubernetesWatchTriggerClient) Get(name string) (*KubernetesWatchTrigger, error) {
|
||||
var result KubernetesWatchTrigger
|
||||
func (c *kubernetesWatchTriggerClient) Get(name string) (*fv1.KubernetesWatchTrigger, error) {
|
||||
var result fv1.KubernetesWatchTrigger
|
||||
err := c.client.Get().
|
||||
Resource("kuberneteswatchtriggers").
|
||||
Namespace(c.namespace).
|
||||
@@ -72,8 +74,8 @@ func (c *kubernetesWatchTriggerClient) Get(name string) (*KubernetesWatchTrigger
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *kubernetesWatchTriggerClient) Update(obj *KubernetesWatchTrigger) (*KubernetesWatchTrigger, error) {
|
||||
var result KubernetesWatchTrigger
|
||||
func (c *kubernetesWatchTriggerClient) Update(obj *fv1.KubernetesWatchTrigger) (*fv1.KubernetesWatchTrigger, error) {
|
||||
var result fv1.KubernetesWatchTrigger
|
||||
err := c.client.Put().
|
||||
Resource("kuberneteswatchtriggers").
|
||||
Namespace(c.namespace).
|
||||
@@ -96,8 +98,8 @@ func (c *kubernetesWatchTriggerClient) Delete(name string, opts *metav1.DeleteOp
|
||||
Error()
|
||||
}
|
||||
|
||||
func (c *kubernetesWatchTriggerClient) List(opts metav1.ListOptions) (*KubernetesWatchTriggerList, error) {
|
||||
var result KubernetesWatchTriggerList
|
||||
func (c *kubernetesWatchTriggerClient) List(opts metav1.ListOptions) (*fv1.KubernetesWatchTriggerList, error) {
|
||||
var result fv1.KubernetesWatchTriggerList
|
||||
err := c.client.Get().
|
||||
Namespace(c.namespace).
|
||||
Resource("kuberneteswatchtriggers").
|
||||
@@ -21,15 +21,17 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
MessageQueueTriggerInterface interface {
|
||||
Create(*MessageQueueTrigger) (*MessageQueueTrigger, error)
|
||||
Get(name string) (*MessageQueueTrigger, error)
|
||||
Update(*MessageQueueTrigger) (*MessageQueueTrigger, error)
|
||||
Create(*fv1.MessageQueueTrigger) (*fv1.MessageQueueTrigger, error)
|
||||
Get(name string) (*fv1.MessageQueueTrigger, error)
|
||||
Update(*fv1.MessageQueueTrigger) (*fv1.MessageQueueTrigger, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*MessageQueueTriggerList, error)
|
||||
List(opts metav1.ListOptions) (*fv1.MessageQueueTriggerList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ func MakeMessageQueueTriggerInterface(crdClient *rest.RESTClient, namespace stri
|
||||
}
|
||||
}
|
||||
|
||||
func (fc *messageQueueTriggerClient) Create(f *MessageQueueTrigger) (*MessageQueueTrigger, error) {
|
||||
var result MessageQueueTrigger
|
||||
func (fc *messageQueueTriggerClient) Create(f *fv1.MessageQueueTrigger) (*fv1.MessageQueueTrigger, error) {
|
||||
var result fv1.MessageQueueTrigger
|
||||
err := fc.client.Post().
|
||||
Resource("messagequeuetriggers").
|
||||
Namespace(fc.namespace).
|
||||
@@ -59,8 +61,8 @@ func (fc *messageQueueTriggerClient) Create(f *MessageQueueTrigger) (*MessageQue
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (fc *messageQueueTriggerClient) Get(name string) (*MessageQueueTrigger, error) {
|
||||
var result MessageQueueTrigger
|
||||
func (fc *messageQueueTriggerClient) Get(name string) (*fv1.MessageQueueTrigger, error) {
|
||||
var result fv1.MessageQueueTrigger
|
||||
err := fc.client.Get().
|
||||
Resource("messagequeuetriggers").
|
||||
Namespace(fc.namespace).
|
||||
@@ -72,8 +74,8 @@ func (fc *messageQueueTriggerClient) Get(name string) (*MessageQueueTrigger, err
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (fc *messageQueueTriggerClient) Update(f *MessageQueueTrigger) (*MessageQueueTrigger, error) {
|
||||
var result MessageQueueTrigger
|
||||
func (fc *messageQueueTriggerClient) Update(f *fv1.MessageQueueTrigger) (*fv1.MessageQueueTrigger, error) {
|
||||
var result fv1.MessageQueueTrigger
|
||||
err := fc.client.Put().
|
||||
Resource("messagequeuetriggers").
|
||||
Namespace(fc.namespace).
|
||||
@@ -96,8 +98,8 @@ func (fc *messageQueueTriggerClient) Delete(name string, opts *metav1.DeleteOpti
|
||||
Error()
|
||||
}
|
||||
|
||||
func (fc *messageQueueTriggerClient) List(opts metav1.ListOptions) (*MessageQueueTriggerList, error) {
|
||||
var result MessageQueueTriggerList
|
||||
func (fc *messageQueueTriggerClient) List(opts metav1.ListOptions) (*fv1.MessageQueueTriggerList, error) {
|
||||
var result fv1.MessageQueueTriggerList
|
||||
err := fc.client.Get().
|
||||
Namespace(fc.namespace).
|
||||
Resource("messagequeuetriggers").
|
||||
@@ -21,15 +21,17 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
PackageInterface interface {
|
||||
Create(*Package) (*Package, error)
|
||||
Get(name string) (*Package, error)
|
||||
Update(*Package) (*Package, error)
|
||||
Create(*fv1.Package) (*fv1.Package, error)
|
||||
Get(name string) (*fv1.Package, error)
|
||||
Update(*fv1.Package) (*fv1.Package, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*PackageList, error)
|
||||
List(opts metav1.ListOptions) (*fv1.PackageList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ func MakePackageInterface(crdClient *rest.RESTClient, namespace string) PackageI
|
||||
}
|
||||
}
|
||||
|
||||
func (c *packageClient) Create(f *Package) (*Package, error) {
|
||||
var result Package
|
||||
func (c *packageClient) Create(f *fv1.Package) (*fv1.Package, error) {
|
||||
var result fv1.Package
|
||||
err := c.client.Post().
|
||||
Resource("packages").
|
||||
Namespace(c.namespace).
|
||||
@@ -59,8 +61,8 @@ func (c *packageClient) Create(f *Package) (*Package, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *packageClient) Get(name string) (*Package, error) {
|
||||
var result Package
|
||||
func (c *packageClient) Get(name string) (*fv1.Package, error) {
|
||||
var result fv1.Package
|
||||
err := c.client.Get().
|
||||
Resource("packages").
|
||||
Namespace(c.namespace).
|
||||
@@ -72,8 +74,8 @@ func (c *packageClient) Get(name string) (*Package, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (c *packageClient) Update(f *Package) (*Package, error) {
|
||||
var result Package
|
||||
func (c *packageClient) Update(f *fv1.Package) (*fv1.Package, error) {
|
||||
var result fv1.Package
|
||||
err := c.client.Put().
|
||||
Resource("packages").
|
||||
Namespace(c.namespace).
|
||||
@@ -96,8 +98,8 @@ func (c *packageClient) Delete(name string, opts *metav1.DeleteOptions) error {
|
||||
Error()
|
||||
}
|
||||
|
||||
func (c *packageClient) List(opts metav1.ListOptions) (*PackageList, error) {
|
||||
var result PackageList
|
||||
func (c *packageClient) List(opts metav1.ListOptions) (*fv1.PackageList, error) {
|
||||
var result fv1.PackageList
|
||||
err := c.client.Get().
|
||||
Namespace(c.namespace).
|
||||
Resource("packages").
|
||||
@@ -21,15 +21,17 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
RecorderInterface interface {
|
||||
Create(*Recorder) (*Recorder, error)
|
||||
Get(name string) (*Recorder, error)
|
||||
Update(*Recorder) (*Recorder, error)
|
||||
Create(*fv1.Recorder) (*fv1.Recorder, error)
|
||||
Get(name string) (*fv1.Recorder, error)
|
||||
Update(*fv1.Recorder) (*fv1.Recorder, error)
|
||||
Delete(name string, opts *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*RecorderList, error)
|
||||
List(opts metav1.ListOptions) (*fv1.RecorderList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ func MakeRecorderInterface(crdClient *rest.RESTClient, namespace string) Recorde
|
||||
}
|
||||
}
|
||||
|
||||
func (rc *recorderClient) Create(r *Recorder) (*Recorder, error) {
|
||||
var result Recorder
|
||||
func (rc *recorderClient) Create(r *fv1.Recorder) (*fv1.Recorder, error) {
|
||||
var result fv1.Recorder
|
||||
err := rc.client.Post().
|
||||
Resource("recorders").
|
||||
Namespace("default").
|
||||
@@ -59,8 +61,8 @@ func (rc *recorderClient) Create(r *Recorder) (*Recorder, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (rc *recorderClient) Get(name string) (*Recorder, error) {
|
||||
var result Recorder
|
||||
func (rc *recorderClient) Get(name string) (*fv1.Recorder, error) {
|
||||
var result fv1.Recorder
|
||||
err := rc.client.Get().
|
||||
Resource("recorders").
|
||||
Namespace(rc.namespace).
|
||||
@@ -72,8 +74,8 @@ func (rc *recorderClient) Get(name string) (*Recorder, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (rc *recorderClient) Update(r *Recorder) (*Recorder, error) {
|
||||
var result Recorder
|
||||
func (rc *recorderClient) Update(r *fv1.Recorder) (*fv1.Recorder, error) {
|
||||
var result fv1.Recorder
|
||||
err := rc.client.Put().
|
||||
Resource("recorders").
|
||||
Namespace(rc.namespace).
|
||||
@@ -96,8 +98,8 @@ func (rc *recorderClient) Delete(name string, opts *metav1.DeleteOptions) error
|
||||
Error()
|
||||
}
|
||||
|
||||
func (rc *recorderClient) List(opts metav1.ListOptions) (*RecorderList, error) {
|
||||
var result RecorderList
|
||||
func (rc *recorderClient) List(opts metav1.ListOptions) (*fv1.RecorderList, error) {
|
||||
var result fv1.RecorderList
|
||||
err := rc.client.Get().
|
||||
Namespace(rc.namespace).
|
||||
Resource("recorders").
|
||||
@@ -21,15 +21,17 @@ import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type (
|
||||
TimeTriggerInterface interface {
|
||||
Create(*TimeTrigger) (*TimeTrigger, error)
|
||||
Get(name string) (*TimeTrigger, error)
|
||||
Update(*TimeTrigger) (*TimeTrigger, error)
|
||||
Create(*fv1.TimeTrigger) (*fv1.TimeTrigger, error)
|
||||
Get(name string) (*fv1.TimeTrigger, error)
|
||||
Update(*fv1.TimeTrigger) (*fv1.TimeTrigger, error)
|
||||
Delete(name string, options *metav1.DeleteOptions) error
|
||||
List(opts metav1.ListOptions) (*TimeTriggerList, error)
|
||||
List(opts metav1.ListOptions) (*fv1.TimeTriggerList, error)
|
||||
Watch(opts metav1.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -46,8 +48,8 @@ func MakeTimeTriggerInterface(crdClient *rest.RESTClient, namespace string) Time
|
||||
}
|
||||
}
|
||||
|
||||
func (fc *timeTriggerClient) Create(f *TimeTrigger) (*TimeTrigger, error) {
|
||||
var result TimeTrigger
|
||||
func (fc *timeTriggerClient) Create(f *fv1.TimeTrigger) (*fv1.TimeTrigger, error) {
|
||||
var result fv1.TimeTrigger
|
||||
err := fc.client.Post().
|
||||
Resource("timetriggers").
|
||||
Namespace(fc.namespace).
|
||||
@@ -59,8 +61,8 @@ func (fc *timeTriggerClient) Create(f *TimeTrigger) (*TimeTrigger, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (fc *timeTriggerClient) Get(name string) (*TimeTrigger, error) {
|
||||
var result TimeTrigger
|
||||
func (fc *timeTriggerClient) Get(name string) (*fv1.TimeTrigger, error) {
|
||||
var result fv1.TimeTrigger
|
||||
err := fc.client.Get().
|
||||
Resource("timetriggers").
|
||||
Namespace(fc.namespace).
|
||||
@@ -72,8 +74,8 @@ func (fc *timeTriggerClient) Get(name string) (*TimeTrigger, error) {
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (fc *timeTriggerClient) Update(f *TimeTrigger) (*TimeTrigger, error) {
|
||||
var result TimeTrigger
|
||||
func (fc *timeTriggerClient) Update(f *fv1.TimeTrigger) (*fv1.TimeTrigger, error) {
|
||||
var result fv1.TimeTrigger
|
||||
err := fc.client.Put().
|
||||
Resource("timetriggers").
|
||||
Namespace(fc.namespace).
|
||||
@@ -96,8 +98,8 @@ func (fc *timeTriggerClient) Delete(name string, opts *metav1.DeleteOptions) err
|
||||
Error()
|
||||
}
|
||||
|
||||
func (fc *timeTriggerClient) List(opts metav1.ListOptions) (*TimeTriggerList, error) {
|
||||
var result TimeTriggerList
|
||||
func (fc *timeTriggerClient) List(opts metav1.ListOptions) (*fv1.TimeTriggerList, error) {
|
||||
var result fv1.TimeTriggerList
|
||||
err := fc.client.Get().
|
||||
Namespace(fc.namespace).
|
||||
Resource("timetriggers").
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fission
|
||||
package error
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -23,6 +23,16 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type (
|
||||
// Errors returned by the Fission API.
|
||||
Error struct {
|
||||
Code errorCode `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
errorCode int
|
||||
)
|
||||
|
||||
func (err Error) Error() string {
|
||||
return fmt.Sprintf("%v - %v", err.Description(), err.Message)
|
||||
}
|
||||
@@ -98,3 +108,29 @@ func (err Error) Description() string {
|
||||
}
|
||||
return errorDescriptions[idx]
|
||||
}
|
||||
|
||||
const (
|
||||
ErrorInternal = iota
|
||||
|
||||
ErrorNotAuthorized
|
||||
ErrorNotFound
|
||||
ErrorNameExists
|
||||
ErrorInvalidArgument
|
||||
ErrorNoSpace
|
||||
ErrorNotImplmented
|
||||
ErrorChecksumFail
|
||||
ErrorSizeLimitExceeded
|
||||
)
|
||||
|
||||
// must match order and len of the above const
|
||||
var errorDescriptions = []string{
|
||||
"Internal error",
|
||||
"Not authorized",
|
||||
"Resource not found",
|
||||
"Resource exists",
|
||||
"Invalid argument",
|
||||
"No space",
|
||||
"Not implemented",
|
||||
"Checksum verification failed",
|
||||
"Size limit exceeded",
|
||||
}
|
||||
@@ -24,12 +24,13 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
"github.com/gorilla/mux"
|
||||
"go.opencensus.io/plugin/ochttp"
|
||||
"go.uber.org/zap"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
func (executor *Executor) getServiceForFunctionApi(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -49,7 +50,7 @@ func (executor *Executor) getServiceForFunctionApi(w http.ResponseWriter, r *htt
|
||||
|
||||
serviceName, err := executor.getServiceForFunction(r.Context(), &m)
|
||||
if err != nil {
|
||||
code, msg := fission.GetHTTPError(err)
|
||||
code, msg := ferror.GetHTTPError(err)
|
||||
executor.logger.Error("error getting service for function",
|
||||
zap.Error(err),
|
||||
zap.String("function", m.Name),
|
||||
@@ -140,7 +141,7 @@ func (executor *Executor) Serve(port int) {
|
||||
defer cancel()
|
||||
executor.ndm.Run(ctx)
|
||||
executor.gpm.Run(ctx)
|
||||
r.Use(fission.LoggingMiddleware(executor.logger))
|
||||
r.Use(utils.LoggingMiddleware(executor.logger))
|
||||
err := http.ListenAndServe(address, &ochttp.Handler{
|
||||
Handler: r,
|
||||
// Propagation: &b3.HTTPFormat{},
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
"golang.org/x/net/context/ctxhttp"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
@@ -72,7 +72,7 @@ func (c *Client) GetServiceForFunction(ctx context.Context, metadata *metav1.Obj
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return "", fission.MakeErrorFromHTTP(resp)
|
||||
return "", ferror.MakeErrorFromHTTP(resp)
|
||||
}
|
||||
|
||||
svcName, err := ioutil.ReadAll(resp.Body)
|
||||
@@ -120,7 +120,7 @@ func (c *Client) _tapService(serviceUrlStr string) error {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return fission.MakeErrorFromHTTP(resp)
|
||||
return ferror.MakeErrorFromHTTP(resp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -30,13 +30,14 @@ import (
|
||||
"go.uber.org/zap"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fetcherConfig "github.com/fission/fission/environments/fetcher/config"
|
||||
"github.com/fission/fission/executor/fscache"
|
||||
"github.com/fission/fission/executor/newdeploy"
|
||||
"github.com/fission/fission/executor/poolmgr"
|
||||
"github.com/fission/fission/executor/reaper"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/executor/fscache"
|
||||
"github.com/fission/fission/pkg/executor/newdeploy"
|
||||
"github.com/fission/fission/pkg/executor/poolmgr"
|
||||
"github.com/fission/fission/pkg/executor/reaper"
|
||||
fetcherConfig "github.com/fission/fission/pkg/fetcher/config"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -137,7 +138,7 @@ func (executor *Executor) serveCreateFuncServices() {
|
||||
}
|
||||
}
|
||||
|
||||
func (executor *Executor) getFunctionExecutorType(meta *metav1.ObjectMeta) (fission.ExecutorType, error) {
|
||||
func (executor *Executor) getFunctionExecutorType(meta *metav1.ObjectMeta) (fv1.ExecutorType, error) {
|
||||
fn, err := executor.fissionClient.Functions(meta.Namespace).Get(meta.Name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -159,7 +160,7 @@ func (executor *Executor) createServiceForFunction(ctx context.Context, meta *me
|
||||
var fsvcErr error
|
||||
|
||||
switch executorType {
|
||||
case fission.ExecutorTypeNewdeploy:
|
||||
case fv1.ExecutorTypeNewdeploy:
|
||||
fsvc, fsvcErr = executor.ndm.GetFuncSvc(ctx, meta)
|
||||
default:
|
||||
fsvc, fsvcErr = executor.gpm.GetFuncSvc(ctx, meta)
|
||||
@@ -206,7 +207,7 @@ func serveMetric(logger *zap.Logger) {
|
||||
// deploymgr and potential future executor types
|
||||
func StartExecutor(logger *zap.Logger, fissionNamespace string, functionNamespace string, envBuilderNamespace string, port int) error {
|
||||
// setup a signal handler for SIGTERM
|
||||
fission.SetupStackTraceHandler()
|
||||
utils.SetupStackTraceHandler()
|
||||
|
||||
fissionClient, kubernetesClient, _, err := crd.MakeFissionClient()
|
||||
|
||||
@@ -40,9 +40,9 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/executor/client"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/executor/client"
|
||||
)
|
||||
|
||||
func panicIf(err error) {
|
||||
@@ -53,7 +53,7 @@ func panicIf(err error) {
|
||||
|
||||
// return the number of pods in the given namespace matching the given labels
|
||||
func countPods(kubeClient *kubernetes.Clientset, ns string, labelz map[string]string) int {
|
||||
pods, err := kubeClient.Pods(ns).List(metav1.ListOptions{
|
||||
pods, err := kubeClient.CoreV1().Pods(ns).List(metav1.ListOptions{
|
||||
LabelSelector: labels.Set(labelz).AsSelector().String(),
|
||||
})
|
||||
if err != nil {
|
||||
@@ -63,7 +63,7 @@ func countPods(kubeClient *kubernetes.Clientset, ns string, labelz map[string]st
|
||||
}
|
||||
|
||||
func createTestNamespace(kubeClient *kubernetes.Clientset, ns string) {
|
||||
_, err := kubeClient.Namespaces().Create(&apiv1.Namespace{
|
||||
_, err := kubeClient.CoreV1().Namespaces().Create(&apiv1.Namespace{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: ns,
|
||||
},
|
||||
@@ -76,7 +76,7 @@ func createTestNamespace(kubeClient *kubernetes.Clientset, ns string) {
|
||||
|
||||
// create a nodeport service
|
||||
func createSvc(kubeClient *kubernetes.Clientset, ns string, name string, targetPort int, nodePort int32, labels map[string]string) *apiv1.Service {
|
||||
svc, err := kubeClient.Services(ns).Create(&apiv1.Service{
|
||||
svc, err := kubeClient.CoreV1().Services(ns).Create(&apiv1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
},
|
||||
@@ -136,10 +136,10 @@ func TestExecutor(t *testing.T) {
|
||||
|
||||
// create the test's namespaces
|
||||
createTestNamespace(kubeClient, fissionNs)
|
||||
defer kubeClient.Namespaces().Delete(fissionNs, nil)
|
||||
defer kubeClient.CoreV1().Namespaces().Delete(fissionNs, nil)
|
||||
|
||||
createTestNamespace(kubeClient, functionNs)
|
||||
defer kubeClient.Namespaces().Delete(functionNs, nil)
|
||||
defer kubeClient.CoreV1().Namespaces().Delete(functionNs, nil)
|
||||
|
||||
logger, err := zap.NewDevelopment()
|
||||
panicIf(err)
|
||||
@@ -156,17 +156,17 @@ func TestExecutor(t *testing.T) {
|
||||
}
|
||||
|
||||
// create an env on the cluster
|
||||
env, err := fissionClient.Environments(fissionNs).Create(&crd.Environment{
|
||||
env, err := fissionClient.Environments(fissionNs).Create(&fv1.Environment{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "nodejs",
|
||||
Namespace: fissionNs,
|
||||
},
|
||||
Spec: fission.EnvironmentSpec{
|
||||
Spec: fv1.EnvironmentSpec{
|
||||
Version: 1,
|
||||
Runtime: fission.Runtime{
|
||||
Runtime: fv1.Runtime{
|
||||
Image: "fission/node-env",
|
||||
},
|
||||
Builder: fission.Builder{},
|
||||
Builder: fv1.Builder{},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -188,23 +188,23 @@ func TestExecutor(t *testing.T) {
|
||||
// waitForPool(functionNs, "nodejs")
|
||||
time.Sleep(6 * time.Second)
|
||||
|
||||
envRef := fission.EnvironmentReference{
|
||||
envRef := fv1.EnvironmentReference{
|
||||
Namespace: env.Metadata.Namespace,
|
||||
Name: env.Metadata.Name,
|
||||
}
|
||||
|
||||
deployment := fission.Archive{
|
||||
Type: fission.ArchiveTypeLiteral,
|
||||
deployment := fv1.Archive{
|
||||
Type: fv1.ArchiveTypeLiteral,
|
||||
Literal: []byte(`module.exports = async function(context) { return { status: 200, body: "Hello, world!\n" }; }`),
|
||||
}
|
||||
|
||||
// create a package
|
||||
p := &crd.Package{
|
||||
p := &fv1.Package{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "hello",
|
||||
Namespace: fissionNs,
|
||||
},
|
||||
Spec: fission.PackageSpec{
|
||||
Spec: fv1.PackageSpec{
|
||||
Environment: envRef,
|
||||
Deployment: deployment,
|
||||
},
|
||||
@@ -215,15 +215,15 @@ func TestExecutor(t *testing.T) {
|
||||
}
|
||||
|
||||
// create a function
|
||||
f := &crd.Function{
|
||||
f := &fv1.Function{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "hello",
|
||||
Namespace: fissionNs,
|
||||
},
|
||||
Spec: fission.FunctionSpec{
|
||||
Spec: fv1.FunctionSpec{
|
||||
Environment: envRef,
|
||||
Package: fission.FunctionPackageRef{
|
||||
PackageRef: fission.PackageRef{
|
||||
Package: fv1.FunctionPackageRef{
|
||||
PackageRef: fv1.PackageRef{
|
||||
Namespace: p.Metadata.Namespace,
|
||||
Name: p.Metadata.Name,
|
||||
ResourceVersion: p.Metadata.ResourceVersion,
|
||||
@@ -240,11 +240,11 @@ func TestExecutor(t *testing.T) {
|
||||
labels := map[string]string{"functionName": f.Metadata.Name}
|
||||
var fetcherPort int32 = 30001
|
||||
fetcherSvc := createSvc(kubeClient, functionNs, fmt.Sprintf("%v-%v", f.Metadata.Name, "fetcher"), 8000, fetcherPort, labels)
|
||||
defer kubeClient.Services(functionNs).Delete(fetcherSvc.ObjectMeta.Name, nil)
|
||||
defer kubeClient.CoreV1().Services(functionNs).Delete(fetcherSvc.ObjectMeta.Name, nil)
|
||||
|
||||
var funcSvcPort int32 = 30002
|
||||
functionSvc := createSvc(kubeClient, functionNs, f.Metadata.Name, 8888, funcSvcPort, labels)
|
||||
defer kubeClient.Services(functionNs).Delete(functionSvc.ObjectMeta.Name, nil)
|
||||
defer kubeClient.CoreV1().Services(functionNs).Delete(functionSvc.ObjectMeta.Name, nil)
|
||||
|
||||
// the main test: get a service for a given function
|
||||
t1 := time.Now()
|
||||
+9
-8
@@ -26,9 +26,10 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/cache"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/cache"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
)
|
||||
|
||||
type fscRequestType int
|
||||
@@ -49,7 +50,7 @@ type (
|
||||
FuncSvc struct {
|
||||
Name string // Name of object
|
||||
Function *metav1.ObjectMeta // function this pod/service is for
|
||||
Environment *crd.Environment // function's environment
|
||||
Environment *fv1.Environment // function's environment
|
||||
Address string // Host:Port or IP:Port that the function's service can be reached at.
|
||||
KubernetesObjects []apiv1.ObjectReference // Kubernetes Objects (within the function namespace)
|
||||
Executor executorType
|
||||
@@ -81,15 +82,15 @@ type (
|
||||
)
|
||||
|
||||
func IsNotFoundError(err error) bool {
|
||||
if fe, ok := err.(fission.Error); ok {
|
||||
return fe.Code == fission.ErrorNotFound
|
||||
if fe, ok := err.(ferror.Error); ok {
|
||||
return fe.Code == ferror.ErrorNotFound
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsNameExistError(err error) bool {
|
||||
if fe, ok := err.(fission.Error); ok {
|
||||
return fe.Code == fission.ErrorNameExists
|
||||
if fe, ok := err.(ferror.Error); ok {
|
||||
return fe.Code == ferror.ErrorNameExists
|
||||
}
|
||||
return false
|
||||
}
|
||||
+6
-7
@@ -9,8 +9,7 @@ import (
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
func panicIf(err error) {
|
||||
@@ -51,17 +50,17 @@ func TestFunctionServiceCache(t *testing.T) {
|
||||
Name: "foo",
|
||||
UID: "1212",
|
||||
},
|
||||
Environment: &crd.Environment{
|
||||
Environment: &fv1.Environment{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: "foo-env",
|
||||
UID: "2323",
|
||||
},
|
||||
Spec: fission.EnvironmentSpec{
|
||||
Spec: fv1.EnvironmentSpec{
|
||||
Version: 1,
|
||||
Runtime: fission.Runtime{
|
||||
Runtime: fv1.Runtime{
|
||||
Image: "fission/foo-env",
|
||||
},
|
||||
Builder: fission.Builder{},
|
||||
Builder: fv1.Builder{},
|
||||
},
|
||||
},
|
||||
Address: "xxx",
|
||||
@@ -69,7 +68,7 @@ func TestFunctionServiceCache(t *testing.T) {
|
||||
Ctime: now,
|
||||
Atime: now,
|
||||
}
|
||||
_, err := fsc.Add(*fsvc)
|
||||
_, err = fsc.Add(*fsvc)
|
||||
if err != nil {
|
||||
fsc.Log()
|
||||
log.Panicf("Failed to add fsvc: %v", err)
|
||||
@@ -21,6 +21,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/fission/fission/pkg/types"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"go.uber.org/zap"
|
||||
asv1 "k8s.io/api/autoscaling/v1"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
@@ -30,10 +33,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/executor/util"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/executor/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -41,7 +42,7 @@ const (
|
||||
DeploymentVersion = "extensions/v1beta1"
|
||||
)
|
||||
|
||||
func (deploy *NewDeploy) createOrGetDeployment(fn *crd.Function, env *crd.Environment,
|
||||
func (deploy *NewDeploy) createOrGetDeployment(fn *fv1.Function, env *fv1.Environment,
|
||||
deployName string, deployLabels map[string]string, deployNamespace string, firstcreate bool) (*v1beta1.Deployment, error) {
|
||||
|
||||
minScale := int32(fn.Spec.InvokeStrategy.ExecutionStrategy.MinScale)
|
||||
@@ -102,13 +103,13 @@ func (deploy *NewDeploy) createOrGetDeployment(fn *crd.Function, env *crd.Enviro
|
||||
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) setupRBACObjs(deployNamespace string, fn *crd.Function) error {
|
||||
func (deploy *NewDeploy) setupRBACObjs(deployNamespace string, fn *fv1.Function) error {
|
||||
// create fetcher SA in this ns, if not already created
|
||||
err := deploy.fetcherConfig.SetupServiceAccount(deploy.kubernetesClient, deployNamespace, fn.Metadata)
|
||||
if err != nil {
|
||||
deploy.logger.Error("error creating fission fetcher service account for function",
|
||||
zap.Error(err),
|
||||
zap.String("service_account_name", fission.FissionFetcherSA),
|
||||
zap.String("service_account_name", types.FissionFetcherSA),
|
||||
zap.String("service_account_namespace", deployNamespace),
|
||||
zap.String("function_name", fn.Metadata.Name),
|
||||
zap.String("function_namespace", fn.Metadata.Namespace))
|
||||
@@ -116,22 +117,22 @@ func (deploy *NewDeploy) setupRBACObjs(deployNamespace string, fn *crd.Function)
|
||||
}
|
||||
|
||||
// create a cluster role binding for the fetcher SA, if not already created, granting access to do a get on packages in any ns
|
||||
err = fission.SetupRoleBinding(deploy.logger, deploy.kubernetesClient, fission.PackageGetterRB, fn.Spec.Package.PackageRef.Namespace, fission.PackageGetterCR, fission.ClusterRole, fission.FissionFetcherSA, deployNamespace)
|
||||
err = utils.SetupRoleBinding(deploy.logger, deploy.kubernetesClient, types.PackageGetterRB, fn.Spec.Package.PackageRef.Namespace, types.PackageGetterCR, types.ClusterRole, types.FissionFetcherSA, deployNamespace)
|
||||
if err != nil {
|
||||
deploy.logger.Error("error creating role binding for function",
|
||||
zap.Error(err),
|
||||
zap.String("role_binding", fission.PackageGetterRB),
|
||||
zap.String("role_binding", types.PackageGetterRB),
|
||||
zap.String("function_name", fn.Metadata.Name),
|
||||
zap.String("function_namespace", fn.Metadata.Namespace))
|
||||
return err
|
||||
}
|
||||
|
||||
// create rolebinding in function namespace for fetcherSA.envNamespace to be able to get secrets and configmaps
|
||||
err = fission.SetupRoleBinding(deploy.logger, deploy.kubernetesClient, fission.SecretConfigMapGetterRB, fn.Metadata.Namespace, fission.SecretConfigMapGetterCR, fission.ClusterRole, fission.FissionFetcherSA, deployNamespace)
|
||||
err = utils.SetupRoleBinding(deploy.logger, deploy.kubernetesClient, types.SecretConfigMapGetterRB, fn.Metadata.Namespace, types.SecretConfigMapGetterCR, types.ClusterRole, types.FissionFetcherSA, deployNamespace)
|
||||
if err != nil {
|
||||
deploy.logger.Error("error creating role binding for function",
|
||||
zap.Error(err),
|
||||
zap.String("role_binding", fission.SecretConfigMapGetterRB),
|
||||
zap.String("role_binding", types.SecretConfigMapGetterRB),
|
||||
zap.String("function_name", fn.Metadata.Name),
|
||||
zap.String("function_namespace", fn.Metadata.Namespace))
|
||||
return err
|
||||
@@ -165,7 +166,7 @@ func (deploy *NewDeploy) deleteDeployment(ns string, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) getDeploymentSpec(fn *crd.Function, env *crd.Environment,
|
||||
func (deploy *NewDeploy) getDeploymentSpec(fn *fv1.Function, env *fv1.Environment,
|
||||
deployName string, deployLabels map[string]string) (*v1beta1.Deployment, error) {
|
||||
|
||||
replicas := int32(fn.Spec.InvokeStrategy.ExecutionStrategy.MinScale)
|
||||
@@ -249,7 +250,7 @@ func (deploy *NewDeploy) getDeploymentSpec(fn *crd.Function, env *crd.Environmen
|
||||
|
||||
// getResources overrides only the resources which are overridden at function level otherwise
|
||||
// default to resources specified at environment level
|
||||
func (deploy *NewDeploy) getResources(env *crd.Environment, fn *crd.Function) apiv1.ResourceRequirements {
|
||||
func (deploy *NewDeploy) getResources(env *fv1.Environment, fn *fv1.Function) apiv1.ResourceRequirements {
|
||||
resources := env.Spec.Resources
|
||||
if resources.Requests == nil {
|
||||
resources.Requests = make(map[apiv1.ResourceName]resource.Quantity)
|
||||
@@ -281,7 +282,7 @@ func (deploy *NewDeploy) getResources(env *crd.Environment, fn *crd.Function) ap
|
||||
return resources
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) createOrGetHpa(hpaName string, execStrategy *fission.ExecutionStrategy, depl *v1beta1.Deployment) (*asv1.HorizontalPodAutoscaler, error) {
|
||||
func (deploy *NewDeploy) createOrGetHpa(hpaName string, execStrategy *fv1.ExecutionStrategy, depl *v1beta1.Deployment) (*asv1.HorizontalPodAutoscaler, error) {
|
||||
|
||||
minRepl := int32(execStrategy.MinScale)
|
||||
if minRepl == 0 {
|
||||
@@ -25,7 +25,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
"github.com/fission/fission/throttler"
|
||||
"github.com/fission/fission/pkg/throttler"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
@@ -34,15 +35,16 @@ import (
|
||||
k8sErrs "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
k8sTypes "k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fetcherConfig "github.com/fission/fission/environments/fetcher/config"
|
||||
"github.com/fission/fission/executor/fscache"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/executor/fscache"
|
||||
fetcherConfig "github.com/fission/fission/pkg/fetcher/config"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -107,7 +109,7 @@ func MakeNewDeploy(
|
||||
throttler: throttler.MakeThrottler(1 * time.Minute),
|
||||
|
||||
fetcherConfig: fetcherConfig,
|
||||
runtimeImagePullPolicy: fission.GetImagePullPolicy(os.Getenv("RUNTIME_IMAGE_PULL_POLICY")),
|
||||
runtimeImagePullPolicy: utils.GetImagePullPolicy(os.Getenv("RUNTIME_IMAGE_PULL_POLICY")),
|
||||
useIstio: enableIstio,
|
||||
|
||||
idlePodReapTime: 2 * time.Minute,
|
||||
@@ -136,9 +138,9 @@ func (deploy *NewDeploy) Run(ctx context.Context) {
|
||||
func (deploy *NewDeploy) initFuncController() (k8sCache.Store, k8sCache.Controller) {
|
||||
resyncPeriod := 30 * time.Second
|
||||
listWatch := k8sCache.NewListWatchFromClient(deploy.crdClient, "functions", metav1.NamespaceAll, fields.Everything())
|
||||
store, controller := k8sCache.NewInformer(listWatch, &crd.Function{}, resyncPeriod, k8sCache.ResourceEventHandlerFuncs{
|
||||
store, controller := k8sCache.NewInformer(listWatch, &fv1.Function{}, resyncPeriod, k8sCache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
fn := obj.(*crd.Function)
|
||||
fn := obj.(*fv1.Function)
|
||||
_, err := deploy.createFunction(fn, true)
|
||||
if err != nil {
|
||||
deploy.logger.Error("error eager creating function",
|
||||
@@ -147,7 +149,7 @@ func (deploy *NewDeploy) initFuncController() (k8sCache.Store, k8sCache.Controll
|
||||
}
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
fn := obj.(*crd.Function)
|
||||
fn := obj.(*fv1.Function)
|
||||
err := deploy.deleteFunction(fn)
|
||||
if err != nil {
|
||||
deploy.logger.Error("error deleting function",
|
||||
@@ -156,8 +158,8 @@ func (deploy *NewDeploy) initFuncController() (k8sCache.Store, k8sCache.Controll
|
||||
}
|
||||
},
|
||||
UpdateFunc: func(oldObj interface{}, newObj interface{}) {
|
||||
oldFn := oldObj.(*crd.Function)
|
||||
newFn := newObj.(*crd.Function)
|
||||
oldFn := oldObj.(*fv1.Function)
|
||||
newFn := newObj.(*fv1.Function)
|
||||
err := deploy.updateFunction(oldFn, newFn)
|
||||
if err != nil {
|
||||
deploy.logger.Error("error updating function",
|
||||
@@ -173,12 +175,12 @@ func (deploy *NewDeploy) initFuncController() (k8sCache.Store, k8sCache.Controll
|
||||
func (deploy *NewDeploy) initEnvController() (k8sCache.Store, k8sCache.Controller) {
|
||||
resyncPeriod := 30 * time.Second
|
||||
listWatch := k8sCache.NewListWatchFromClient(deploy.crdClient, "environments", metav1.NamespaceAll, fields.Everything())
|
||||
store, controller := k8sCache.NewInformer(listWatch, &crd.Environment{}, resyncPeriod, k8sCache.ResourceEventHandlerFuncs{
|
||||
store, controller := k8sCache.NewInformer(listWatch, &fv1.Environment{}, resyncPeriod, k8sCache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {},
|
||||
DeleteFunc: func(obj interface{}) {},
|
||||
UpdateFunc: func(oldObj interface{}, newObj interface{}) {
|
||||
newEnv := newObj.(*crd.Environment)
|
||||
oldEnv := oldObj.(*crd.Environment)
|
||||
newEnv := newObj.(*fv1.Environment)
|
||||
oldEnv := oldObj.(*fv1.Environment)
|
||||
// Currently only an image update in environment calls for function's deployment recreation. In future there might be more attributes which would want to do it
|
||||
if oldEnv.Spec.Runtime.Image != newEnv.Spec.Runtime.Image {
|
||||
deploy.logger.Info("Updating all function of the environment that changed, old env:", zap.Any("environment", oldEnv))
|
||||
@@ -199,12 +201,12 @@ func (deploy *NewDeploy) initEnvController() (k8sCache.Store, k8sCache.Controlle
|
||||
return store, controller
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) getEnvFunctions(m *metav1.ObjectMeta) []crd.Function {
|
||||
func (deploy *NewDeploy) getEnvFunctions(m *metav1.ObjectMeta) []fv1.Function {
|
||||
funcList, err := deploy.fissionClient.Functions(m.Namespace).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
deploy.logger.Error("Error getting functions for env", zap.Error(err), zap.Any("environment", m))
|
||||
}
|
||||
relatedFunctions := make([]crd.Function, 0)
|
||||
relatedFunctions := make([]fv1.Function, 0)
|
||||
for _, f := range funcList.Items {
|
||||
if (f.Spec.Environment.Name == m.Name) && (f.Spec.Environment.Namespace == m.Namespace) {
|
||||
relatedFunctions = append(relatedFunctions, f)
|
||||
@@ -221,8 +223,8 @@ func (deploy *NewDeploy) GetFuncSvc(ctx context.Context, metadata *metav1.Object
|
||||
return deploy.createFunction(fn, false)
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) createFunction(fn *crd.Function, firstcreate bool) (*fscache.FuncSvc, error) {
|
||||
if fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fission.ExecutorTypeNewdeploy {
|
||||
func (deploy *NewDeploy) createFunction(fn *fv1.Function, firstcreate bool) (*fscache.FuncSvc, error) {
|
||||
if fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fv1.ExecutorTypeNewdeploy {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -241,8 +243,8 @@ func (deploy *NewDeploy) createFunction(fn *crd.Function, firstcreate bool) (*fs
|
||||
return fsvc, err
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) deleteFunction(fn *crd.Function) error {
|
||||
if fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fission.ExecutorTypeNewdeploy {
|
||||
func (deploy *NewDeploy) deleteFunction(fn *fv1.Function) error {
|
||||
if fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fv1.ExecutorTypeNewdeploy {
|
||||
return nil
|
||||
}
|
||||
err := deploy.fnDelete(fn)
|
||||
@@ -252,7 +254,7 @@ func (deploy *NewDeploy) deleteFunction(fn *crd.Function) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) fnCreate(fn *crd.Function, firstcreate bool) (*fscache.FuncSvc, error) {
|
||||
func (deploy *NewDeploy) fnCreate(fn *fv1.Function, firstcreate bool) (*fscache.FuncSvc, error) {
|
||||
env, err := deploy.fissionClient.
|
||||
Environments(fn.Spec.Environment.Namespace).
|
||||
Get(fn.Spec.Environment.Name)
|
||||
@@ -348,21 +350,21 @@ func (deploy *NewDeploy) fnCreate(fn *crd.Function, firstcreate bool) (*fscache.
|
||||
return fsvc, nil
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) updateFunction(oldFn *crd.Function, newFn *crd.Function) error {
|
||||
func (deploy *NewDeploy) updateFunction(oldFn *fv1.Function, newFn *fv1.Function) error {
|
||||
|
||||
if oldFn.Metadata.ResourceVersion == newFn.Metadata.ResourceVersion {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Ignoring updates to functions which are not of NewDeployment type
|
||||
if newFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fission.ExecutorTypeNewdeploy &&
|
||||
oldFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fission.ExecutorTypeNewdeploy {
|
||||
if newFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fv1.ExecutorTypeNewdeploy &&
|
||||
oldFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fv1.ExecutorTypeNewdeploy {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Executor type is no longer New Deployment
|
||||
if newFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fission.ExecutorTypeNewdeploy &&
|
||||
oldFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fission.ExecutorTypeNewdeploy {
|
||||
if newFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fv1.ExecutorTypeNewdeploy &&
|
||||
oldFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fv1.ExecutorTypeNewdeploy {
|
||||
deploy.logger.Info("function does not use new deployment executor anymore, deleting resources",
|
||||
zap.Any("function", newFn))
|
||||
// IMP - pass the oldFn, as the new/modified function is not in cache
|
||||
@@ -370,8 +372,8 @@ func (deploy *NewDeploy) updateFunction(oldFn *crd.Function, newFn *crd.Function
|
||||
}
|
||||
|
||||
// Executor type changed to New Deployment from something else
|
||||
if oldFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fission.ExecutorTypeNewdeploy &&
|
||||
newFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fission.ExecutorTypeNewdeploy {
|
||||
if oldFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fv1.ExecutorTypeNewdeploy &&
|
||||
newFn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fv1.ExecutorTypeNewdeploy {
|
||||
deploy.logger.Info("function type changed to new deployment, creating resources",
|
||||
zap.Any("old_function", oldFn.Metadata),
|
||||
zap.Any("new_function", newFn.Metadata))
|
||||
@@ -474,7 +476,7 @@ func (deploy *NewDeploy) updateFunction(oldFn *crd.Function, newFn *crd.Function
|
||||
return nil
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) updateFuncDeployment(fn *crd.Function, env *crd.Environment) error {
|
||||
func (deploy *NewDeploy) updateFuncDeployment(fn *fv1.Function, env *fv1.Environment) error {
|
||||
|
||||
fsvc, err := deploy.fsCache.GetByFunctionUID(fn.Metadata.UID)
|
||||
if err != nil {
|
||||
@@ -508,7 +510,7 @@ func (deploy *NewDeploy) updateFuncDeployment(fn *crd.Function, env *crd.Environ
|
||||
return nil
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) fnDelete(fn *crd.Function) error {
|
||||
func (deploy *NewDeploy) fnDelete(fn *fv1.Function) error {
|
||||
var multierr *multierror.Error
|
||||
|
||||
// GetByFunction uses resource version as part of cache key, however,
|
||||
@@ -544,20 +546,20 @@ func (deploy *NewDeploy) fnDelete(fn *crd.Function) error {
|
||||
}
|
||||
|
||||
// getObjName returns a unique name for kubernetes objects of function
|
||||
func (deploy *NewDeploy) getObjName(fn *crd.Function) string {
|
||||
func (deploy *NewDeploy) getObjName(fn *fv1.Function) string {
|
||||
return strings.ToLower(fmt.Sprintf("newdeploy-%v-%v-%v", fn.Metadata.Name, fn.Metadata.Namespace, uniuri.NewLen(8)))
|
||||
}
|
||||
|
||||
func (deploy *NewDeploy) getDeployLabels(fn *crd.Function, env *crd.Environment) map[string]string {
|
||||
func (deploy *NewDeploy) getDeployLabels(fn *fv1.Function, env *fv1.Environment) map[string]string {
|
||||
return map[string]string{
|
||||
fission.EXECUTOR_INSTANCEID_LABEL: deploy.instanceID,
|
||||
fission.EXECUTOR_TYPE: fission.ExecutorTypeNewdeploy,
|
||||
fission.ENVIRONMENT_NAME: env.Metadata.Name,
|
||||
fission.ENVIRONMENT_NAMESPACE: env.Metadata.Namespace,
|
||||
fission.ENVIRONMENT_UID: string(env.Metadata.UID),
|
||||
fission.FUNCTION_NAME: fn.Metadata.Name,
|
||||
fission.FUNCTION_NAMESPACE: fn.Metadata.Namespace,
|
||||
fission.FUNCTION_UID: string(fn.Metadata.UID),
|
||||
types.EXECUTOR_INSTANCEID_LABEL: deploy.instanceID,
|
||||
types.EXECUTOR_TYPE: fv1.ExecutorTypeNewdeploy,
|
||||
types.ENVIRONMENT_NAME: env.Metadata.Name,
|
||||
types.ENVIRONMENT_NAMESPACE: env.Metadata.Namespace,
|
||||
types.ENVIRONMENT_UID: string(env.Metadata.UID),
|
||||
types.FUNCTION_NAME: fn.Metadata.Name,
|
||||
types.FUNCTION_NAMESPACE: fn.Metadata.Namespace,
|
||||
types.FUNCTION_UID: string(fn.Metadata.UID),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +579,7 @@ func (deploy *NewDeploy) updateKubeObjRefRV(fsvc *fscache.FuncSvc, objKind strin
|
||||
|
||||
// updateStatus is a function which updates status of update.
|
||||
// Current implementation only logs messages, in future it will update function status
|
||||
func (deploy *NewDeploy) updateStatus(fn *crd.Function, err error, message string) {
|
||||
func (deploy *NewDeploy) updateStatus(fn *fv1.Function, err error, message string) {
|
||||
deploy.logger.Info("function status update", zap.Error(err), zap.Any("function", fn), zap.String("message", message))
|
||||
}
|
||||
|
||||
@@ -629,7 +631,7 @@ func (deploy *NewDeploy) idleObjectReaper() {
|
||||
deploy.logger.Fatal("failed to get environment list", zap.Error(err))
|
||||
}
|
||||
|
||||
envList := make(map[types.UID]struct{})
|
||||
envList := make(map[k8sTypes.UID]struct{})
|
||||
for _, env := range envs.Items {
|
||||
envList[env.Metadata.UID] = struct{}{}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package poolmgr
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/fission/fission/pkg/types"
|
||||
"go.uber.org/zap"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
@@ -28,8 +29,9 @@ import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
func getIstioServiceLabels(fnName string) map[string]string {
|
||||
@@ -44,10 +46,10 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
|
||||
resyncPeriod := 30 * time.Second
|
||||
lw := k8sCache.NewListWatchFromClient(fissionClient.GetCrdClient(), "functions", metav1.NamespaceAll, fields.Everything())
|
||||
|
||||
funcStore, controller := k8sCache.NewInformer(lw, &crd.Function{}, resyncPeriod,
|
||||
funcStore, controller := k8sCache.NewInformer(lw, &fv1.Function{}, resyncPeriod,
|
||||
k8sCache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
fn := obj.(*crd.Function)
|
||||
fn := obj.(*fv1.Function)
|
||||
|
||||
// Since istio only allows accessing pod through k8s service,
|
||||
// for the functions with executor type "poolmgr" we need to
|
||||
@@ -58,7 +60,7 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
|
||||
|
||||
// In some cases, user may not enter the executorType explicitly, for example in his spec.yaml.
|
||||
// we assume it to be of type poolmgr
|
||||
if fnExecutorType != "" && fnExecutorType != fission.ExecutorTypePoolmgr {
|
||||
if fnExecutorType != "" && fnExecutorType != fv1.ExecutorTypePoolmgr {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -72,12 +74,12 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
|
||||
// setup rolebinding is tried, if it fails, we dont return. we just log an error and move on, because :
|
||||
// 1. not all functions have secrets and/or configmaps, so things will work without this rolebinding in that case.
|
||||
// 2. on the contrary, when the route is tried, the env fetcher logs will show a 403 forbidden message and same will be relayed to executor.
|
||||
err := fission.SetupRoleBinding(gpm.logger, kubernetesClient, fission.SecretConfigMapGetterRB, fn.Metadata.Namespace, fission.SecretConfigMapGetterCR, fission.ClusterRole, fission.FissionFetcherSA, envNs)
|
||||
err := utils.SetupRoleBinding(gpm.logger, kubernetesClient, types.SecretConfigMapGetterRB, fn.Metadata.Namespace, types.SecretConfigMapGetterCR, types.ClusterRole, types.FissionFetcherSA, envNs)
|
||||
if err != nil {
|
||||
gpm.logger.Error("error creating rolebinding", zap.Error(err), zap.String("role_binding", fission.SecretConfigMapGetterRB))
|
||||
gpm.logger.Error("error creating rolebinding", zap.Error(err), zap.String("role_binding", types.SecretConfigMapGetterRB))
|
||||
} else {
|
||||
gpm.logger.Info("successfully set up rolebinding for fetcher service account for function",
|
||||
zap.String("service_account", fission.FissionFetcherSA),
|
||||
zap.String("service_account", types.FissionFetcherSA),
|
||||
zap.String("service_account_namepsace", envNs),
|
||||
zap.String("function_name", fn.Metadata.Name),
|
||||
zap.String("function_namespace", fn.Metadata.Namespace))
|
||||
@@ -91,7 +93,7 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
|
||||
"functionUid": string(fn.Metadata.UID),
|
||||
}
|
||||
|
||||
svcName := fission.GetFunctionIstioServiceName(fn.Metadata.Name, fn.Metadata.Namespace)
|
||||
svcName := utils.GetFunctionIstioServiceName(fn.Metadata.Name, fn.Metadata.Namespace)
|
||||
|
||||
// service for accepting user traffic
|
||||
svc := apiv1.Service{
|
||||
@@ -140,10 +142,10 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
|
||||
},
|
||||
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
fn := obj.(*crd.Function)
|
||||
fn := obj.(*fv1.Function)
|
||||
|
||||
fnExecutorType := fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType
|
||||
if fnExecutorType != "" && fnExecutorType != fission.ExecutorTypePoolmgr {
|
||||
if fnExecutorType != "" && fnExecutorType != fv1.ExecutorTypePoolmgr {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -153,7 +155,7 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
|
||||
}
|
||||
|
||||
if istioEnabled {
|
||||
svcName := fission.GetFunctionIstioServiceName(fn.Metadata.Name, fn.Metadata.Namespace)
|
||||
svcName := utils.GetFunctionIstioServiceName(fn.Metadata.Name, fn.Metadata.Namespace)
|
||||
// delete function istio service
|
||||
err := kubernetesClient.CoreV1().Services(envNs).Delete(svcName, nil)
|
||||
if err != nil && !kerrors.IsNotFound(err) {
|
||||
@@ -167,8 +169,8 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
|
||||
},
|
||||
|
||||
UpdateFunc: func(oldObj, newObj interface{}) {
|
||||
oldFunc := oldObj.(*crd.Function)
|
||||
newFunc := newObj.(*crd.Function)
|
||||
oldFunc := oldObj.(*fv1.Function)
|
||||
newFunc := newObj.(*fv1.Function)
|
||||
|
||||
if oldFunc.Metadata.ResourceVersion == newFunc.Metadata.ResourceVersion {
|
||||
return
|
||||
@@ -176,8 +178,8 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
|
||||
|
||||
envChanged := (oldFunc.Spec.Environment.Namespace != newFunc.Spec.Environment.Namespace)
|
||||
|
||||
executorTypeChangedToPM := (oldFunc.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fission.ExecutorTypePoolmgr &&
|
||||
newFunc.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fission.ExecutorTypePoolmgr)
|
||||
executorTypeChangedToPM := (oldFunc.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fv1.ExecutorTypePoolmgr &&
|
||||
newFunc.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fv1.ExecutorTypePoolmgr)
|
||||
|
||||
// if a func's env reference gets updated and the newly referenced env is in a different ns,
|
||||
// we need to create a rolebinding in func's ns so that the fetcher-sa in env ns has access
|
||||
@@ -190,15 +192,15 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
|
||||
envNs = newFunc.Spec.Environment.Namespace
|
||||
}
|
||||
|
||||
err := fission.SetupRoleBinding(gpm.logger, kubernetesClient, fission.SecretConfigMapGetterRB,
|
||||
newFunc.Metadata.Namespace, fission.SecretConfigMapGetterCR, fission.ClusterRole,
|
||||
fission.FissionFetcherSA, envNs)
|
||||
err := utils.SetupRoleBinding(gpm.logger, kubernetesClient, types.SecretConfigMapGetterRB,
|
||||
newFunc.Metadata.Namespace, types.SecretConfigMapGetterCR, types.ClusterRole,
|
||||
types.FissionFetcherSA, envNs)
|
||||
|
||||
if err != nil {
|
||||
gpm.logger.Error("error creating rolebinding", zap.Error(err), zap.String("role_binding", fission.SecretConfigMapGetterRB))
|
||||
gpm.logger.Error("error creating rolebinding", zap.Error(err), zap.String("role_binding", types.SecretConfigMapGetterRB))
|
||||
} else {
|
||||
gpm.logger.Info("successfully set up rolebinding for fetcher service account for function",
|
||||
zap.String("service_account", fission.FissionFetcherSA),
|
||||
zap.String("service_account", types.FissionFetcherSA),
|
||||
zap.String("service_account_namepsace", envNs),
|
||||
zap.String("function_name", newFunc.Metadata.Name),
|
||||
zap.String("function_namespace", newFunc.Metadata.Namespace))
|
||||
@@ -26,6 +26,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
@@ -36,18 +38,18 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fetcherClient "github.com/fission/fission/environments/fetcher/client"
|
||||
fetcherConfig "github.com/fission/fission/environments/fetcher/config"
|
||||
"github.com/fission/fission/executor/fscache"
|
||||
"github.com/fission/fission/executor/util"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/executor/fscache"
|
||||
"github.com/fission/fission/pkg/executor/util"
|
||||
fetcherClient "github.com/fission/fission/pkg/fetcher/client"
|
||||
fetcherConfig "github.com/fission/fission/pkg/fetcher/config"
|
||||
)
|
||||
|
||||
type (
|
||||
GenericPool struct {
|
||||
logger *zap.Logger
|
||||
env *crd.Environment
|
||||
env *fv1.Environment
|
||||
replicas int32 // num idle pods
|
||||
deployment *v1beta1.Deployment // kubernetes deployment
|
||||
namespace string // namespace to keep our resources
|
||||
@@ -82,7 +84,7 @@ func MakeGenericPool(
|
||||
logger *zap.Logger,
|
||||
fissionClient *crd.FissionClient,
|
||||
kubernetesClient *kubernetes.Clientset,
|
||||
env *crd.Environment,
|
||||
env *fv1.Environment,
|
||||
initialReplicas int32,
|
||||
namespace string,
|
||||
functionNamespace string,
|
||||
@@ -116,7 +118,7 @@ func MakeGenericPool(
|
||||
useIstio: enableIstio, // defaults off -- istio integration requires pod relabeling and it takes a second or more to become routable, slowing cold start
|
||||
}
|
||||
|
||||
gp.runtimeImagePullPolicy = fission.GetImagePullPolicy(os.Getenv("RUNTIME_IMAGE_PULL_POLICY"))
|
||||
gp.runtimeImagePullPolicy = utils.GetImagePullPolicy(os.Getenv("RUNTIME_IMAGE_PULL_POLICY"))
|
||||
|
||||
// create fetcher SA in this ns, if not already created
|
||||
err := fetcherConfig.SetupServiceAccount(gp.kubernetesClient, gp.namespace, nil)
|
||||
@@ -141,12 +143,12 @@ func MakeGenericPool(
|
||||
|
||||
func (gp *GenericPool) getDeployLabels() map[string]string {
|
||||
return map[string]string{
|
||||
fission.EXECUTOR_INSTANCEID_LABEL: gp.instanceId,
|
||||
fission.EXECUTOR_TYPE: fission.ExecutorTypePoolmgr,
|
||||
fission.ENVIRONMENT_NAME: gp.env.Metadata.Name,
|
||||
fission.ENVIRONMENT_NAMESPACE: gp.env.Metadata.Namespace,
|
||||
fission.ENVIRONMENT_UID: string(gp.env.Metadata.UID),
|
||||
"managed": "true", // this allows us to easily find pods managed by the deployment
|
||||
fv1.EXECUTOR_INSTANCEID_LABEL: gp.instanceId,
|
||||
types.EXECUTOR_TYPE: fv1.ExecutorTypePoolmgr,
|
||||
types.ENVIRONMENT_NAME: gp.env.Metadata.Name,
|
||||
types.ENVIRONMENT_NAMESPACE: gp.env.Metadata.Namespace,
|
||||
types.ENVIRONMENT_UID: string(gp.env.Metadata.UID),
|
||||
"managed": "true", // this allows us to easily find pods managed by the deployment
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +203,7 @@ func (gp *GenericPool) _choosePod(newLabels map[string]string) (*apiv1.Pod, erro
|
||||
pod := podList.Items[i]
|
||||
|
||||
// Ignore not ready pod here
|
||||
if !fission.IsReadyPod(&pod) {
|
||||
if !utils.IsReadyPod(&pod) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -227,7 +229,7 @@ func (gp *GenericPool) _choosePod(newLabels map[string]string) (*apiv1.Pod, erro
|
||||
// and make a good scheduling decision.
|
||||
chosenPod := readyPods[rand.Intn(len(readyPods))]
|
||||
|
||||
if gp.env.Spec.AllowedFunctionsPerContainer != fission.AllowedFunctionsPerContainerInfinite {
|
||||
if gp.env.Spec.AllowedFunctionsPerContainer != types.AllowedFunctionsPerContainerInfinite {
|
||||
// Relabel. If the pod already got picked and
|
||||
// modified, this should fail; in that case just
|
||||
// retry.
|
||||
@@ -246,10 +248,10 @@ func (gp *GenericPool) _choosePod(newLabels map[string]string) (*apiv1.Pod, erro
|
||||
|
||||
func (gp *GenericPool) labelsForFunction(metadata *metav1.ObjectMeta) map[string]string {
|
||||
label := gp.getDeployLabels()
|
||||
label[fission.FUNCTION_NAME] = metadata.Name
|
||||
label[fission.FUNCTION_UID] = string(metadata.UID)
|
||||
label[fission.FUNCTION_NAMESPACE] = metadata.Namespace // function CRD must stay within same namespace of environment CRD
|
||||
label["managed"] = "false" // this allows us to easily find pods not managed by the deployment
|
||||
label[types.FUNCTION_NAME] = metadata.Name
|
||||
label[types.FUNCTION_UID] = string(metadata.UID)
|
||||
label[types.FUNCTION_NAMESPACE] = metadata.Namespace // function CRD must stay within same namespace of environment CRD
|
||||
label["managed"] = "false" // this allows us to easily find pods not managed by the deployment
|
||||
return label
|
||||
|
||||
}
|
||||
@@ -305,7 +307,7 @@ func (gp *GenericPool) specializePod(ctx context.Context, pod *apiv1.Pod, metada
|
||||
}
|
||||
// specialize pod with service
|
||||
if gp.useIstio {
|
||||
svc := fission.GetFunctionIstioServiceName(metadata.Name, metadata.Namespace)
|
||||
svc := utils.GetFunctionIstioServiceName(metadata.Name, metadata.Namespace)
|
||||
podIP = fmt.Sprintf("%v.%v", svc, gp.namespace)
|
||||
}
|
||||
|
||||
@@ -569,7 +571,7 @@ func (gp *GenericPool) GetFuncSvc(ctx context.Context, m *metav1.ObjectMeta) (*f
|
||||
// namespace-qualified hostname
|
||||
svcHost = fmt.Sprintf("%v.%v", svcName, gp.namespace)
|
||||
} else if gp.useIstio {
|
||||
svc := fission.GetFunctionIstioServiceName(m.Name, m.Namespace)
|
||||
svc := utils.GetFunctionIstioServiceName(m.Name, m.Namespace)
|
||||
svcHost = fmt.Sprintf("%v.%v:8888", svc, gp.namespace)
|
||||
} else {
|
||||
gp.logger.Info("using pod IP for specialized pod", zap.String("pod", pod.ObjectMeta.Name), zap.String("function", m.Name))
|
||||
@@ -23,18 +23,20 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
"go.uber.org/zap"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
k8sTypes "k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/cache"
|
||||
"github.com/fission/fission/crd"
|
||||
fetcherConfig "github.com/fission/fission/environments/fetcher/config"
|
||||
"github.com/fission/fission/executor/fscache"
|
||||
"github.com/fission/fission/executor/reaper"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/cache"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/executor/fscache"
|
||||
"github.com/fission/fission/pkg/executor/reaper"
|
||||
fetcherConfig "github.com/fission/fission/pkg/fetcher/config"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
type requestType int
|
||||
@@ -70,8 +72,8 @@ type (
|
||||
}
|
||||
request struct {
|
||||
requestType
|
||||
env *crd.Environment
|
||||
envList []crd.Environment
|
||||
env *fv1.Environment
|
||||
envList []fv1.Environment
|
||||
responseChannel chan *response
|
||||
}
|
||||
response struct {
|
||||
@@ -139,7 +141,7 @@ func (gpm *GenericPoolManager) service() {
|
||||
if !ok {
|
||||
poolsize := gpm.getEnvPoolsize(req.env)
|
||||
switch req.env.Spec.AllowedFunctionsPerContainer {
|
||||
case fission.AllowedFunctionsPerContainerInfinite:
|
||||
case types.AllowedFunctionsPerContainerInfinite:
|
||||
poolsize = 1
|
||||
}
|
||||
|
||||
@@ -170,7 +172,7 @@ func (gpm *GenericPoolManager) service() {
|
||||
if !ok || poolsize == 0 {
|
||||
// Env no longer exists or pool size changed to zero
|
||||
|
||||
gpm.logger.Info("eestroying generic pool", zap.Any("environment", pool.env.Metadata))
|
||||
gpm.logger.Info("destroying generic pool", zap.Any("environment", pool.env.Metadata))
|
||||
delete(gpm.pools, key)
|
||||
|
||||
// and delete the pool asynchronously.
|
||||
@@ -182,7 +184,7 @@ func (gpm *GenericPoolManager) service() {
|
||||
}
|
||||
}
|
||||
|
||||
func (gpm *GenericPoolManager) GetPool(env *crd.Environment) (*GenericPool, error) {
|
||||
func (gpm *GenericPoolManager) GetPool(env *fv1.Environment) (*GenericPool, error) {
|
||||
c := make(chan *response)
|
||||
gpm.requestChannel <- &request{
|
||||
requestType: GET_POOL,
|
||||
@@ -193,7 +195,7 @@ func (gpm *GenericPoolManager) GetPool(env *crd.Environment) (*GenericPool, erro
|
||||
return resp.pool, resp.error
|
||||
}
|
||||
|
||||
func (gpm *GenericPoolManager) CleanupPools(envs []crd.Environment) {
|
||||
func (gpm *GenericPoolManager) CleanupPools(envs []fv1.Environment) {
|
||||
gpm.requestChannel <- &request{
|
||||
requestType: CLEANUP_POOLS,
|
||||
envList: envs,
|
||||
@@ -218,13 +220,13 @@ func (gpm *GenericPoolManager) GetFuncSvc(ctx context.Context, metadata *metav1.
|
||||
return pool.GetFuncSvc(ctx, metadata)
|
||||
}
|
||||
|
||||
func (gpm *GenericPoolManager) getFunctionEnv(m *metav1.ObjectMeta) (*crd.Environment, error) {
|
||||
var env *crd.Environment
|
||||
func (gpm *GenericPoolManager) getFunctionEnv(m *metav1.ObjectMeta) (*fv1.Environment, error) {
|
||||
var env *fv1.Environment
|
||||
|
||||
// Cached ?
|
||||
result, err := gpm.functionEnv.Get(crd.CacheKey(m))
|
||||
if err == nil {
|
||||
env = result.(*crd.Environment)
|
||||
env = result.(*fv1.Environment)
|
||||
return env, nil
|
||||
}
|
||||
|
||||
@@ -253,7 +255,7 @@ func (gpm *GenericPoolManager) eagerPoolCreator() {
|
||||
// get list of envs from controller
|
||||
envs, err := gpm.fissionClient.Environments(metav1.NamespaceAll).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
if fission.IsNetworkError(err) {
|
||||
if utils.IsNetworkError(err) {
|
||||
gpm.logger.Error("encountered network error, retrying", zap.Error(err))
|
||||
time.Sleep(5 * time.Second)
|
||||
continue
|
||||
@@ -282,7 +284,7 @@ func (gpm *GenericPoolManager) eagerPoolCreator() {
|
||||
}
|
||||
}
|
||||
|
||||
func (gpm *GenericPoolManager) getEnvPoolsize(env *crd.Environment) int32 {
|
||||
func (gpm *GenericPoolManager) getEnvPoolsize(env *fv1.Environment) int32 {
|
||||
var poolsize int32
|
||||
if env.Spec.Version < 3 {
|
||||
poolsize = 3
|
||||
@@ -298,7 +300,7 @@ func (gpm *GenericPoolManager) IsValid(fsvc *fscache.FuncSvc) bool {
|
||||
for _, obj := range fsvc.KubernetesObjects {
|
||||
if obj.Kind == "pod" {
|
||||
pod, err := gpm.kubernetesClient.CoreV1().Pods(obj.Namespace).Get(obj.Name, metav1.GetOptions{})
|
||||
if err == nil && strings.Contains(fsvc.Address, pod.Status.PodIP) && fission.IsReadyPod(pod) {
|
||||
if err == nil && strings.Contains(fsvc.Address, pod.Status.PodIP) && utils.IsReadyPod(pod) {
|
||||
gpm.logger.Info("valid pod address", zap.String("address", fsvc.Address))
|
||||
return true
|
||||
}
|
||||
@@ -319,7 +321,7 @@ func (gpm *GenericPoolManager) idleObjectReaper() {
|
||||
gpm.logger.Fatal("failed to get environment list", zap.Error(err))
|
||||
}
|
||||
|
||||
envList := make(map[types.UID]struct{})
|
||||
envList := make(map[k8sTypes.UID]struct{})
|
||||
for _, env := range envs.Items {
|
||||
envList[env.Metadata.UID] = struct{}{}
|
||||
}
|
||||
@@ -343,7 +345,7 @@ func (gpm *GenericPoolManager) idleObjectReaper() {
|
||||
zap.String("function", fsvc.Name))
|
||||
}
|
||||
|
||||
if fsvc.Environment.Spec.AllowedFunctionsPerContainer == fission.AllowedFunctionsPerContainerInfinite {
|
||||
if fsvc.Environment.Spec.AllowedFunctionsPerContainer == types.AllowedFunctionsPerContainerInfinite {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -19,14 +19,16 @@ package poolmgr
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/fission/fission/pkg/types"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
"go.uber.org/zap"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
)
|
||||
|
||||
// TODO : It may make sense to make each of add, update, delete funcs run as separate go routines.
|
||||
@@ -35,10 +37,10 @@ func (gpm *GenericPoolManager) makePkgController(fissionClient *crd.FissionClien
|
||||
|
||||
resyncPeriod := 30 * time.Second
|
||||
lw := k8sCache.NewListWatchFromClient(fissionClient.GetCrdClient(), "packages", metav1.NamespaceAll, fields.Everything())
|
||||
pkgStore, controller := k8sCache.NewInformer(lw, &crd.Package{}, resyncPeriod,
|
||||
pkgStore, controller := k8sCache.NewInformer(lw, &fv1.Package{}, resyncPeriod,
|
||||
k8sCache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
pkg := obj.(*crd.Package)
|
||||
pkg := obj.(*fv1.Package)
|
||||
gpm.logger.Debug("list watch for package reported a new package addition",
|
||||
zap.String("package_name", pkg.Metadata.Name),
|
||||
zap.String("package_namepsace", pkg.Metadata.Namespace))
|
||||
@@ -51,26 +53,26 @@ func (gpm *GenericPoolManager) makePkgController(fissionClient *crd.FissionClien
|
||||
|
||||
// here, we return if we hit an error during rolebinding setup. this is because this rolebinding is mandatory for
|
||||
// every function's package to be loaded into its env. without that, there's no point to move forward.
|
||||
err := fission.SetupRoleBinding(gpm.logger, kubernetesClient, fission.PackageGetterRB, pkg.Metadata.Namespace, fission.PackageGetterCR, fission.ClusterRole, fission.FissionFetcherSA, envNs)
|
||||
err := utils.SetupRoleBinding(gpm.logger, kubernetesClient, types.PackageGetterRB, pkg.Metadata.Namespace, types.PackageGetterCR, types.ClusterRole, types.FissionFetcherSA, envNs)
|
||||
if err != nil {
|
||||
gpm.logger.Error("error creating rolebinding for package",
|
||||
zap.Error(err),
|
||||
zap.String("role_binding", fission.PackageGetterRB),
|
||||
zap.String("role_binding", types.PackageGetterRB),
|
||||
zap.String("package_name", pkg.Metadata.Name),
|
||||
zap.String("package_namespace", pkg.Metadata.Namespace))
|
||||
return
|
||||
}
|
||||
|
||||
gpm.logger.Debug("successfully set up rolebinding for fetcher service account",
|
||||
zap.String("service_account", fission.FissionFetcherSA),
|
||||
zap.String("service_account", types.FissionFetcherSA),
|
||||
zap.String("service_account_namespace", envNs),
|
||||
zap.String("package_name", pkg.Metadata.Name),
|
||||
zap.String("package_namespace", pkg.Metadata.Namespace))
|
||||
},
|
||||
|
||||
UpdateFunc: func(oldObj, newObj interface{}) {
|
||||
oldPkg := oldObj.(*crd.Package)
|
||||
newPkg := newObj.(*crd.Package)
|
||||
oldPkg := oldObj.(*fv1.Package)
|
||||
newPkg := newObj.(*fv1.Package)
|
||||
|
||||
if oldPkg.Metadata.ResourceVersion == newPkg.Metadata.ResourceVersion {
|
||||
return
|
||||
@@ -85,20 +87,20 @@ func (gpm *GenericPoolManager) makePkgController(fissionClient *crd.FissionClien
|
||||
envNs = newPkg.Spec.Environment.Namespace
|
||||
}
|
||||
|
||||
err := fission.SetupRoleBinding(gpm.logger, kubernetesClient, fission.PackageGetterRB,
|
||||
newPkg.Metadata.Namespace, fission.PackageGetterCR, fission.ClusterRole,
|
||||
fission.FissionFetcherSA, envNs)
|
||||
err := utils.SetupRoleBinding(gpm.logger, kubernetesClient, types.PackageGetterRB,
|
||||
newPkg.Metadata.Namespace, types.PackageGetterCR, types.ClusterRole,
|
||||
types.FissionFetcherSA, envNs)
|
||||
if err != nil {
|
||||
gpm.logger.Error("error updating rolebinding for package",
|
||||
zap.Error(err),
|
||||
zap.String("role_binding", fission.PackageGetterRB),
|
||||
zap.String("role_binding", types.PackageGetterRB),
|
||||
zap.String("package_name", newPkg.Metadata.Name),
|
||||
zap.String("package_namespace", newPkg.Metadata.Namespace))
|
||||
return
|
||||
}
|
||||
|
||||
gpm.logger.Debug("successfully updated rolebinding for fetcher service account",
|
||||
zap.String("service_account", fission.FissionFetcherSA),
|
||||
zap.String("service_account", types.FissionFetcherSA),
|
||||
zap.String("service_account_namespace", envNs),
|
||||
zap.String("package_name", newPkg.Metadata.Name),
|
||||
zap.String("package_namespace", newPkg.Metadata.Namespace))
|
||||
@@ -20,13 +20,14 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
"go.uber.org/zap"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -119,7 +120,7 @@ func cleanupDeployments(logger *zap.Logger, client *kubernetes.Clientset, instan
|
||||
return err
|
||||
}
|
||||
for _, dep := range deploymentList.Items {
|
||||
id, ok := dep.ObjectMeta.Labels[fission.EXECUTOR_INSTANCEID_LABEL]
|
||||
id, ok := dep.ObjectMeta.Labels[types.EXECUTOR_INSTANCEID_LABEL]
|
||||
if ok && id != instanceId {
|
||||
logger.Info("cleaning up deployment", zap.String("deployment", dep.ObjectMeta.Name))
|
||||
err := client.ExtensionsV1beta1().Deployments(dep.ObjectMeta.Namespace).Delete(dep.ObjectMeta.Name, &delOpt)
|
||||
@@ -132,7 +133,7 @@ func cleanupDeployments(logger *zap.Logger, client *kubernetes.Clientset, instan
|
||||
// ignore err
|
||||
}
|
||||
// Backward compatibility with older label name
|
||||
pid, pok := dep.ObjectMeta.Labels[fission.POOLMGR_INSTANCEID_LABEL]
|
||||
pid, pok := dep.ObjectMeta.Labels[types.POOLMGR_INSTANCEID_LABEL]
|
||||
if pok && pid != instanceId {
|
||||
logger.Info("cleaning up deployment", zap.String("deployment", dep.ObjectMeta.Name))
|
||||
err := client.ExtensionsV1beta1().Deployments(dep.ObjectMeta.Namespace).Delete(dep.ObjectMeta.Name, &delOpt)
|
||||
@@ -154,7 +155,7 @@ func cleanupPods(logger *zap.Logger, client *kubernetes.Clientset, instanceId st
|
||||
return err
|
||||
}
|
||||
for _, pod := range podList.Items {
|
||||
id, ok := pod.ObjectMeta.Labels[fission.EXECUTOR_INSTANCEID_LABEL]
|
||||
id, ok := pod.ObjectMeta.Labels[types.EXECUTOR_INSTANCEID_LABEL]
|
||||
if ok && id != instanceId {
|
||||
logger.Info("cleaning up pod", zap.String("pod", pod.ObjectMeta.Name))
|
||||
err := client.CoreV1().Pods(pod.ObjectMeta.Namespace).Delete(pod.ObjectMeta.Name, nil)
|
||||
@@ -167,7 +168,7 @@ func cleanupPods(logger *zap.Logger, client *kubernetes.Clientset, instanceId st
|
||||
// ignore err
|
||||
}
|
||||
// Backward compatibility with older label name
|
||||
pid, pok := pod.ObjectMeta.Labels[fission.POOLMGR_INSTANCEID_LABEL]
|
||||
pid, pok := pod.ObjectMeta.Labels[types.POOLMGR_INSTANCEID_LABEL]
|
||||
if pok && pid != instanceId {
|
||||
logger.Info("cleaning up pod", zap.String("pod", pod.ObjectMeta.Name))
|
||||
err := client.CoreV1().Pods(pod.ObjectMeta.Namespace).Delete(pod.ObjectMeta.Name, nil)
|
||||
@@ -190,7 +191,7 @@ func cleanupServices(logger *zap.Logger, client *kubernetes.Clientset, instanceI
|
||||
return err
|
||||
}
|
||||
for _, svc := range svcList.Items {
|
||||
id, ok := svc.ObjectMeta.Labels[fission.EXECUTOR_INSTANCEID_LABEL]
|
||||
id, ok := svc.ObjectMeta.Labels[types.EXECUTOR_INSTANCEID_LABEL]
|
||||
if ok && id != instanceId {
|
||||
logger.Info("cleaning up service", zap.String("service", svc.ObjectMeta.Name))
|
||||
err := client.CoreV1().Services(svc.ObjectMeta.Namespace).Delete(svc.ObjectMeta.Name, nil)
|
||||
@@ -213,7 +214,7 @@ func cleanupHpa(logger *zap.Logger, client *kubernetes.Clientset, instanceId str
|
||||
}
|
||||
|
||||
for _, hpa := range hpaList.Items {
|
||||
id, ok := hpa.ObjectMeta.Labels[fission.EXECUTOR_INSTANCEID_LABEL]
|
||||
id, ok := hpa.ObjectMeta.Labels[types.EXECUTOR_INSTANCEID_LABEL]
|
||||
if ok && id != instanceId {
|
||||
logger.Info("cleaning up HPA", zap.String("hpa", hpa.ObjectMeta.Name))
|
||||
err := client.AutoscalingV1().HorizontalPodAutoscalers(hpa.ObjectMeta.Namespace).Delete(hpa.ObjectMeta.Name, nil)
|
||||
@@ -252,7 +253,7 @@ func CleanupRoleBindings(logger *zap.Logger, client *kubernetes.Clientset, fissi
|
||||
}
|
||||
|
||||
// ignore role-bindings not created by fission
|
||||
if roleBinding.Name != fission.PackageGetterRB && roleBinding.Name != fission.SecretConfigMapGetterRB {
|
||||
if roleBinding.Name != types.PackageGetterRB && roleBinding.Name != types.SecretConfigMapGetterRB {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -295,7 +296,7 @@ func CleanupRoleBindings(logger *zap.Logger, client *kubernetes.Clientset, fissi
|
||||
break
|
||||
}
|
||||
|
||||
if fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fission.ExecutorTypeNewdeploy {
|
||||
if fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == types.ExecutorTypeNewdeploy {
|
||||
ndmFunc = true
|
||||
break
|
||||
}
|
||||
@@ -303,7 +304,7 @@ func CleanupRoleBindings(logger *zap.Logger, client *kubernetes.Clientset, fissi
|
||||
|
||||
// if its a package-getterr-rb, we have 2 kinds of SAs and each of them is handled differently
|
||||
// else if its a secret-configmap-rb, we have only one SA which is fission-fetcher
|
||||
if roleBinding.Name == fission.PackageGetterRB {
|
||||
if roleBinding.Name == types.PackageGetterRB {
|
||||
// check if there is an env obj in saNs
|
||||
envList, err := fissionClient.Environments(saNs).List(meta_v1.ListOptions{})
|
||||
if err != nil {
|
||||
@@ -316,9 +317,9 @@ func CleanupRoleBindings(logger *zap.Logger, client *kubernetes.Clientset, fissi
|
||||
// if there's at least one function in the role-binding namespace with env reference
|
||||
// to the SA's namespace.
|
||||
// if neither, then we can remove this SA from this role-binding
|
||||
if subj.Name == fission.FissionBuilderSA {
|
||||
if subj.Name == types.FissionBuilderSA {
|
||||
if len(envList.Items) == 0 && !funcEnvReference {
|
||||
saToRemove[fission.MakeSAMapKey(subj.Name, subj.Namespace)] = true
|
||||
saToRemove[utils.MakeSAMapKey(subj.Name, subj.Namespace)] = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,18 +327,18 @@ func CleanupRoleBindings(logger *zap.Logger, client *kubernetes.Clientset, fissi
|
||||
// we also need to check if there's at least one function with executor type New deploy
|
||||
// in the rolebinding's namespace.
|
||||
// if none of them are true, then remove this SA from this role-binding
|
||||
if subj.Name == fission.FissionFetcherSA {
|
||||
if subj.Name == types.FissionFetcherSA {
|
||||
if len(envList.Items) == 0 && !ndmFunc && !funcEnvReference {
|
||||
// remove SA from rolebinding
|
||||
saToRemove[fission.MakeSAMapKey(subj.Name, subj.Namespace)] = true
|
||||
saToRemove[utils.MakeSAMapKey(subj.Name, subj.Namespace)] = true
|
||||
}
|
||||
}
|
||||
} else if roleBinding.Name == fission.SecretConfigMapGetterRB {
|
||||
} else if roleBinding.Name == types.SecretConfigMapGetterRB {
|
||||
// if there's not even one function in the role-binding's namespace and there's not even
|
||||
// one function with env reference to the SA's namespace, then remove that SA
|
||||
// from this role-binding
|
||||
if !ndmFunc && !funcEnvReference {
|
||||
saToRemove[fission.MakeSAMapKey(subj.Name, subj.Namespace)] = true
|
||||
saToRemove[utils.MakeSAMapKey(subj.Name, subj.Namespace)] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,7 +352,7 @@ func CleanupRoleBindings(logger *zap.Logger, client *kubernetes.Clientset, fissi
|
||||
zap.String("role_binding_namespace", roleBinding.Namespace))
|
||||
|
||||
// call this once in the end for each role-binding
|
||||
err = fission.RemoveSAFromRoleBindingWithRetries(logger, client, roleBinding.Name, roleBinding.Namespace, saToRemove)
|
||||
err = utils.RemoveSAFromRoleBindingWithRetries(logger, client, roleBinding.Name, roleBinding.Namespace, saToRemove)
|
||||
if err != nil {
|
||||
// if there's an error, we just log it and proceed with the next role-binding, hoping that this role-binding
|
||||
// will be processed in next iteration.
|
||||
@@ -15,7 +15,8 @@ import (
|
||||
"go.opencensus.io/plugin/ochttp"
|
||||
"golang.org/x/net/context/ctxhttp"
|
||||
|
||||
"github.com/fission/fission"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -48,20 +49,20 @@ func (c *Client) getUploadUrl() string {
|
||||
return c.url + "/upload"
|
||||
}
|
||||
|
||||
func (c *Client) Specialize(ctx context.Context, req *fission.FunctionSpecializeRequest) error {
|
||||
func (c *Client) Specialize(ctx context.Context, req *types.FunctionSpecializeRequest) error {
|
||||
_, err := sendRequest(c.logger, ctx, c.httpClient, req, c.getSpecializeUrl())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) Fetch(ctx context.Context, fr *fission.FunctionFetchRequest) error {
|
||||
func (c *Client) Fetch(ctx context.Context, fr *types.FunctionFetchRequest) error {
|
||||
_, err := sendRequest(c.logger, ctx, c.httpClient, fr, c.getFetchUrl())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) Upload(ctx context.Context, fr *fission.ArchiveUploadRequest) (*fission.ArchiveUploadResponse, error) {
|
||||
func (c *Client) Upload(ctx context.Context, fr *types.ArchiveUploadRequest) (*types.ArchiveUploadResponse, error) {
|
||||
body, err := sendRequest(c.logger, ctx, c.httpClient, fr, c.getUploadUrl())
|
||||
|
||||
uploadResp := fission.ArchiveUploadResponse{}
|
||||
uploadResp := types.ArchiveUploadResponse{}
|
||||
err = json.Unmarshal(body, &uploadResp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -91,7 +92,7 @@ func sendRequest(logger *zap.Logger, ctx context.Context, httpClient *http.Clien
|
||||
resp.Body.Close()
|
||||
return body, err
|
||||
}
|
||||
err = fission.MakeErrorFromHTTP(resp)
|
||||
err = ferror.MakeErrorFromHTTP(resp)
|
||||
}
|
||||
|
||||
if i < maxRetries-1 {
|
||||
@@ -7,14 +7,15 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/fission/fission/pkg/types"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/fission/fission"
|
||||
crd "github.com/fission/fission/crd"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -90,19 +91,19 @@ func MakeFetcherConfig(sharedMountPath string) (*Config, error) {
|
||||
return &Config{
|
||||
resourceRequirements: resources,
|
||||
fetcherImage: fetcherImage,
|
||||
fetcherImagePullPolicy: fission.GetImagePullPolicy(fetcherImagePullPolicy),
|
||||
fetcherImagePullPolicy: utils.GetImagePullPolicy(fetcherImagePullPolicy),
|
||||
sharedMountPath: sharedMountPath,
|
||||
sharedSecretPath: "/secrets",
|
||||
sharedCfgMapPath: "/configs",
|
||||
jaegerCollectorEndpoint: os.Getenv("OPENCENSUS_TRACE_JAEGER_COLLECTOR_ENDPOINT"),
|
||||
serviceAccount: fission.FissionFetcherSA,
|
||||
serviceAccount: types.FissionFetcherSA,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (cfg *Config) SetupServiceAccount(kubernetesClient *kubernetes.Clientset, namespace string, context interface{}) error {
|
||||
_, err := fission.SetupSA(kubernetesClient, fission.FissionFetcherSA, namespace)
|
||||
_, err := utils.SetupSA(kubernetesClient, types.FissionFetcherSA, namespace)
|
||||
if err != nil {
|
||||
log.Printf("Error : %v creating %s in ns : %s for: %#v", err, fission.FissionFetcherSA, namespace, context)
|
||||
log.Printf("Error : %v creating %s in ns : %s for: %#v", err, types.FissionFetcherSA, namespace, context)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@ func (cfg *Config) SharedMountPath() string {
|
||||
return cfg.sharedMountPath
|
||||
}
|
||||
|
||||
func (cfg *Config) NewSpecializeRequest(fn *crd.Function, env *crd.Environment) fission.FunctionSpecializeRequest {
|
||||
func (cfg *Config) NewSpecializeRequest(fn *fv1.Function, env *fv1.Environment) types.FunctionSpecializeRequest {
|
||||
// for backward compatibility, since most v1 env
|
||||
// still try to load user function from hard coded
|
||||
// path /userfunc/user
|
||||
@@ -122,9 +123,9 @@ func (cfg *Config) NewSpecializeRequest(fn *crd.Function, env *crd.Environment)
|
||||
targetFilename = string(fn.Metadata.UID)
|
||||
}
|
||||
|
||||
return fission.FunctionSpecializeRequest{
|
||||
FetchReq: fission.FunctionFetchRequest{
|
||||
FetchType: fission.FETCH_DEPLOYMENT,
|
||||
return types.FunctionSpecializeRequest{
|
||||
FetchReq: types.FunctionFetchRequest{
|
||||
FetchType: types.FETCH_DEPLOYMENT,
|
||||
Package: metav1.ObjectMeta{
|
||||
Namespace: fn.Spec.Package.PackageRef.Namespace,
|
||||
Name: fn.Spec.Package.PackageRef.Name,
|
||||
@@ -134,7 +135,7 @@ func (cfg *Config) NewSpecializeRequest(fn *crd.Function, env *crd.Environment)
|
||||
ConfigMaps: fn.Spec.ConfigMaps,
|
||||
KeepArchive: env.Spec.KeepArchive,
|
||||
},
|
||||
LoadReq: fission.FunctionLoadRequest{
|
||||
LoadReq: types.FunctionLoadRequest{
|
||||
FilePath: filepath.Join(cfg.sharedMountPath, targetFilename),
|
||||
FunctionName: fn.Spec.Package.FunctionName,
|
||||
FunctionMetadata: &fn.Metadata,
|
||||
@@ -147,7 +148,7 @@ func (cfg *Config) AddFetcherToPodSpec(podSpec *apiv1.PodSpec, mainContainerName
|
||||
return cfg.addFetcherToPodSpecWithCommand(podSpec, mainContainerName, cfg.fetcherCommand())
|
||||
}
|
||||
|
||||
func (cfg *Config) AddSpecializingFetcherToPodSpec(podSpec *apiv1.PodSpec, mainContainerName string, fn *crd.Function, env *crd.Environment) error {
|
||||
func (cfg *Config) AddSpecializingFetcherToPodSpec(podSpec *apiv1.PodSpec, mainContainerName string, fn *fv1.Function, env *fv1.Environment) error {
|
||||
specializeReq := cfg.NewSpecializeRequest(fn, env)
|
||||
specializePayload, err := json.Marshal(specializeReq)
|
||||
if err != nil {
|
||||
@@ -179,19 +180,19 @@ func (cfg *Config) fetcherCommand(extraArgs ...string) []string {
|
||||
func (cfg *Config) volumesWithMounts() ([]apiv1.Volume, []apiv1.VolumeMount) {
|
||||
volumes := []apiv1.Volume{
|
||||
{
|
||||
Name: fission.SharedVolumeUserfunc,
|
||||
Name: types.SharedVolumeUserfunc,
|
||||
VolumeSource: apiv1.VolumeSource{
|
||||
EmptyDir: &apiv1.EmptyDirVolumeSource{},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: fission.SharedVolumeSecrets,
|
||||
Name: types.SharedVolumeSecrets,
|
||||
VolumeSource: apiv1.VolumeSource{
|
||||
EmptyDir: &apiv1.EmptyDirVolumeSource{},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: fission.SharedVolumeConfigmaps,
|
||||
Name: types.SharedVolumeConfigmaps,
|
||||
VolumeSource: apiv1.VolumeSource{
|
||||
EmptyDir: &apiv1.EmptyDirVolumeSource{},
|
||||
},
|
||||
@@ -199,15 +200,15 @@ func (cfg *Config) volumesWithMounts() ([]apiv1.Volume, []apiv1.VolumeMount) {
|
||||
}
|
||||
mounts := []apiv1.VolumeMount{
|
||||
{
|
||||
Name: fission.SharedVolumeUserfunc,
|
||||
Name: types.SharedVolumeUserfunc,
|
||||
MountPath: cfg.sharedMountPath,
|
||||
},
|
||||
{
|
||||
Name: fission.SharedVolumeSecrets,
|
||||
Name: types.SharedVolumeSecrets,
|
||||
MountPath: cfg.sharedSecretPath,
|
||||
},
|
||||
{
|
||||
Name: fission.SharedVolumeConfigmaps,
|
||||
Name: types.SharedVolumeConfigmaps,
|
||||
MountPath: cfg.sharedCfgMapPath,
|
||||
},
|
||||
}
|
||||
@@ -296,7 +297,7 @@ func (cfg *Config) addFetcherToPodSpecWithCommand(podSpec *apiv1.PodSpec, mainCo
|
||||
podSpec.Volumes = append(podSpec.Volumes, volumes...)
|
||||
podSpec.Containers = append(podSpec.Containers, c)
|
||||
if podSpec.ServiceAccountName == "" {
|
||||
podSpec.ServiceAccountName = fission.FissionFetcherSA
|
||||
podSpec.ServiceAccountName = types.FissionFetcherSA
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -26,9 +26,12 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
storageSvcClient "github.com/fission/fission/storagesvc/client"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
"github.com/fission/fission/pkg/info"
|
||||
storageSvcClient "github.com/fission/fission/pkg/storagesvc/client"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -111,7 +114,7 @@ func downloadUrl(ctx context.Context, httpClient *http.Client, url string, local
|
||||
return nil
|
||||
}
|
||||
|
||||
func getChecksum(path string) (*fission.Checksum, error) {
|
||||
func getChecksum(path string) (*fv1.Checksum, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -126,18 +129,18 @@ func getChecksum(path string) (*fission.Checksum, error) {
|
||||
|
||||
c := hex.EncodeToString(hasher.Sum(nil))
|
||||
|
||||
return &fission.Checksum{
|
||||
Type: fission.ChecksumTypeSHA256,
|
||||
return &fv1.Checksum{
|
||||
Type: fv1.ChecksumTypeSHA256,
|
||||
Sum: c,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func verifyChecksum(fileChecksum, checksum *fission.Checksum) error {
|
||||
if checksum.Type != fission.ChecksumTypeSHA256 {
|
||||
return fission.MakeError(fission.ErrorInvalidArgument, "Unsupported checksum type")
|
||||
func verifyChecksum(fileChecksum, checksum *fv1.Checksum) error {
|
||||
if checksum.Type != fv1.ChecksumTypeSHA256 {
|
||||
return ferror.MakeError(ferror.ErrorInvalidArgument, "Unsupported checksum type")
|
||||
}
|
||||
if fileChecksum.Sum != checksum.Sum {
|
||||
return fission.MakeError(fission.ErrorChecksumFail, "Checksum validation failed")
|
||||
return ferror.MakeError(ferror.ErrorChecksumFail, "Checksum validation failed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -155,7 +158,7 @@ func writeSecretOrConfigMap(dataMap map[string][]byte, dirPath string) error {
|
||||
|
||||
func (fetcher *Fetcher) VersionHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
fmt.Fprintf(w, fission.BuildInfo().String())
|
||||
fmt.Fprintf(w, info.BuildInfo().String())
|
||||
}
|
||||
|
||||
func (fetcher *Fetcher) FetchHandler(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -177,7 +180,7 @@ func (fetcher *Fetcher) FetchHandler(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
var req fission.FunctionFetchRequest
|
||||
var req types.FunctionFetchRequest
|
||||
err = json.Unmarshal(body, &req)
|
||||
if err != nil {
|
||||
fetcher.logger.Error("error parsing request body", zap.Error(err))
|
||||
@@ -218,7 +221,7 @@ func (fetcher *Fetcher) SpecializeHandler(w http.ResponseWriter, r *http.Request
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
var req fission.FunctionSpecializeRequest
|
||||
var req types.FunctionSpecializeRequest
|
||||
err = json.Unmarshal(body, &req)
|
||||
if err != nil {
|
||||
fetcher.logger.Error("error parsing request body", zap.Error(err))
|
||||
@@ -239,7 +242,7 @@ func (fetcher *Fetcher) SpecializeHandler(w http.ResponseWriter, r *http.Request
|
||||
|
||||
// Fetch takes FetchRequest and makes the fetch call
|
||||
// It returns the HTTP code and error if any
|
||||
func (fetcher *Fetcher) Fetch(ctx context.Context, req fission.FunctionFetchRequest) (int, error) {
|
||||
func (fetcher *Fetcher) Fetch(ctx context.Context, req types.FunctionFetchRequest) (int, error) {
|
||||
// check that the requested filename is not an empty string and error out if so
|
||||
if len(req.Filename) == 0 {
|
||||
e := "fetch request received for an empty file name"
|
||||
@@ -258,7 +261,7 @@ func (fetcher *Fetcher) Fetch(ctx context.Context, req fission.FunctionFetchRequ
|
||||
tmpFile := req.Filename + ".tmp"
|
||||
tmpPath := filepath.Join(fetcher.sharedVolumePath, tmpFile)
|
||||
|
||||
if req.FetchType == fission.FETCH_URL {
|
||||
if req.FetchType == types.FETCH_URL {
|
||||
// fetch the file and save it to the tmp path
|
||||
err := downloadUrl(ctx, fetcher.httpClient, req.Url, tmpPath)
|
||||
if err != nil {
|
||||
@@ -277,16 +280,16 @@ func (fetcher *Fetcher) Fetch(ctx context.Context, req fission.FunctionFetchRequ
|
||||
return http.StatusInternalServerError, errors.Wrap(err, e)
|
||||
}
|
||||
|
||||
var archive *fission.Archive
|
||||
if req.FetchType == fission.FETCH_SOURCE {
|
||||
var archive *fv1.Archive
|
||||
if req.FetchType == types.FETCH_SOURCE {
|
||||
archive = &pkg.Spec.Source
|
||||
} else if req.FetchType == fission.FETCH_DEPLOYMENT {
|
||||
} else if req.FetchType == types.FETCH_DEPLOYMENT {
|
||||
// sometimes, the user may invoke the function even before the source code is built into a deploy pkg.
|
||||
// this results in executor sending a fetch request of type FETCH_DEPLOYMENT and since pkg.Spec.Deployment.Url will be empty,
|
||||
// we hit this "Get : unsupported protocol scheme "" error.
|
||||
// it may be useful to the user if we can send a more meaningful error in such a scenario.
|
||||
if pkg.Status.BuildStatus != fission.BuildStatusSucceeded && pkg.Status.BuildStatus != fission.BuildStatusNone {
|
||||
e := fmt.Sprintf("cannot fetch deployment: package build status was not %q", fission.BuildStatusSucceeded)
|
||||
if pkg.Status.BuildStatus != types.BuildStatusSucceeded && pkg.Status.BuildStatus != types.BuildStatusNone {
|
||||
e := fmt.Sprintf("cannot fetch deployment: package build status was not %q", types.BuildStatusSucceeded)
|
||||
fetcher.logger.Error(e,
|
||||
zap.String("package_name", pkg.Metadata.Name),
|
||||
zap.String("package_namespace", pkg.Metadata.Namespace),
|
||||
@@ -361,7 +364,7 @@ func (fetcher *Fetcher) Fetch(ctx context.Context, req fission.FunctionFetchRequ
|
||||
|
||||
// FetchSecretsAndCfgMaps fetches secrets and configmaps specified by user
|
||||
// It returns the HTTP code and error if any
|
||||
func (fetcher *Fetcher) FetchSecretsAndCfgMaps(secrets []fission.SecretReference, cfgmaps []fission.ConfigMapReference) (int, error) {
|
||||
func (fetcher *Fetcher) FetchSecretsAndCfgMaps(secrets []fv1.SecretReference, cfgmaps []fv1.ConfigMapReference) (int, error) {
|
||||
if len(secrets) > 0 {
|
||||
for _, secret := range secrets {
|
||||
data, err := fetcher.kubeClient.CoreV1().Secrets(secret.Namespace).Get(secret.Name, metav1.GetOptions{})
|
||||
@@ -477,7 +480,7 @@ func (fetcher *Fetcher) UploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var req fission.ArchiveUploadRequest
|
||||
var req types.ArchiveUploadRequest
|
||||
err = json.Unmarshal(body, &req)
|
||||
if err != nil {
|
||||
fetcher.logger.Error("error parsing request body", zap.Error(err))
|
||||
@@ -527,7 +530,7 @@ func (fetcher *Fetcher) UploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
resp := fission.ArchiveUploadResponse{
|
||||
resp := types.ArchiveUploadResponse{
|
||||
ArchiveDownloadUrl: ssClient.GetUrl(fileID),
|
||||
Checksum: *sum,
|
||||
}
|
||||
@@ -583,7 +586,7 @@ func (fetcher *Fetcher) unarchive(src string, dst string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fetcher *Fetcher) SpecializePod(ctx context.Context, fetchReq fission.FunctionFetchRequest, loadReq fission.FunctionLoadRequest) error {
|
||||
func (fetcher *Fetcher) SpecializePod(ctx context.Context, fetchReq types.FunctionFetchRequest, loadReq types.FunctionLoadRequest) error {
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsed := time.Since(startTime)
|
||||
@@ -646,7 +649,7 @@ func (fetcher *Fetcher) SpecializePod(ctx context.Context, fetchReq fission.Func
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
err = fission.MakeErrorFromHTTP(resp)
|
||||
err = ferror.MakeErrorFromHTTP(resp)
|
||||
}
|
||||
|
||||
return errors.Wrap(err, "error specializing function pod")
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
package fission_cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -23,10 +23,10 @@ import (
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/controller/client"
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/fission/util"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -73,17 +73,17 @@ func (w *packageBuildWatcher) watch(ctx context.Context) {
|
||||
// find packages that (a) are in the app spec and (b) have an interesting
|
||||
// build status (either succeeded or failed; not "none")
|
||||
keepWaiting := false
|
||||
buildpkgs := make([]crd.Package, 0)
|
||||
buildpkgs := make([]fv1.Package, 0)
|
||||
for _, pkg := range pkgs {
|
||||
_, ok := w.pkgMeta[mapKey(&pkg.Metadata)]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if pkg.Status.BuildStatus == fission.BuildStatusNone {
|
||||
if pkg.Status.BuildStatus == types.BuildStatusNone {
|
||||
continue
|
||||
}
|
||||
if pkg.Status.BuildStatus == fission.BuildStatusPending ||
|
||||
pkg.Status.BuildStatus == fission.BuildStatusRunning {
|
||||
if pkg.Status.BuildStatus == types.BuildStatusPending ||
|
||||
pkg.Status.BuildStatus == types.BuildStatusRunning {
|
||||
keepWaiting = true
|
||||
}
|
||||
buildpkgs = append(buildpkgs, pkg)
|
||||
@@ -95,10 +95,10 @@ func (w *packageBuildWatcher) watch(ctx context.Context) {
|
||||
if _, printed := w.finished[k]; printed {
|
||||
continue
|
||||
}
|
||||
if pkg.Status.BuildStatus == fission.BuildStatusFailed {
|
||||
if pkg.Status.BuildStatus == types.BuildStatusFailed {
|
||||
w.finished[k] = true
|
||||
fmt.Printf("--- Build FAILED: ---\n%v\n------\n", pkg.Status.BuildLog)
|
||||
} else if pkg.Status.BuildStatus == fission.BuildStatusSucceeded {
|
||||
} else if pkg.Status.BuildStatus == types.BuildStatusSucceeded {
|
||||
w.finished[k] = true
|
||||
fmt.Printf("--- Build SUCCEEDED ---\n")
|
||||
if len(pkg.Status.BuildLog) > 0 {
|
||||
@@ -115,7 +115,7 @@ func (w *packageBuildWatcher) watch(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func pkgKey(pkg *crd.Package) string {
|
||||
func pkgKey(pkg *fv1.Package) string {
|
||||
// packages are mutable so we want to keep track of them by resource version
|
||||
return fmt.Sprintf("%v:%v:%v", pkg.Metadata.Name, pkg.Metadata.Namespace, pkg.Metadata.ResourceVersion)
|
||||
}
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
package fission_cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -25,10 +25,10 @@ import (
|
||||
"github.com/urfave/cli"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/crd"
|
||||
"github.com/fission/fission/fission/log"
|
||||
"github.com/fission/fission/fission/util"
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/fission-cli/log"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
"github.com/fission/fission/pkg/types"
|
||||
)
|
||||
|
||||
func canaryConfigCreate(c *cli.Context) error {
|
||||
@@ -64,7 +64,7 @@ func canaryConfigCreate(c *cli.Context) error {
|
||||
}
|
||||
|
||||
// check that the trigger has function reference type function weights
|
||||
if htTrigger.Spec.FunctionReference.Type != fission.FunctionReferenceTypeFunctionWeights {
|
||||
if htTrigger.Spec.FunctionReference.Type != types.FunctionReferenceTypeFunctionWeights {
|
||||
log.Fatal("Canary config cannot be created for http triggers that do not reference functions by weights")
|
||||
}
|
||||
|
||||
@@ -87,22 +87,22 @@ func canaryConfigCreate(c *cli.Context) error {
|
||||
}
|
||||
|
||||
// finally create canaryCfg in the same namespace as the functions referenced
|
||||
canaryCfg := &crd.CanaryConfig{
|
||||
canaryCfg := &fv1.CanaryConfig{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
Name: canaryConfigName,
|
||||
Namespace: ns,
|
||||
},
|
||||
Spec: fission.CanaryConfigSpec{
|
||||
Spec: fv1.CanaryConfigSpec{
|
||||
Trigger: trigger,
|
||||
NewFunction: newFunc,
|
||||
OldFunction: oldFunc,
|
||||
WeightIncrement: incrementStep,
|
||||
WeightIncrementDuration: incrementInterval,
|
||||
FailureThreshold: failureThreshold,
|
||||
FailureType: fission.FailureTypeStatusCode,
|
||||
FailureType: fv1.FailureTypeStatusCode,
|
||||
},
|
||||
Status: fission.CanaryConfigStatus{
|
||||
Status: fission.CanaryConfigStatusPending,
|
||||
Status: fv1.CanaryConfigStatus{
|
||||
Status: fv1.CanaryConfigStatusPending,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ func canaryConfigUpdate(c *cli.Context) error {
|
||||
}
|
||||
|
||||
if updateNeeded {
|
||||
canaryCfg.Status.Status = fission.CanaryConfigStatusPending
|
||||
canaryCfg.Status.Status = fv1.CanaryConfigStatusPending
|
||||
|
||||
_, err = client.CanaryConfigUpdate(canaryCfg)
|
||||
util.CheckErr(err, "update canary config")
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user