From f0dc2554a1adf79362fe0f71dadb19c155abd1f2 Mon Sep 17 00:00:00 2001 From: smruthi2187 <34555664+smruthi2187@users.noreply.github.com> Date: Thu, 3 May 2018 07:51:48 -0700 Subject: [PATCH] Meaningful error message when fetch request is received for a package when build is not successful. (#661) --- environments/fetcher/fetcher.go | 9 +++++++++ test/tests/test_fn_update/test_nd_pkg_update.sh | 2 +- test/tests/test_fn_update/test_poolmgr_nd.sh | 4 ++-- test/tests/test_fn_update/test_resource_change.sh | 2 +- test/tests/test_fn_update/test_scale_change.sh | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/environments/fetcher/fetcher.go b/environments/fetcher/fetcher.go index f0b4d932..157da92c 100644 --- a/environments/fetcher/fetcher.go +++ b/environments/fetcher/fetcher.go @@ -254,6 +254,15 @@ func (fetcher *Fetcher) Fetch(req FetchRequest) (int, error) { if req.FetchType == FETCH_SOURCE { archive = &pkg.Spec.Source } else if req.FetchType == 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("Build status for the function's pkg : %s.%s is : %s, can't fetch deployment", pkg.Metadata.Name, pkg.Metadata.Namespace, pkg.Status.BuildStatus) + log.Printf(e) + return 500, errors.New(e) + } archive = &pkg.Spec.Deployment } // get package data as literal or by url diff --git a/test/tests/test_fn_update/test_nd_pkg_update.sh b/test/tests/test_fn_update/test_nd_pkg_update.sh index c5d2e11a..1b68161c 100755 --- a/test/tests/test_fn_update/test_nd_pkg_update.sh +++ b/test/tests/test_fn_update/test_nd_pkg_update.sh @@ -50,7 +50,7 @@ sed -i 's/world/fission/' test_dir/hello.py zip -jr test-deploy-pkg.zip test_dir/ log "Updating function with updated package" -fission fn update --name $fn_name --env $env --deploy test-deploy-pkg.zip --entrypoint "hello.main" --executortype newdeploy --minscale 1 --maxscale 4 --targetcpu 50 +fission fn update --name $fn_name --deploy test-deploy-pkg.zip --entrypoint "hello.main" --executortype newdeploy --minscale 1 --maxscale 4 --targetcpu 50 log "Waiting for deployment to update" sleep 5 diff --git a/test/tests/test_fn_update/test_poolmgr_nd.sh b/test/tests/test_fn_update/test_poolmgr_nd.sh index 981f6df3..de1cf22a 100755 --- a/test/tests/test_fn_update/test_poolmgr_nd.sh +++ b/test/tests/test_fn_update/test_poolmgr_nd.sh @@ -25,7 +25,7 @@ sleep 5 timeout 60 bash -c "test_fn $fn 'world'" log "Updating function $fn executor type to new deployment" -fission fn update --name $fn --env $env --code $ROOT/examples/python/hello.py --minscale 1 --maxscale 4 --executortype newdeploy +fission fn update --name $fn --code $ROOT/examples/python/hello.py --minscale 1 --maxscale 4 --executortype newdeploy log "Waiting for router to catch up" sleep 5 @@ -33,7 +33,7 @@ sleep 5 timeout 60 bash -c "test_fn $fn 'world'" log "Updating function $fn executor type back to pool manager" -fission fn update --name $fn --env $env --code $ROOT/examples/python/hello.py --executortype poolmgr +fission fn update --name $fn --code $ROOT/examples/python/hello.py --executortype poolmgr log "Waiting for router to catch up" sleep 5 diff --git a/test/tests/test_fn_update/test_resource_change.sh b/test/tests/test_fn_update/test_resource_change.sh index ee4db460..2e7f51d2 100755 --- a/test/tests/test_fn_update/test_resource_change.sh +++ b/test/tests/test_fn_update/test_resource_change.sh @@ -55,7 +55,7 @@ fi timeout 60 bash -c "test_fn $fn 'world'" log "Updating function $fn with new resource values" -fission fn update --name $fn --env $env --code $ROOT/examples/python/hello.py --minscale 1 --maxscale 4 --executortype newdeploy --mincpu $mincpu2 --maxcpu $maxcpu2 --minmemory $minmem2 --maxmemory $maxmem2 +fission fn update --name $fn --code $ROOT/examples/python/hello.py --minscale 1 --maxscale 4 --executortype newdeploy --mincpu $mincpu2 --maxcpu $maxcpu2 --minmemory $minmem2 --maxmemory $maxmem2 maxcpu_actual=$(kubectl get $func $fn -n default -ojsonpath='{.spec.resources.limits.cpu}'|tr -dc '0-9') mincpu_actual=$(kubectl get $func $fn -n default -ojsonpath='{.spec.resources.requests.cpu}'|tr -dc '0-9') diff --git a/test/tests/test_fn_update/test_scale_change.sh b/test/tests/test_fn_update/test_scale_change.sh index 93959408..b48fb64d 100755 --- a/test/tests/test_fn_update/test_scale_change.sh +++ b/test/tests/test_fn_update/test_scale_change.sh @@ -28,7 +28,7 @@ sleep 5 timeout 60 bash -c "test_fn $fn 'world'" log "Updating function scale and target CPU percent for $fn" -fission fn update --name $fn --env $env --code $ROOT/examples/python/hello.py --minscale $targetMinScale --maxscale $targetMaxScale --targetcpu $targetCpuPercent --executortype newdeploy --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256 +fission fn update --name $fn --code $ROOT/examples/python/hello.py --minscale $targetMinScale --maxscale $targetMaxScale --targetcpu $targetCpuPercent --executortype newdeploy --mincpu 20 --maxcpu 100 --minmemory 128 --maxmemory 256 log "Waiting for update to catch up" sleep 5