Refactor logging to remove logger, use fluentd with kubernetes filter (#380)
Remove the `logger` container from the logging daemonset. Remove the outgoing call from the poolmgr to the logger. Use Fluentd's Kubernetes filter to add function name and UID to influx metadata. This means fluentd now figures out when to start collecting function logs on its own, without being informed by poolmgr. This is great for other execution strategies, and for autoscaling, where fission isn't in direct control of function pod creation. Also adds an integration test to make sure logging keeps working.
This commit is contained in:
committed by
Soam Vasani
parent
74e05ba3a1
commit
8b40ad0b33
@@ -13,6 +13,7 @@ source $(dirname $0)/test_utils.sh
|
||||
REPO=gcr.io/fission-ci
|
||||
IMAGE=$REPO/fission-bundle
|
||||
FETCHER_IMAGE=$REPO/fetcher
|
||||
FLUENTD_IMAGE=gcr.io/fission-ci/fluentd
|
||||
TAG=test
|
||||
|
||||
build_and_push_fission_bundle $IMAGE:$TAG
|
||||
@@ -27,6 +28,8 @@ build_and_push_env_runtime $ENV $REPO/$ENV-env:$TAG
|
||||
|
||||
build_and_push_env_builder $ENV $REPO/$ENV-env-builder:$TAG
|
||||
|
||||
build_and_push_fluentd $FLUENTD_IMAGE:$TAG
|
||||
|
||||
build_fission_cli
|
||||
|
||||
install_and_test $IMAGE $TAG $FETCHER_IMAGE $TAG
|
||||
install_and_test $IMAGE $TAG $FETCHER_IMAGE $TAG $FLUENTD_IMAGE $TAG
|
||||
|
||||
+18
-2
@@ -56,6 +56,19 @@ build_builder() {
|
||||
popd
|
||||
}
|
||||
|
||||
build_and_push_fluentd(){
|
||||
image_tag=$1
|
||||
|
||||
pushd $ROOT/logger/fluentd
|
||||
docker build -t $image_tag .
|
||||
|
||||
gcloud_login
|
||||
|
||||
gcloud docker -- push $image_tag
|
||||
popd
|
||||
|
||||
}
|
||||
|
||||
build_and_push_env_runtime() {
|
||||
env=$1
|
||||
image_tag=$2
|
||||
@@ -110,11 +123,12 @@ helm_install_fission() {
|
||||
fetcherImageTag=$5
|
||||
controllerNodeport=$6
|
||||
routerNodeport=$7
|
||||
fluentdImage=$8
|
||||
|
||||
ns=f-$id
|
||||
fns=f-func-$id
|
||||
|
||||
helmVars=image=$image,imageTag=$imageTag,fetcherImage=$fetcherImage,fetcherImageTag=$fetcherImageTag,functionNamespace=$fns,controllerPort=$controllerNodeport,routerPort=$routerNodeport,pullPolicy=Always,analytics=false
|
||||
helmVars=image=$image,imageTag=$imageTag,fetcherImage=$fetcherImage,fetcherImageTag=$fetcherImageTag,functionNamespace=$fns,controllerPort=$controllerNodeport,routerPort=$routerNodeport,pullPolicy=Always,analytics=false,logger.fluentdImage=$fluentdImage
|
||||
|
||||
helm_setup
|
||||
|
||||
@@ -280,6 +294,8 @@ install_and_test() {
|
||||
imageTag=$2
|
||||
fetcherImage=$3
|
||||
fetcherImageTag=$4
|
||||
fluentdImage=$5
|
||||
fluentdImageTag=$6
|
||||
|
||||
controllerPort=31234
|
||||
routerPort=31235
|
||||
@@ -288,7 +304,7 @@ install_and_test() {
|
||||
|
||||
id=$(generate_test_id)
|
||||
trap "helm_uninstall_fission $id" EXIT
|
||||
if ! helm_install_fission $id $image $imageTag $fetcherImage $fetcherImageTag $controllerPort $routerPort
|
||||
if ! helm_install_fission $id $image $imageTag $fetcherImage $fetcherImageTag $controllerPort $routerPort $fluentdImage:$fluentdImageTag
|
||||
then
|
||||
dump_logs $id
|
||||
exit 1
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
module.exports = async function(context) {
|
||||
console.log("log test log test log test")
|
||||
return {
|
||||
status: 200,
|
||||
body: "Log, test!\n"
|
||||
};
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(dirname $0)/../..
|
||||
|
||||
fn=nodejs-logtest
|
||||
|
||||
|
||||
function cleanup {
|
||||
echo "Cleanup route"
|
||||
var=$(fission route list | grep $fn | awk '{print $1;}')
|
||||
fission route delete --name $var
|
||||
fission function delete --name $fn
|
||||
}
|
||||
|
||||
# Create a hello world function in nodejs, test it with an http trigger
|
||||
echo "Pre-test cleanup"
|
||||
fission env delete --name nodejs || true
|
||||
|
||||
echo "Creating nodejs env"
|
||||
fission env create --name nodejs --image fission/node-env
|
||||
trap "fission env delete --name nodejs" EXIT
|
||||
|
||||
echo "Creating function"
|
||||
fission fn create --name $fn --env nodejs --code log.js
|
||||
trap "fission fn delete --name $fn" EXIT
|
||||
|
||||
echo "Creating route"
|
||||
fission route create --function $fn --url /logtest --method GET
|
||||
|
||||
echo "Waiting for router to catch up"
|
||||
sleep 3
|
||||
|
||||
echo "Doing 4 HTTP GET on the function's route"
|
||||
curl http://$FISSION_ROUTER/logtest
|
||||
curl http://$FISSION_ROUTER/logtest
|
||||
curl http://$FISSION_ROUTER/logtest
|
||||
curl http://$FISSION_ROUTER/logtest
|
||||
|
||||
|
||||
echo "Grabbing logs, should have 4 calls in logs"
|
||||
|
||||
sleep 15
|
||||
|
||||
echo "woke up"
|
||||
logs=$(fission function logs --name $fn)
|
||||
num=$(echo "$logs" | grep 'log test' | wc -l)
|
||||
echo $num
|
||||
|
||||
if [ $num -ne 4 ]
|
||||
then
|
||||
echo "Test Failed"
|
||||
trap cleanup EXIT
|
||||
fi
|
||||
cleanup
|
||||
|
||||
echo "All done."
|
||||
Reference in New Issue
Block a user