Skip to content

feat: add healthcheck for sync configuration#12200

Merged
Revolyssup merged 65 commits into
apache:masterfrom
Revolyssup:revolyssup/healthcheck-standalone
May 21, 2025
Merged

feat: add healthcheck for sync configuration#12200
Revolyssup merged 65 commits into
apache:masterfrom
Revolyssup:revolyssup/healthcheck-standalone

Conversation

@Revolyssup

@Revolyssup Revolyssup commented May 8, 2025

Copy link
Copy Markdown
Contributor

image

Description

  • Standalone mode: This PR aims to add a healthcheck endpoint which can be used by to indicate where APISIX is ready and has loaded the configuration from clients such as ingress controller.
  • Config provider etcd: The above endpoint can be used to get the healthcheck status which will be false until all the workers have first time loaded the configuration from etcd.

Refer: #12179 (review)

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 first)

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 8, 2025
@Revolyssup
Revolyssup marked this pull request as draft May 8, 2025 14:07
@dosubot dosubot Bot added the enhancement New feature or request label May 8, 2025
@Revolyssup
Revolyssup marked this pull request as ready for review May 12, 2025 18:32
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 12, 2025
@Revolyssup
Revolyssup requested review from bzp2010 and nic-6443 May 12, 2025 19:50
Comment thread apisix/cli/config.lua Outdated
Comment thread apisix/cli/ngx_tpl.lua Outdated
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 13, 2025
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 20, 2025
@Revolyssup
Revolyssup requested review from bzp2010 and kayx23 May 20, 2025 11:15

@bzp2010 bzp2010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

nic-6443
nic-6443 previously approved these changes May 21, 2025

```json
{
"status": "ok"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the status is not ok? The section below shows output when its "not ok" - what about this section?

@Revolyssup Revolyssup May 21, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If APISIX is running, this endpoint will always return 200 and no other response. If APISIX is not running, then it wouldn't return any HTTP response, the request will error out while establishing tcp connection.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. Maybe add a sentence at the end of this section?

If APISIX is not running, the request will error out while establishing TCP connection.

wdyt

Comment thread docs/en/latest/status-api.md Outdated

Returns `ok` when all workers have loaded the configuration, otherwise returns the specific error with `503` error code. Below are specific examples.

When all workers have loaded the configuration

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When all workers have loaded the configuration
When all workers have loaded the configuration:

Please do the same for other sentences missing punctuation in this doc.

Comment thread docs/zh/latest/status-api.md Outdated
#
-->

在 Apache APISIX 中,状态 API 用于:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
在 Apache APISIX 中,状态 API 用于:
在 Apache APISIX 中,Status API 用于:

Comment thread docs/zh/latest/status-api.md Outdated
在 Apache APISIX 中,状态 API 用于:

* 检查 APISIX 是否已成功启动并正确运行
* 检查所有工作人员是否已收到并加载配置。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 检查所有工作人员是否已收到并加载配置
* 检查所有 workers 是否已收到配置并加载

Comment thread docs/zh/latest/status-api.md Outdated

### GET /status

返回报告 APISIX 工作者状态的 JSON

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
返回报告 APISIX 工作者状态的 JSON
返回报告 APISIX worker 状态的 JSON

similarly add missing punctuation in this doc

Comment thread docs/zh/latest/status-api.md Outdated
}
```

当特定工作器尚未加载配置时

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
当特定工作器尚未加载配置时
当特定 worker 尚未加载配置时:

Comment thread docs/zh/latest/status-api.md Outdated

当所有 Worker 都已加载配置时,返回 `ok`;否则,返回特定错误,错误代码为 `503`。以下是具体示例。

当所有 Worker 都已加载配置时

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

lower case the Worker, thanks

Comment thread docs/en/latest/status-api.md Outdated
}
```

When 1 workers has't been initialised

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When 1 workers has't been initialised
When 1 workers has't been initialised:

Comment thread docs/en/latest/status-api.md Outdated
}
```

When a particular worker hasn't loaded the configuration

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When a particular worker hasn't loaded the configuration
When a particular worker hasn't loaded the configuration:

Comment thread docs/zh/latest/status-api.md Outdated
在 Apache APISIX 中,Status API 用于:

* 检查 APISIX 是否已成功启动并正确运行
* 检查所有 workers 是否已收到配置并加载。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 检查所有 workers 是否已收到配置并加载
* 检查所有 workers 是否已收到配置并加载

Comment thread docs/zh/latest/status-api.md Outdated
}
```

当 1 个 workers 尚未初始化时

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
当 1 个 workers 尚未初始化时
当 1 个 workers 尚未初始化时

Comment thread docs/zh/latest/status-api.md Outdated

当所有 worker 都已加载配置时,返回 `ok`;否则,返回特定错误,错误代码为 `503`。以下是具体示例。

当所有 worker 都已加载配置时

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
当所有 worker 都已加载配置时
当所有 worker 都已加载配置时

@kayx23 kayx23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others LGTM. Please fix for doc lint errors as well, likely due to punctuations.

Comment thread docs/zh/latest/status-api.md Outdated
### GET /status

返回报告 APISIX worker 状态的 JSON
返回报告 APISIX 工作人员状态的 JSON。如果 APISIX 未运行,则建立 TCP 连接时请求将出错。否则,如果请求到达正在运行的工作线程,此端点将始终返回 ok

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
返回报告 APISIX 工作人员状态的 JSON。如果 APISIX 未运行,则建立 TCP 连接时请求将出错。否则,如果请求到达正在运行的工作线程,此端点将始终返回 ok
返回报告 APISIX 工作人员状态的 JSON。如果 APISIX 未运行,建立 TCP 连接时请求将报错。否则,如果请求到达正在运行的 worker,此端点将始终返回 ok

@Revolyssup
Revolyssup merged commit e430a2b into apache:master May 21, 2025
@Revolyssup
Revolyssup deleted the revolyssup/healthcheck-standalone branch May 21, 2025 06:44
laz-xyr pushed a commit to laz-xyr/apisix that referenced this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants