Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions .github/workflows/build_and_test_with_resty_events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build:
name: CI using lua-resty-events
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
openresty-version: [1.21.4.1]
Expand All @@ -24,10 +24,10 @@ jobs:
- name: Set environment variables
env:
OPENRESTY_VER: ${{ matrix.openresty-version }}
RESTY_EVENTS_VER: 0.1.2
LUAROCKS_VER: 3.9.0
OPENSSL_VER: 1.1.1q
PCRE_VER: 8.45
RESTY_EVENTS_VER: 0.3.0
LUAROCKS_VER: 3.12.0
OPENSSL_VER: 3.4.1
PCRE_VER: 10.45
run: |
echo "INSTALL_ROOT=/home/runner/work/cache/install-root" >> $GITHUB_ENV
echo "DOWNLOAD_ROOT=/home/runner/work/cache/download-root" >> $GITHUB_ENV
Expand All @@ -39,16 +39,16 @@ jobs:
echo "LD_LIBRARY_PATH=$HOME/install-root/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV

- name: Checkout lua-resty-healthcheck
uses: actions/checkout@v3
uses: actions/checkout@v4

# - name: Lookup build cache
# uses: actions/cache@v3
# id: cache-deps
# with:
# path: |
# /home/runner/work/cache/install-root
# /home/runner/work/cache/download-root
# key: ${{ runner.os }}-${{ hashFiles('**/.github/workflows/build_and_test_with_resty_events.yml') }}-${{ matrix.openresty-version }}
- name: Lookup build cache
uses: actions/cache@v4
id: cache-deps
with:
path: |
/home/runner/work/cache/install-root
/home/runner/work/cache/download-root
key: ${{ runner.os }}-${{ hashFiles('**/.github/workflows/build_and_test_with_resty_events.yml') }}-${{ matrix.openresty-version }}

- name: Add to Path
if: steps.cache-deps.outputs.cache-hit != 'true'
Expand All @@ -65,8 +65,7 @@ jobs:
make install_sw

- name: Checkout lua-resty-events
uses: actions/checkout@v3
if: steps.cache-deps.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: Kong/lua-resty-events
ref: refs/tags/0.1.0
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/build_and_test_with_worker_events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:
jobs:
build:
name: CI using lua-resty-worker-events
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
openresty-version: [1.21.4.1]
openresty-version: [1.27.1.2]

steps:
- name: Update and install OS dependencies
Expand All @@ -28,17 +28,17 @@ jobs:
echo "/usr/local/openresty/nginx/sbin" >> $GITHUB_PATH

- name: Checkout lua-resty-healthcheck
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install OpenResty ${{ matrix.openresty-version }}
env:
OPENRESTY_VER: ${{ matrix.openresty-version }}
run: |
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openresty.list
wget -O - https://openresty.org/package/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/openresty.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openresty.list > /dev/null
sudo apt-get update
sudo apt-get -y install openresty=$OPENRESTY_VER-1~focal1
sudo apt-get -y install openresty=$OPENRESTY_VER-1~jammy1

- name: Install LuaRocks
run: sudo apt-get install -y luarocks
Expand All @@ -54,6 +54,9 @@ jobs:
cpanm --notest --local-lib=$HOME/perl5 local::lib && eval $(perl -I $HOME/perl5/lib/perl5/ -Mlocal::lib)
cpanm --notest Test::Nginx

- name: Checkout lua-resty-healthcheck
uses: actions/checkout@v4

- name: Install lua-resty-healthcheck
run: sudo luarocks make lua-resty-healthcheck-scm-1.rockspec

Expand Down
2 changes: 2 additions & 0 deletions lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ local function incr_counter(self, health_report, ip, port, hostname, limit, ctr_
return true
end

hostname = hostname or ip
port = tonumber(port)
local target = get_target(self, ip, port, hostname)
if not target then
Expand Down Expand Up @@ -979,6 +980,7 @@ function checker:set_target_status(ip, port, hostname, is_healthy)
ip = tostring(assert(ip, "no ip address provided"))
port = assert(tonumber(port), "no port number provided")
assert(type(is_healthy) == "boolean")
hostname = hostname or ip

local health_report = is_healthy and "healthy" or "unhealthy"

Expand Down
36 changes: 18 additions & 18 deletions t/with_resty-events/04-report_success.t
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ GET /t
true
true
--- error_log
healthy SUCCESS increment (1/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '(127.0.0.1:2116)'
event: target status '(127.0.0.1:2116)' from 'false' to 'true'
healthy SUCCESS increment (1/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '(127.0.0.1:2116)'
event: target status '(127.0.0.1:2118)' from 'false' to 'true'
healthy SUCCESS increment (1/3) for '127.0.0.1(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '127.0.0.1(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '127.0.0.1(127.0.0.1:2116)'
event: target status '127.0.0.1(127.0.0.1:2116)' from 'false' to 'true'
healthy SUCCESS increment (1/3) for '127.0.0.1(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '127.0.0.1(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '127.0.0.1(127.0.0.1:2116)'
event: target status '127.0.0.1(127.0.0.1:2118)' from 'false' to 'true'


=== TEST 2: report_success() recovers TCP active = passive
Expand Down Expand Up @@ -180,14 +180,14 @@ GET /t
true
true
--- error_log
healthy SUCCESS increment (1/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '(127.0.0.1:2116)'
event: target status '(127.0.0.1:2116)' from 'false' to 'true'
healthy SUCCESS increment (1/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '(127.0.0.1:2116)'
event: target status '(127.0.0.1:2118)' from 'false' to 'true'
healthy SUCCESS increment (1/3) for '127.0.0.1(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '127.0.0.1(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '127.0.0.1(127.0.0.1:2116)'
event: target status '127.0.0.1(127.0.0.1:2116)' from 'false' to 'true'
healthy SUCCESS increment (1/3) for '127.0.0.1(127.0.0.1:2116)'
healthy SUCCESS increment (2/3) for '127.0.0.1(127.0.0.1:2116)'
healthy SUCCESS increment (3/3) for '127.0.0.1(127.0.0.1:2116)'
event: target status '127.0.0.1(127.0.0.1:2118)' from 'false' to 'true'

=== TEST 3: report_success() is a nop when active.healthy.sucesses == 0
--- http_config eval
Expand Down Expand Up @@ -249,7 +249,7 @@ GET /t
false
--- no_error_log
healthy SUCCESS increment
event: target status '127.0.0.1 (127.0.0.1:2116)' from 'false' to 'true'
event: target status '127.0.0.1(127.0.0.1:2116)' from 'false' to 'true'



Expand Down Expand Up @@ -313,4 +313,4 @@ GET /t
false
--- no_error_log
healthy SUCCESS increment
event: target status '(127.0.0.1:2118)' from 'false' to 'true'
event: target status '127.0.0.1(127.0.0.1:2118)' from 'false' to 'true'
40 changes: 20 additions & 20 deletions t/with_resty-events/05-report_failure.t
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ GET /t
false
false
--- error_log
unhealthy HTTP increment (1/3) for '(127.0.0.1:2117)'
unhealthy HTTP increment (2/3) for '(127.0.0.1:2117)'
unhealthy HTTP increment (3/3) for '(127.0.0.1:2117)'
event: target status '(127.0.0.1:2117)' from 'true' to 'false'
unhealthy HTTP increment (1/3) for '(127.0.0.1:2113)'
unhealthy HTTP increment (2/3) for '(127.0.0.1:2113)'
unhealthy HTTP increment (3/3) for '(127.0.0.1:2113)'
event: target status '(127.0.0.1:2113)' from 'true' to 'false'
unhealthy HTTP increment (1/3) for '127.0.0.1(127.0.0.1:2117)'
unhealthy HTTP increment (2/3) for '127.0.0.1(127.0.0.1:2117)'
unhealthy HTTP increment (3/3) for '127.0.0.1(127.0.0.1:2117)'
event: target status '127.0.0.1(127.0.0.1:2117)' from 'true' to 'false'
unhealthy HTTP increment (1/3) for '127.0.0.1(127.0.0.1:2113)'
unhealthy HTTP increment (2/3) for '127.0.0.1(127.0.0.1:2113)'
unhealthy HTTP increment (3/3) for '127.0.0.1(127.0.0.1:2113)'
event: target status '127.0.0.1(127.0.0.1:2113)' from 'true' to 'false'


=== TEST 2: report_failure() fails TCP active + passive
Expand Down Expand Up @@ -180,12 +180,12 @@ GET /t
false
false
--- error_log
unhealthy TCP increment (1/2) for '(127.0.0.1:2117)'
unhealthy TCP increment (2/2) for '(127.0.0.1:2117)'
event: target status '(127.0.0.1:2117)' from 'true' to 'false'
unhealthy TCP increment (1/2) for '(127.0.0.1:2113)'
unhealthy TCP increment (2/2) for '(127.0.0.1:2113)'
event: target status '(127.0.0.1:2113)' from 'true' to 'false'
unhealthy TCP increment (1/2) for '127.0.0.1(127.0.0.1:2117)'
unhealthy TCP increment (2/2) for '127.0.0.1(127.0.0.1:2117)'
event: target status '127.0.0.1(127.0.0.1:2117)' from 'true' to 'false'
unhealthy TCP increment (1/2) for '127.0.0.1(127.0.0.1:2113)'
unhealthy TCP increment (2/2) for '127.0.0.1(127.0.0.1:2113)'
event: target status '127.0.0.1(127.0.0.1:2113)' from 'true' to 'false'


=== TEST 3: report_failure() is a nop when failure counters == 0
Expand Down Expand Up @@ -253,9 +253,9 @@ GET /t
true
true
--- no_error_log
unhealthy TCP increment (1/2) for '(127.0.0.1:2117)'
unhealthy TCP increment (2/2) for '(127.0.0.1:2117)'
event: target status '(127.0.0.1:2117)' from 'true' to 'false'
unhealthy TCP increment (1/2) for '(127.0.0.1:2113)'
unhealthy TCP increment (2/2) for '(127.0.0.1:2113)'
event: target status '(127.0.0.1:2113)' from 'true' to 'false'
unhealthy TCP increment (1/2) for '127.0.0.1(127.0.0.1:2117)'
unhealthy TCP increment (2/2) for '127.0.0.1(127.0.0.1:2117)'
event: target status '127.0.0.1(127.0.0.1:2117)' from 'true' to 'false'
unhealthy TCP increment (1/2) for '127.0.0.1(127.0.0.1:2113)'
unhealthy TCP increment (2/2) for '127.0.0.1(127.0.0.1:2113)'
event: target status '127.0.0.1(127.0.0.1:2113)' from 'true' to 'false'
44 changes: 22 additions & 22 deletions t/with_resty-events/06-report_http_status.t
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ GET /t
false
false
--- error_log
unhealthy HTTP increment (1/3) for '(127.0.0.1:2119)'
unhealthy HTTP increment (2/3) for '(127.0.0.1:2119)'
unhealthy HTTP increment (3/3) for '(127.0.0.1:2119)'
event: target status '(127.0.0.1:2119)' from 'true' to 'false'
unhealthy HTTP increment (1/3) for '(127.0.0.1:2113)'
unhealthy HTTP increment (2/3) for '(127.0.0.1:2113)'
unhealthy HTTP increment (3/3) for '(127.0.0.1:2113)'
event: target status '(127.0.0.1:2113)' from 'true' to 'false'
unhealthy HTTP increment (1/3) for '127.0.0.1(127.0.0.1:2119)'
unhealthy HTTP increment (2/3) for '127.0.0.1(127.0.0.1:2119)'
unhealthy HTTP increment (3/3) for '127.0.0.1(127.0.0.1:2119)'
event: target status '127.0.0.1(127.0.0.1:2119)' from 'true' to 'false'
unhealthy HTTP increment (1/3) for '127.0.0.1(127.0.0.1:2113)'
unhealthy HTTP increment (2/3) for '127.0.0.1(127.0.0.1:2113)'
unhealthy HTTP increment (3/3) for '127.0.0.1(127.0.0.1:2113)'
event: target status '127.0.0.1(127.0.0.1:2113)' from 'true' to 'false'



Expand Down Expand Up @@ -183,16 +183,16 @@ GET /t
true
true
--- error_log
healthy SUCCESS increment (1/4) for '(127.0.0.1:2119)'
healthy SUCCESS increment (2/4) for '(127.0.0.1:2119)'
healthy SUCCESS increment (3/4) for '(127.0.0.1:2119)'
healthy SUCCESS increment (4/4) for '(127.0.0.1:2119)'
event: target status '(127.0.0.1:2119)' from 'false' to 'true'
healthy SUCCESS increment (1/4) for '(127.0.0.1:2113)'
healthy SUCCESS increment (2/4) for '(127.0.0.1:2113)'
healthy SUCCESS increment (3/4) for '(127.0.0.1:2113)'
healthy SUCCESS increment (4/4) for '(127.0.0.1:2113)'
event: target status '(127.0.0.1:2113)' from 'false' to 'true'
healthy SUCCESS increment (1/4) for '127.0.0.1(127.0.0.1:2119)'
healthy SUCCESS increment (2/4) for '127.0.0.1(127.0.0.1:2119)'
healthy SUCCESS increment (3/4) for '127.0.0.1(127.0.0.1:2119)'
healthy SUCCESS increment (4/4) for '127.0.0.1(127.0.0.1:2119)'
event: target status '127.0.0.1(127.0.0.1:2119)' from 'false' to 'true'
healthy SUCCESS increment (1/4) for '127.0.0.1(127.0.0.1:2113)'
healthy SUCCESS increment (2/4) for '127.0.0.1(127.0.0.1:2113)'
healthy SUCCESS increment (3/4) for '127.0.0.1(127.0.0.1:2113)'
healthy SUCCESS increment (4/4) for '127.0.0.1(127.0.0.1:2113)'
event: target status '127.0.0.1(127.0.0.1:2113)' from 'false' to 'true'


=== TEST 3: report_http_status() with success is a nop when passive.healthy.successes == 0
Expand Down Expand Up @@ -256,7 +256,7 @@ GET /t
false
--- no_error_log
healthy SUCCESS increment
event: target status '127.0.0.1 (127.0.0.1:2119)' from 'false' to 'true'
event: target status '127.0.0.1(127.0.0.1:2119)' from 'false' to 'true'


=== TEST 4: report_http_status() with success is a nop when active.healthy.successes == 0
Expand Down Expand Up @@ -320,7 +320,7 @@ GET /t
false
--- no_error_log
healthy SUCCESS increment
event: target status '127.0.0.1 (127.0.0.1:2119)' from 'false' to 'true'
event: target status '127.0.0.1(127.0.0.1:2119)' from 'false' to 'true'


=== TEST 5: report_http_status() with failure is a nop when passive.unhealthy.http_failures == 0
Expand Down Expand Up @@ -384,7 +384,7 @@ GET /t
true
--- no_error_log
unhealthy HTTP increment
event: target status '127.0.0.1 (127.0.0.1:2119)' from 'true' to 'false'
event: target status '127.0.0.1(127.0.0.1:2119)' from 'true' to 'false'


=== TEST 4: report_http_status() with success is a nop when active.unhealthy.http_failures == 0
Expand Down Expand Up @@ -448,7 +448,7 @@ GET /t
true
--- no_error_log
unhealthy HTTP increment
event: target status '(127.0.0.1:2119)' from 'true' to 'false'
event: target status '127.0.0.1(127.0.0.1:2119)' from 'true' to 'false'


=== TEST 5: report_http_status() must work in log phase
Expand Down
20 changes: 10 additions & 10 deletions t/with_resty-events/07-report_tcp_failure.t
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ GET /t
false
false
--- error_log
unhealthy TCP increment (1/3) for '(127.0.0.1:2120)'
unhealthy TCP increment (2/3) for '(127.0.0.1:2120)'
unhealthy TCP increment (3/3) for '(127.0.0.1:2120)'
event: target status '(127.0.0.1:2120)' from 'true' to 'false'
unhealthy TCP increment (1/3) for '(127.0.0.1:2113)'
unhealthy TCP increment (2/3) for '(127.0.0.1:2113)'
unhealthy TCP increment (3/3) for '(127.0.0.1:2113)'
event: target status '(127.0.0.1:2113)' from 'true' to 'false'
unhealthy TCP increment (1/3) for '127.0.0.1(127.0.0.1:2120)'
unhealthy TCP increment (2/3) for '127.0.0.1(127.0.0.1:2120)'
unhealthy TCP increment (3/3) for '127.0.0.1(127.0.0.1:2120)'
event: target status '127.0.0.1(127.0.0.1:2120)' from 'true' to 'false'
unhealthy TCP increment (1/3) for '127.0.0.1(127.0.0.1:2113)'
unhealthy TCP increment (2/3) for '127.0.0.1(127.0.0.1:2113)'
unhealthy TCP increment (3/3) for '127.0.0.1(127.0.0.1:2113)'
event: target status '127.0.0.1(127.0.0.1:2113)' from 'true' to 'false'


=== TEST 2: report_tcp_failure() for active is a nop when active.unhealthy.tcp_failures == 0
Expand Down Expand Up @@ -175,7 +175,7 @@ GET /t
true
--- no_error_log
unhealthy TCP increment
event: target status '(127.0.0.1:2120)' from 'true' to 'false'
event: target status '127.0.0.1(127.0.0.1:2120)' from 'true' to 'false'



Expand Down Expand Up @@ -239,4 +239,4 @@ GET /t
true
--- no_error_log
unhealthy TCP increment
event: target status '(127.0.0.1:2120)' from 'true' to 'false'
event: target status '127.0.0.1(127.0.0.1:2120)' from 'true' to 'false'
16 changes: 8 additions & 8 deletions t/with_resty-events/08-report_timeout.t
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ GET /t
false
false
--- error_log
unhealthy TIMEOUT increment (1/2) for '(127.0.0.1:2122)'
unhealthy TIMEOUT increment (2/2) for '(127.0.0.1:2122)'
event: target status '(127.0.0.1:2122)' from 'true' to 'false'
unhealthy TIMEOUT increment (1/2) for '(127.0.0.1:2113)'
unhealthy TIMEOUT increment (2/2) for '(127.0.0.1:2113)'
event: target status '(127.0.0.1:2113)' from 'true' to 'false'
unhealthy TIMEOUT increment (1/2) for '127.0.0.1(127.0.0.1:2122)'
unhealthy TIMEOUT increment (2/2) for '127.0.0.1(127.0.0.1:2122)'
event: target status '127.0.0.1(127.0.0.1:2122)' from 'true' to 'false'
unhealthy TIMEOUT increment (1/2) for '127.0.0.1(127.0.0.1:2113)'
unhealthy TIMEOUT increment (2/2) for '127.0.0.1(127.0.0.1:2113)'
event: target status '127.0.0.1(127.0.0.1:2113)' from 'true' to 'false'


=== TEST 2: report_timeout() for active is a nop when active.unhealthy.timeouts == 0
Expand Down Expand Up @@ -175,7 +175,7 @@ GET /t
true
--- no_error_log
unhealthy TCP increment
event: target status '(127.0.0.1:2122)' from 'true' to 'false'
event: target status '127.0.0.1(127.0.0.1:2122)' from 'true' to 'false'



Expand Down Expand Up @@ -241,4 +241,4 @@ GET /t
true
--- no_error_log
unhealthy TCP increment
event: target status '(127.0.0.1:2122)' from 'true' to 'false'
event: target status '127.0.0.1(127.0.0.1:2122)' from 'true' to 'false'
Loading