You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "Revolyssup (via GitHub)" <gi...@apache.org> on 2025/03/03 10:14:20 UTC
[PR] fix: resync etcd when a lower revision is found [apisix]
Revolyssup opened a new pull request, #12015:
URL: https://github.com/apache/apisix/pull/12015
### Description
<!-- Please include a summary of the change and which issue is fixed. -->
<!-- Please also include relevant motivation and context. -->
Fixes # (issue)
When using ingress controller in etcd mode, if the ingress restarts the revision in etcd will start over since its stateless.
APISIX on receiving updates ignores the lower revision. This PR makes sure that a full resync is triggered when lower revision is found.
### Checklist
- [ ] I have explained the need for this PR and the problem it solves
- [ ] I have explained the changes or the new features added to this PR
- [ ] I have added tests corresponding to this change
- [ ] I have updated the documentation to reflect this change
- [ ] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)
<!--
Note
1. Mark the PR as draft until it's ready to be reviewed.
2. Always add/update tests for any changes unless you have a good reason.
3. Always update the documentation to reflect the changes made in the PR.
4. Make a new commit to resolve conversations instead of `push -f`.
5. To resolve merge conflicts, merge master instead of rebasing.
6. Use "request review" to notify the reviewer after making changes.
7. Only a reviewer can mark a conversation as resolved.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: resync etcd when a lower revision is found [apisix]
Posted by "membphis (via GitHub)" <gi...@apache.org>.
membphis commented on code in PR #12015:
URL: https://github.com/apache/apisix/pull/12015#discussion_r1977276165
##########
apisix/core/config_etcd.lua:
##########
@@ -262,9 +262,13 @@ local function do_run_watch(premature)
cancel_watch(http_cli)
break
end
- if rev > watch_ctx.rev then
- watch_ctx.rev = rev + 1
+ if rev < watch_ctx.rev then
+ log.warn("received smaller revision, rev=", rev, ", watch_ctx.rev=", watch_ctx.rev,". etcd may be restarted. resyncing....")
Review Comment:
we should use a error log level
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: resync etcd when a lower revision is found [apisix]
Posted by "nic-chen (via GitHub)" <gi...@apache.org>.
nic-chen commented on code in PR #12015:
URL: https://github.com/apache/apisix/pull/12015#discussion_r1980511205
##########
apisix/core/config_etcd.lua:
##########
@@ -262,9 +262,15 @@ local function do_run_watch(premature)
cancel_watch(http_cli)
break
end
- if rev > watch_ctx.rev then
- watch_ctx.rev = rev + 1
+
+ if rev < watch_ctx.rev then
+ log.error("received smaller revision, rev=", rev, ", watch_ctx.rev=",
+ watch_ctx.rev,". etcd may be restarted. resyncing....")
+ produce_res(nil, "restarted")
+ cancel_watch(http_cli)
+ break
end
+ watch_ctx.rev = rev + 1
Review Comment:
what will happen when `rev == watch_ctx.rev` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: resync etcd when a lower revision is found [apisix]
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on code in PR #12015:
URL: https://github.com/apache/apisix/pull/12015#discussion_r1980752912
##########
apisix/core/config_etcd.lua:
##########
@@ -262,9 +262,15 @@ local function do_run_watch(premature)
cancel_watch(http_cli)
break
end
- if rev > watch_ctx.rev then
- watch_ctx.rev = rev + 1
+
+ if rev < watch_ctx.rev then
+ log.error("received smaller revision, rev=", rev, ", watch_ctx.rev=",
+ watch_ctx.rev,". etcd may be restarted. resyncing....")
+ produce_res(nil, "restarted")
+ cancel_watch(http_cli)
+ break
end
+ watch_ctx.rev = rev + 1
Review Comment:
updated the code.
1. Smaller revision -> Cause resync
2. Equal revision -> Do nothing like previous
3. Bigger revision -> Increment watch_ctx.rev
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: resync etcd when a lower revision is found [apisix]
Posted by "guoqqqi (via GitHub)" <gi...@apache.org>.
guoqqqi merged PR #12015:
URL: https://github.com/apache/apisix/pull/12015
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org