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
WIP: Implement multi-tenanted mode (thread-safe seamless mode) #3698
base: main
Are you sure you want to change the base?
Conversation
…RNAL_API_PATH is not set
✅ Deploy Preview for volto ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
20 failed tests on run #7193 ↗︎
Details:
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
src/server.jsx
Outdated
res.locals.detectedInternalHost = `${ | ||
req.headers['x-forwarded-proto'] || req.protocol | ||
}://${req.headers['x-internal-host']}`; | ||
config.settings.internalApiPath = res.locals.detectedInternalHost; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing that we're unsure of (at least I am) and needs testing is this line.
config.settings.internalApiPath = res.locals.detectedInternalHost;
Basically, I think it would be a good idea that all our URL helper functions stop depending on config.settings.apiPath and config.settings.internalApiPath and always use information either from the browser window or server HOST. CC @sneridagh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we should talk about it during the conference.
I added it to my todo list.
…se x-forwarded-proto, let it be set in the header.
I made a couple of changes
I'm not sure if
can just be shortened to
I'm not quite sure what |
@instification It's awesome that you're tackling this issue. There was a problem, at some point with cross-request pollution. Imagine that Volto's nodejs server is handling all requests, and because of nodejs's async nature (as far as I understand it, and I'm not sure of this) you may get execution of code "out of sync" between two different separate requests. If the config object is a global, and is mutated but shared between the requests, you'll get issues. https://stackoverflow.com/questions/35649998/is-it-possible-to-have-thread-local-variables-in-node |
@instification @tiberiuichim today I can use the variables RAZZLE_INTERNAL_API_PATH and RAZZLE_API_PATH, so that Plone requests made by the Volto server use RAZZLE_INTERNAL_API_PATH and requests made by the browser use RAZZLE_API_PATH? |
@wesleybl yes that's correct as I understand it :) |
@wesleybl RAZZLE_INTERNAL_API_PATH is intended to be used in containerised environments. Specially the ones that the network topology prevents an easy communication between containers private/public interfaces (k8s, etc...) For the rest, it is fine that your Volto SSR server access to the public backend API URL. |
@instification It does look good, but I think we should be a bit cautious about this one. It would be great if you lead this and test it in your servers, having good first hand feedback will help, for sure. If that adds some load tests it would be amazing. Let's talk during the conference about the details. |
@sneridagh I have already started to look at isolating it following @tiberiuichim's advice to move away from using the global config object. I made some progress, certainly for api requests it is possible to look up per request whether there is a header set (for SSR requests) or whether the I don't think there are too many other places where apiPath is being read, but I am not 100% sure how simple it will be to access the Presumably if we get the thread isolation issue resolved via not relying on the config object, then the load equation would be similar to if we were running with fixed api paths via env vars. But I think having some benchmarks and comparisons will be important. Look forward to discussing more at the conference! |
… anontools, api and connectionrefused.
See plip: #3774
How to test
The traefik setup in
docker-compose.yml
is configured to run a single backend and a single frontend, but use HTTP headers to change the backend site that the frontend is set to visit.docker compose up backend frontend reverse-proxy
plone.localhost:8080
and create a second site with an ID ofPlone2
.Implementation tasks
flattenToAppUrl
? (perhaps by logging a warning when used)Convert following components to use new helpers hook/hoc
List of files to convert
Non Component
Functional Components
Class Components
Files/Tests which use deprecated components but don't need converting