Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
38.83k stars 4.77k forks source link

Fail to run Kong from compiled source code as mentioned on DEVELOPER.md #11554

Closed DGideas closed 1 year ago

DGideas commented 1 year ago

Is there an existing issue for this?

Kong version ($ kong version)

3.4.0

Current Behavior

I use a clean Ubuntu 22.04 LTS on a x86_64 machine. And I want to compile Kong from source code. The following bash script is majorly from DEVELOPER.md and I run them as root user:

cd ~
sudo apt update \
&& sudo apt install -y \
    automake \
    build-essential \
    curl \
    file \
    git \
    libyaml-dev \
    libprotobuf-dev \
    m4 \
    perl \
    pkg-config \
    procps \
    unzip \
    valgrind \
    zlib1g-dev \
    docker-compose
git clone https://github.com/Kong/kong
cd kong
git checkout 3.4.0
export GITHUB_TOKEN=github_xxx
make build-venv

When finish building Kong, I use the following code originally from DEVELOPER.md try to start Kong:

source /root/kong/bazel-bin/build/kong-dev-venv.sh # venv
start_services
kong migrations bootstrap
kong start

When executes on kong start, I met this exception:

# kong start
2023/09/12 20:52:26 [warn] ulimit is currently set to "1024". For better performance set it to at least "4096" using "ulimit -n"
2023/09/12 20:52:26 [warn] ulimit is currently set to "1024". For better performance set it to at least "4096" using "ulimit -n"
Error: ...azel-bin/build/kong-dev/share/lua/5.1/kong/cmd/start.lua:98: nginx: [error] init_by_lua error: ...el-bin/build/kong-dev/share/lua/5.1/kong/tools/utils.lua:786: error loading module 'kong.plugins.opentelemetry.handler':
...s/kong/bazel-bin/build/kong-dev/share/lua/5.1/protoc.lua:342: module load error: opentelemetry/proto/collector/trace/v1/trace_service.proto
    opentelemetry/proto/collector/trace/v1/trace_service.proto: No such file or directory
    ./opentelemetry/proto/collector/trace/v1/trace_service.proto: No such file or directory
    /usr/local/kong/include/opentelemetry/proto/collector/trace/v1/trace_service.proto: No such file or directory
    /usr/local/opt/protobuf/include//opentelemetry/proto/collector/trace/v1/trace_service.proto: No such file or directory
    /usr/include/opentelemetry/proto/collector/trace/v1/trace_service.proto: No such file or directory
    kong/include/opentelemetry/proto/collector/trace/v1/trace_service.proto: No such file or directory
    spec/fixtures/grpc/opentelemetry/proto/collector/trace/v1/trace_service.proto: No such file or directory
stack traceback:
    [C]: in function 'error'
    ...s/kong/bazel-bin/build/kong-dev/share/lua/5.1/protoc.lua:342: in function 'f'
    ...s/kong/bazel-bin/build/kong-dev/share/lua/5.1/protoc.lua:1149: in function 'do_compile'
    ...s/kong/bazel-bin/build/kong-dev/share/lua/5.1/protoc.lua:1165: in function 'compilefile'
    ...s/kong/bazel-bin/build/kong-dev/share/lua/5.1/protoc.lua:1178: in function 'loadfile'
    ...g-dev/share/lua/5.1/kong/plugins/opentelemetry/proto.lua:9: in function 'load_proto'
    ...g-dev/share/lua/5.1/kong/plugins/opentelemetry/proto.lua:12: in main chunk
    [C]: in function 'require'
    ...ng-dev/share/lua/5.1/kong/plugins/opentelemetry/otlp.lua:1: in main chunk
    [C]: in function 'require'
    ...dev/share/lua/5.1/kong/plugins/opentelemetry/handler.lua:4: in main chunk
    [C]: at 0x7f55a26e0310
    [C]: in function 'xpcall'
    ...el-bin/build/kong-dev/share/lua/5.1/kong/tools/utils.lua:777: in function 'load_module_if_exists'
    ...bin/build/kong-dev/share/lua/5.1/kong/db/dao/plugins.lua:154: in function 'load_plugin_handler'
    ...bin/build/kong-dev/share/lua/5.1/kong/db/dao/plugins.lua:260: in function 'load_plugin'
    ...bin/build/kong-dev/share/lua/5.1/kong/db/dao/plugins.lua:312: in function 'load_plugin_schemas'
    ...ong/bazel-bin/build/kong-dev/share/lua/5.1/kong/init.lua:629: in function 'init'
    init_by_lua:3: in main chunk
stack traceback:
    [C]: in function 'error'
    ...el-bin/build/kong-dev/share/lua/5.1/kong/tools/utils.lua:786: in function 'load_module_if_exists'
    ...bin/build/kong-dev/share/lua/5.1/kong/db/dao/plugins.lua:154: in function 'load_plugin_handler'
    ...bin/build/kong-dev/share/lua/5.1/kong/db/dao/plugins.lua:260: in function 'load_plugin'
    ...bin/build/kong-dev/share/lua/5.1/kong/db/dao/plugins.lua:312: in function 'load_plugin_schemas'
    ...ong/bazel-bin/build/kong-dev/share/lua/5.1/kong/init.lua:629: in function 'init'
    init_by_lua:3: in main chunk

  Run with --v (verbose) or --vv (debug) for more details

Expected Behavior

The Kong should start normally.

Steps To Reproduce

(Please see "Current Behavior" section, I have paste all the script I executed there)

Anything else?

n/a

DGideas commented 1 year ago

By the way, I fixed it by executing make install as root user. However, this behavior has not been mentioned in DEVELOPER.md. I am curious if other users are able to start their development environment successfully without executing make install?

DGideas commented 1 year ago

Eventually I found the reason why Kong raises Error: ...azel-bin/build/kong-dev/share/lua/5.1/kong/cmd/start.lua:98: nginx: [error] init_by_lua error..., you need to switch your working directory to ~/kong/ (or your kong source code directory) then execute kong start

DGideas commented 1 year ago

If you meet exception from opentelemetry or PATH, you need to execute the following code:

echo 'PATH=$PATH:~/home/user/kong/bazel-bin/build/kong-dev/openresty/bin' | sudo tee -a ~/.bashrc
echo 'PATH=$PATH:~/home/user/kong/bazel-bin/build/kong-dev/openresty/nginx/sbin' | sudo tee -a ~/.bashrc
echo 'PATH=$PATH:~/home/user/kong/bazel-bin/build/kong-dev/bin' | sudo tee -a ~/.bashrc

The user mentioned above could be /root, these code from .github/workflows/perf.yml:63