Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

En/fix 1988 1 #2151

Merged
merged 7 commits into from
Aug 29, 2024
Merged

En/fix 1988 1 #2151

merged 7 commits into from
Aug 29, 2024

Conversation

enuribekov-tempesta
Copy link
Contributor

New pull request for #1988 made from the scratch.

fw/apm.c Outdated Show resolved Hide resolved
Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

Nothing serious, but bunch of cleanups is required. Probably it's more serious to fix the tests in tempesta-tech/tempesta-test#637 w/o using the warning

fw/apm.c Outdated Show resolved Hide resolved
fw/apm.c Outdated Show resolved Hide resolved
fw/http.c Outdated Show resolved Hide resolved
fw/http.c Outdated Show resolved Hide resolved
fw/http.c Show resolved Hide resolved
fw/http.c Outdated Show resolved Hide resolved

if(tfw_apm_hm_srv_alive(resp, srv)) {
T_DBG2("Mark server alive");
tfw_srv_mark_alive(srv);
Copy link
Contributor

Choose a reason for hiding this comment

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

The function must be renamed or commented here: it's very confusing to see a function call with name 'mark_alive' right after thec all 'try_suspend'

Copy link
Contributor Author

@enuribekov-tempesta enuribekov-tempesta Aug 1, 2024

Choose a reason for hiding this comment

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

tfw_http_hm_try_suspend() is the conditional function and has following comment:

/*
 * Try to mark server as suspended.
 * In case of HM is active do it, otherwise left unchanged.
 */

tfw_srv_mark_alive() is just inline for clearing flag

Copy link
Contributor

Choose a reason for hiding this comment

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

The logic is not clear for me. We trying to suspend server using tfw_http_hm_try_suspend even in case if server was suspended in previous call we checking is it alive tfw_apm_hm_srv_alive. Why?

Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

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

LGTM

fw/http.c Outdated
old_flags = cmpxchg(&srv->flags, flags,
flags | TFW_SRV_F_SUSPEND);
flags | TFW_SRV_F_SUSPEND);
Copy link
Contributor

Choose a reason for hiding this comment

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

Previous alignment was good

* Total response statistics is counted permanently regardless
* of the state of the health monitor.
*/
bool lim_exceeded = tfw_apm_hm_srv_limit(resp->status, srv->apmref);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we calc the limit before checking flag srv->flags & TFW_SRV_F_HMONITOR, seems we calc the limit even for servers doesn't have health monitor. Or am I wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because these counters used for statistics too.
Perhaps this can be done much more elegantly, but I have kept the existing logic because statistics go beyond that.


if(tfw_apm_hm_srv_alive(resp, srv)) {
T_DBG2("Mark server alive");
tfw_srv_mark_alive(srv);
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic is not clear for me. We trying to suspend server using tfw_http_hm_try_suspend even in case if server was suspended in previous call we checking is it alive tfw_apm_hm_srv_alive. Why?

Request string should not contain quotes, because all of the symbols
will be send on the wire as is.
Also fixed HTTTP string.
Original issue to investigate was a suspection that automatic CRC
calculation will never works properly.
After investigation it turned out that response never achieves
this place.
This commit contains fixes, light refactoring for better readability
and removing unused function arguments.
Test cases for checking this changes added to tempesta-test.
In case of HM off, TfwApmHM is not allocated and following access
to it lead to crash. So we should return from tfw_http_hm_control()
immediately after updating statistics.
Warning informed that auto CRC generated and used by tests.
Now tests will be just check CRC regardless of it origin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants