deps: upgrade lua-resty-limit-traffic from 1.0.0 to 1.2.0#455
deps: upgrade lua-resty-limit-traffic from 1.0.0 to 1.2.0#455
Conversation
Align apisix-runtime with api7ee-runtime by upgrading lua-resty-limit-traffic from v1.0.0 to v1.2.0. Key changes in the library: - incoming_new() now counts UP (returns consumed) instead of DOWN (remaining) - Removed assert(cost >= 1), allowing cost=0 for dry_run peek operations - Callers need to convert consumed to remaining: remaining = limit - consumed This is a prerequisite for making the limit-count plugin's dry_run behavior consistent between open-source APISIX and the enterprise edition.
📝 WalkthroughWalkthroughThe build scripts were modified to change which Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
build-apisix-runtime.sh (1)
148-158: Consolidate lua-resty-limit-traffic versions across build scripts.Both
build-apisix-runtime.shandbuild-apisix-base.shdefineor_limit_ver=0.09as the target directory, but download different versions: runtime uses1.2.0(line 154) while base uses1.0.0(line 122). This version drift can cause inconsistent builds. Update both scripts to use the same version or centralize the version pin.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@build-apisix-runtime.sh` around lines 148 - 158, The build script uses inconsistent versions for lua-resty-limit-traffic (or_limit_ver and limit_ver): ensure both build-apisix-runtime.sh and build-apisix-base.sh use the same pinned version by centralizing the version into a single variable (e.g., LIMIT_TRAFFIC_VERSION) and replacing the separate limit_ver/or_limit_ver usages; update the download (wget), untar, and move logic to reference that single variable so the bundle directory name and the downloaded tarball version remain consistent across both scripts.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@build-apisix-runtime.sh`:
- Around line 154-157: The runtime script pins lua-resty-limit-traffic to v1.2.0
(with resty.limit.count.incoming() now returning consumed) while
build-apisix-base.sh still uses v1.0.0 and apisix-nginx-module 1.19.3 expects
remaining, causing incorrect limit decisions; reconcile by either (A) pin both
build-apisix-runtime.sh and build-apisix-base.sh to the same safe version (e.g.,
v1.0.0) by changing the limit_ver in build-apisix-runtime.sh to match
build-apisix-base.sh, or (B) update both scripts to the new version and then
update the caller code that invokes resty.limit.count.incoming() (search for
resty.limit.count.incoming(), apisix-nginx-module limit/count call sites) to
convert consumed -> remaining (remaining = limit - consumed) before making
allow/deny decisions, and also fix the obvious variable typo in the runtime
script mv command that uses $or_limit_ver to use the correct variable name so
the bundle directory is named consistently.
---
Nitpick comments:
In `@build-apisix-runtime.sh`:
- Around line 148-158: The build script uses inconsistent versions for
lua-resty-limit-traffic (or_limit_ver and limit_ver): ensure both
build-apisix-runtime.sh and build-apisix-base.sh use the same pinned version by
centralizing the version into a single variable (e.g., LIMIT_TRAFFIC_VERSION)
and replacing the separate limit_ver/or_limit_ver usages; update the download
(wget), untar, and move logic to reference that single variable so the bundle
directory name and the downloaded tarball version remain consistent across both
scripts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d84dbfe0-ef8e-41d8-ac14-fe1541561986
📒 Files selected for processing (1)
build-apisix-runtime.sh
…ase.sh Keep both build scripts consistent.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
build-apisix-base.sh (1)
116-126: Centralize thelimit_verdeclaration to prevent version skew between build scripts.Both
build-apisix-base.shandbuild-apisix-runtime.shindependently declarelimit_ver=1.2.0(lines 122 and 154 respectively). Since upgradinglua-resty-limit-trafficrequires both scripts to stay synchronized—especially for breaking changes like v1.0.0→v1.2.0 which alter the API return semantics—duplicating this value introduces maintenance risk. Define the version once in a shared configuration file or enforced wrapper script.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@build-apisix-base.sh` around lines 116 - 126, The scripts duplicate the lua-resty-limit-traffic version (limit_ver=1.2.0) which risks skew; centralize the version by moving the declaration into a single shared config or wrapper and have both build-apisix-base.sh and build-apisix-runtime.sh read that variable (e.g., source a file like common_build_vars.sh or read LIMIT_VER env var) instead of defining limit_ver locally; update references to limit_ver and ensure or_limit_ver usage remains consistent so both scripts use the same authoritative version value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@build-apisix-base.sh`:
- Around line 116-126: The scripts duplicate the lua-resty-limit-traffic version
(limit_ver=1.2.0) which risks skew; centralize the version by moving the
declaration into a single shared config or wrapper and have both
build-apisix-base.sh and build-apisix-runtime.sh read that variable (e.g.,
source a file like common_build_vars.sh or read LIMIT_VER env var) instead of
defining limit_ver locally; update references to limit_ver and ensure
or_limit_ver usage remains consistent so both scripts use the same authoritative
version value.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3f5ab3da-878a-4c90-bd59-46d5835654a1
📒 Files selected for processing (1)
build-apisix-base.sh
Description
Upgrade
lua-resty-limit-trafficfrom v1.0.0 to v1.2.0 in bothbuild-apisix-runtime.shandbuild-apisix-base.sh.Why
This aligns the open-source
apisix-runtimeandapisix-basewith the enterpriseapi7ee-runtime, which already uses v1.2.0.Key library change in v1.2.0:
incoming_new()counts UP from 0 (returns consumed count) instead of DOWN from limit (returns remaining count), and removes theassert(cost >= 1)restriction.The companion APISIX PR (apache/apisix#13191) adapts
limit-count-local.luato handle the new return value semantics (consumed → remaining conversion).Changes
build-apisix-runtime.sh:limit_ver=1.0.0→limit_ver=1.2.0build-apisix-base.sh:limit_ver=1.0.0→limit_ver=1.2.0Summary by CodeRabbit