Skip to content

Refactor http state - #871

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
refactor_http_state
Feb 13, 2023
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
refactor_http_state

Conversation

@Keksoj

@Keksoj Keksoj commented Jan 10, 2023

Copy link
Copy Markdown

In order to support HTTP2 in Sōzu, there is a number of steps to take. This is one of them.

This PR aims to normalize the States of the various protocols (Expect, Pipe...), and to make them handle backend connection.

A side effect of this refactoring is to merge duplicate code of the http and https proxies into the Http state.

@Keksoj Keksoj added this to the HTTP2 milestone Jan 10, 2023
@Keksoj Keksoj self-assigned this Jan 10, 2023
@Wonshtrum
Wonshtrum force-pushed the refactor_http_state branch 3 times, most recently from 4419f2d to 195813e Compare January 10, 2023 15:22
@Keksoj
Keksoj force-pushed the refactor_http_state branch from 5f59d3e to 84617e5 Compare January 12, 2023 14:03
@Wonshtrum
Wonshtrum force-pushed the refactor_http_state branch from 84617e5 to 7dbccbf Compare January 13, 2023 15:06
@Keksoj
Keksoj force-pushed the refactor_http_state branch from a2c6ae4 to b4fd3e4 Compare January 17, 2023 15:14
@Keksoj
Keksoj force-pushed the refactor_http_state branch 3 times, most recently from 82dd79a to fab483b Compare January 30, 2023 11:51
@Wonshtrum
Wonshtrum force-pushed the refactor_http_state branch from d72b2f4 to ba83d10 Compare February 1, 2023 11:18
@Keksoj
Keksoj force-pushed the refactor_http_state branch from a562368 to e9b936f Compare February 1, 2023 15:06
@Wonshtrum
Wonshtrum force-pushed the refactor_http_state branch from acd0c1c to 44c661b Compare February 3, 2023 14:16
@Keksoj
Keksoj force-pushed the refactor_http_state branch from 44c661b to eaebfe4 Compare February 3, 2023 16:19
@Keksoj
Keksoj force-pushed the refactor_http_state branch from eaebfe4 to b0c2745 Compare February 13, 2023 09:14
In order to fit HTTP2 modifications later: Mux sessions, generic HTTP

Traits:
  trait L7ListenerHandler (impl by listeners)
  proxy trait L7Proxy (impl by proxies)
  state trait SessionState (impl by Http, Pipe, Expect)

state machines of HTTP, HTTPS and TCP sessions:
  handle backend connection, passthrough, closing
  integrate https logic into new http state
  Replace State::Invalid by State::FailedUpgrade(marker)
  add the Invalid variant to Http state, extract it from the Option
  StateMachineBuilder macro to merge all State related boilerplate
  default behavior for SessionState::shutting_down()
  pass container_frontend_timeout to the State instead of the Session

Session:
  clean closing of all sessions (add has_been_closed field)
  rewrite all session upgrades
  remove unused SessionResult::ReconnectBackend,
  remove HttpSession::back_token() and HttpsSession::back_token()
  make ProxySession::print_session() call SessionState::print_state()
  remove listener token and request timeout from HTTP and HTTPS Session
  Narrowing scopes: StateResult > SessionResult > SessionIsToBeClosed
  replace ProxySession::tokens() with ProxySession::frontend_token()

Server rewrite:
  only the server calls ProxySession::close()
  generic session shutdown for the zombie_check and shutdown()
  change ProxySession::tokens() to frontend_tokens(), fix the zombie checker
  shut_down_sessions_by_frontend_tokens()
  the zombie checker has to be repaired to use only the frontend token

end-to-end tests:
  test_http_behaviors replaces /lib/tests/http.rs
  test_tls_endpoint
  remove try_issue_810_panic_variant, no longer relevant
  Init logger with loglevel error is RUST_LOG is not found
  Use localhost instead of lolcatho.st for e2e test in pipeline

renaming:
  config::HttpListener   -> HttpListenerconfig (same for TCP and HTTPS)
  Session/Listener/Proxy -> add Tcp/Http/Https prefixes
  process_events         -> update_readiness
  ProxySession::print_state -> ProxySession::print_session

Fixed gauges:
  all "protocol.*" gauges are modified by the Sessions only
 "*.active_requests" are explicit

Code cleanliness:
  sort alphabetically the field structs and function arguments relevant to this commit
  Replace if lets with exhaustive pattern matching
  documenting comments in relevant places

Co-authored-by: Emmanuel Bosquet <[email protected]>
@Keksoj
Keksoj force-pushed the refactor_http_state branch from b0c2745 to 476e230 Compare February 13, 2023 09:56

@FlorentinDUBOIS FlorentinDUBOIS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That seems good to me :)

@FlorentinDUBOIS
FlorentinDUBOIS merged commit 3727f14 into main Feb 13, 2023
@FlorentinDUBOIS
FlorentinDUBOIS deleted the refactor_http_state branch February 13, 2023 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants