kong icon indicating copy to clipboard operation
kong copied to clipboard

fix(clustering) improve wRPC protocol detection

Open flrgh opened this issue 2 years ago • 4 comments

Summary

The data-plane clustering code optimistically makes a request to the control-plane (HEAD /v1/wrpc) to determine if it can use wRPC or not. If the request did not return a 404, it would assume wRPC.

We gate the presence of the /v1/wrpc block based on the legacy_hybrid_protocol config param and rely on NGINX to return a 404.

This is all behaving kinda finnicky in EE land (for reasons I spent an hour debugging and couldn't figure out). Needless to say, I think a more explicit form of feature detection is warranted.

Full changelog

  • /v1/wrpc returns 200 immediately for HEAD requests
  • kong.clustering.utils.check_protocol_support checks response codes more strictly now:
    • 404 => legacy
    • 200 => wrpc
    • anything else is an error
  • renamed 06-lagacy_switch_spec.lua => 06-legacy_switch_spec.lua

flrgh avatar Jul 26 '22 01:07 flrgh

Added the legacy_hybrid_protocol check to the test template. It didn't seem to break any tests, so :crossed_fingers: that this is good to go.

flrgh avatar Jul 28 '22 16:07 flrgh

@chronolaw @Suika-Kong @hbagdi, any :+1:/:-1: on whether this should get merged for 3.0 or not? It's not a hill I would die on, but I think it's a worthwhile improvement, and making any kind of changes to the wRPC clustering API after 3.0 is out will be a lot harder to justify.

flrgh avatar Aug 09 '22 20:08 flrgh

The current code seems to work well, I think this PR is not urgent and we can discuss it after 3.0 release.

chronolaw avatar Aug 24 '22 03:08 chronolaw

Michael is going to cherry-pick https://github.com/Kong/kong/pull/9145/commits/7c299b48b338ee50b698acda4b49e0d02bd9700a as its own PR (because that fixes some test issues in EE). I moved this to a 3.1 milestone as a future improvement.

tyler-ball avatar Aug 24 '22 17:08 tyler-ball

@flrgh Still pursuing this change?

hbagdi avatar Oct 25 '22 21:10 hbagdi

@flrgh Still pursuing this change?

Yes I'd like to.

It's a little bit tougher to realize now that 3.0 is out though, since it changes the response-handling logic in the DP to be more strict, which could cause breakage. I probably need to change this to a feat and merge the CP change (both here and in Koko) at least one minor release ahead of the DP changes.

flrgh avatar Oct 25 '22 21:10 flrgh

Due to #9740, perhaps we could close it.

chronolaw avatar Nov 16 '22 13:11 chronolaw

Due to #9740, perhaps we could close it.

Agreed. We can revisit this if anything changes later on.

flrgh avatar Nov 16 '22 23:11 flrgh