Skip to content

Commit

Permalink
release 3.0.0 (#142)
Browse files Browse the repository at this point in the history
* feat(ci/KAG-1800): add lint and sast workflows using shared actions

* chore(ci): pin shared code quality actions

* chore(*): backport - localize some functions

A commit on master 80ee2e1
introduced localizing some functions. This commit backports that one.

Backports: #92

* fix(healthcheck): fixed incorrect default http_statuses when new() was called multiple times (#83)

* chore(lint): bump kong/public-shared-actions

* docs(README): added 1.5.2 and 1.5.3 releases

* chore(*) rename readme, add release instructions

* chore(healthcheck): fix get_defaults function

* fix(test): fix worker-events test

* release 3.0.0

* chore(github): cancel in progress workflows when new pushed

---------

Co-authored-by: saisatish karra <saisatish.karra@konghq.com>
Co-authored-by: Shuoqing Ding <dsq704136@gmail.com>
Co-authored-by: Vinicius Mignot <vinicius.mignot@gmail.com>
Co-authored-by: Thijs Schreijer <thijs@thijsschreijer.nl>
  • Loading branch information
5 people authored Oct 23, 2023
1 parent d5754c2 commit a2bec67
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 53 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/build_and_test_with_resty_events.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
name: Build and test

on: [push, pull_request]
name: Build and test - with resty_events

concurrency:
# for PR's cancel the running task, if another commit is pushed
group: ${{ github.workflow }} ${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
pull_request: {}
workflow_dispatch: {}
push:
branches:
- main
- master
- release/**

jobs:
build:
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/build_and_test_with_worker_events.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
name: Build and test
name: Build and test - with worker_events

on: [push, pull_request]
concurrency:
# for PR's cancel the running task, if another commit is pushed
group: ${{ github.workflow }} ${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
pull_request: {}
workflow_dispatch: {}
push:
branches:
- main
- master

jobs:
build:
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Lint

concurrency:
# for PR's cancel the running task, if another commit is pushed
group: ${{ github.workflow }} ${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
pull_request: {}
workflow_dispatch: {}
push:
branches:
- main
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
lua-check:
name: Lua Check
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
checks: write
pull-requests: write
if: (github.actor != 'dependabot[bot]')

steps:
- name: Checkout source code
uses: actions/checkout@v3

# Optional step to run on only changed files
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@54849deb963ca9f24185fb5de2965e002d066e6b # v37
with:
files: |
**.lua
- name: Lua Check
if: steps.changed-files.outputs.any_changed == 'true'
uses: Kong/public-shared-actions/code-check-actions/lua-lint@c03e30a36e8a2dde5cbd463229a96aaad7ccad24
with:
additional_args: '--no-default-config --config .luacheckrc'
files: ${{ steps.changed-files.outputs.all_changed_files }}
36 changes: 36 additions & 0 deletions .github/workflows/sast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: SAST

concurrency:
# for PR's cancel the running task, if another commit is pushed
group: ${{ github.workflow }} ${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
pull_request:
paths:
- lib/**.lua
push:
branches:
- master
- main
paths:
- lib/**.lua
workflow_dispatch: {}


jobs:
semgrep:
name: Semgrep SAST
runs-on: ubuntu-latest
permissions:
# required for all workflows
security-events: write
# only required for workflows in private repositories
actions: read
contents: read

if: (github.actor != 'dependabot[bot]')

steps:
- uses: actions/checkout@v3
- uses: Kong/public-shared-actions/security-actions/semgrep@c03e30a36e8a2dde5cbd463229a96aaad7ccad24
37 changes: 37 additions & 0 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ for the complete API.

Versioning is strictly based on [Semantic Versioning](https://semver.org/)

### Releasing new versions:

* update changelog below (PR's should be merged including a changelog entry)
* based on changelog determine new SemVer version
* create a new rockspec
* render the docs using `ldoc` (don't do this within PR's)
* commit as "release x.x.x" (do not include rockspec revision)
* tag the commit with "x.x.x" (do not include rockspec revision)
* push commit and tag
* upload rock to luarocks: `luarocks upload rockspecs/[name] --api-key=abc`

### 3.0.0 (12-Oct-2023)

* Perf: optimize by localizing some functions [#92](https://github.com/Kong/lua-resty-healthcheck/pull/92) (backport)
* Fix: Generate fresh default http_statuses within new() [#83](https://github.com/Kong/lua-resty-healthcheck/pull/83) (backport)

### 2.0.0
--- Version discarded from current & future development

### 1.6.3 (06-Sep-2023)

* Feature: Added support for https_sni [#49](https://github.com/Kong/lua-resty-healthcheck/pull/49) (backport)
Expand Down Expand Up @@ -126,6 +145,24 @@ Versioning is strictly based on [Semantic Versioning](https://semver.org/)
serialization API. If it is unavailable, lua-resty-healthcheck fallbacks to
cjson. [#109](https://github.com/Kong/lua-resty-healthcheck/pull/109)

### 1.5.3 (14-Nov-2022)

* Fix: avoid raising worker events for new targets that were marked for delayed
removal, i.e. targets that already exist in memory only need the removal flag
cleared when added back. [#121](https://github.com/Kong/lua-resty-healthcheck/pull/121)

### 1.5.2 (07-Jul-2022)

* Better handling of `resty.lock` failure modes, adding more checks to ensure the
lock is held before running critical code, and improving the decision whether a
function should be retried after a timeout trying to acquire a lock.
[#113](https://github.com/Kong/lua-resty-healthcheck/pull/113)
* Increased logging for locked function failures.
[#114](https://github.com/Kong/lua-resty-healthcheck/pull/114)
* The cleanup frequency of deleted targets was lowered, cutting the number of
created locks in a short period.
[#116](https://github.com/Kong/lua-resty-healthcheck/pull/116)

### 1.5.1 (23-Mar-2022)

* Fix: avoid breaking active health checks when adding or removing targets.
Expand Down
2 changes: 1 addition & 1 deletion config.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description='Provides active and passive healthchecks (http and tcp) for OpenRes
format='discount'
file='./lib/'
dir='docs'
readme='readme.md'
readme='README.md'
sort=true
sort_modules=true
all=false
Expand Down
96 changes: 50 additions & 46 deletions lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ local tostring = tostring
local ipairs = ipairs
local table_insert = table.insert
local table_remove = table.remove
local table_concat = table.concat
local string_format = string.format
local ssl = require("ngx.ssl")
local resty_timer = require "resty.timer"
Expand Down Expand Up @@ -918,7 +919,7 @@ function checker:set_all_target_statuses_for_hostname(hostname, port, is_healthy
end
end

return all_ok, #errs > 0 and table.concat(errs, "; ") or nil
return all_ok, #errs > 0 and table_concat(errs, "; ") or nil
end


Expand Down Expand Up @@ -1043,7 +1044,7 @@ function checker:run_single_check(ip, port, hostname, hostheader)
if headers_length > 0 then
if is_array(req_headers) then
self:log(WARN, "array headers is deprecated")
headers = table.concat(req_headers, "\r\n")
headers = table_concat(req_headers, "\r\n")
else
headers = new_tab(0, headers_length)
local idx = 0
Expand All @@ -1058,7 +1059,7 @@ function checker:run_single_check(ip, port, hostname, hostheader)
headers[idx] = key .. ": " .. tostring(values)
end
end
headers = table.concat(headers, "\r\n")
headers = table_concat(headers, "\r\n")
end
if #headers > 0 then
headers = headers .. "\r\n"
Expand Down Expand Up @@ -1384,7 +1385,7 @@ local MAXNUM = 2^31 - 1

local function fail(ctx, k, msg)
ctx[#ctx + 1] = k
error(table.concat(ctx, ".") .. ": " .. msg, #ctx + 1)
error(table_concat(ctx, ".") .. ": " .. msg, #ctx + 1)
end


Expand Down Expand Up @@ -1425,51 +1426,52 @@ local function fill_in_settings(opts, defaults, ctx)
end


local defaults = {
name = NO_DEFAULT,
shm_name = NO_DEFAULT,
type = NO_DEFAULT,
events_module = "resty.worker.events",
checks = {
active = {
type = "http",
timeout = 1,
concurrency = 10,
http_path = "/",
https_sni = NO_DEFAULT,
https_verify_certificate = true,
headers = {""},
healthy = {
interval = 0, -- 0 = disabled by default
http_statuses = { 200, 302 },
successes = 2,
local function get_defaults()
return {
name = NO_DEFAULT,
shm_name = NO_DEFAULT,
type = NO_DEFAULT,
events_module = "resty.worker.events",
checks = {
active = {
type = "http",
timeout = 1,
concurrency = 10,
http_path = "/",
https_sni = NO_DEFAULT,
https_verify_certificate = true,
headers = {""},
healthy = {
interval = 0, -- 0 = disabled by default
http_statuses = { 200, 302 },
successes = 2,
},
unhealthy = {
interval = 0, -- 0 = disabled by default
http_statuses = { 429, 404,
500, 501, 502, 503, 504, 505 },
tcp_failures = 2,
timeouts = 3,
http_failures = 5,
},
},
unhealthy = {
interval = 0, -- 0 = disabled by default
http_statuses = { 429, 404,
500, 501, 502, 503, 504, 505 },
tcp_failures = 2,
timeouts = 3,
http_failures = 5,
passive = {
type = "http",
healthy = {
http_statuses = { 200, 201, 202, 203, 204, 205, 206, 207, 208, 226,
300, 301, 302, 303, 304, 305, 306, 307, 308 },
successes = 5,
},
unhealthy = {
http_statuses = { 429, 500, 503 },
tcp_failures = 2,
timeouts = 7,
http_failures = 5,
},
},
},
passive = {
type = "http",
healthy = {
http_statuses = { 200, 201, 202, 203, 204, 205, 206, 207, 208, 226,
300, 301, 302, 303, 304, 305, 306, 307, 308 },
successes = 5,
},
unhealthy = {
http_statuses = { 429, 500, 503 },
tcp_failures = 2,
timeouts = 7,
http_failures = 5,
},
},
},
}

}
end

local function to_set(tbl, key)
local set = {}
Expand Down Expand Up @@ -1539,6 +1541,8 @@ function _M.new(opts)
local active_type = (((opts or EMPTY).checks or EMPTY).active or EMPTY).type
local passive_type = (((opts or EMPTY).checks or EMPTY).passive or EMPTY).type

-- create a new defaults table within new() as defaults table will be modified by to_set function later
local defaults = get_defaults()
local self = fill_in_settings(opts, defaults)

load_events_module(self)
Expand Down
26 changes: 26 additions & 0 deletions rockspecs/lua-resty-healthcheck-3.0.0-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package = "lua-resty-healthcheck"
version = "3.0.0-1"
source = {
url = "git+https://github.com/Kong/lua-resty-healthcheck.git",
tag = "3.0.0"
}
description = {
summary = "Healthchecks for OpenResty to check upstream service status",
detailed = [[
lua-resty-healthcheck is a module that can check upstream service
availability by sending requests and validating responses at timed
intervals.
]],
license = "Apache 2.0",
homepage = "https://github.com/Kong/lua-resty-healthcheck"
}
dependencies = {
"penlight >= 1.9.2",
"lua-resty-timer ~> 1",
}
build = {
type = "builtin",
modules = {
["resty.healthcheck"] = "lib/resty/healthcheck.lua",
}
}
Loading

0 comments on commit a2bec67

Please sign in to comment.