-
Notifications
You must be signed in to change notification settings - Fork 292
CP-54274: Add user-specific error message for vnc connection limits #6710
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
base: feature/limit-vnc-console-sessions
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,7 +230,19 @@ let real_proxy' ~__context ~vm vnc_port s = | |
debug "Proxy exited" | ||
with exn -> debug "error: %s" (ExnHelper.string_of_exn exn) | ||
|
||
let real_proxy __context vm _ _ vnc_port s = | ||
let respond_console_limit_exceeded ~__context req s = | ||
let session_id = Xapi_http.get_session_id req in | ||
let user = Db.Session.get_auth_user_name ~__context ~self:session_id in | ||
let body = | ||
Printf.sprintf | ||
"<html><body><h1>Connection Limit Exceeded</h1><p>User '%s': Only 1 \ | ||
|
||
connection is allowed at a time. Please try again \ | ||
later.</p></body></html>" | ||
user | ||
in | ||
Http_svr.response_forbidden_with_body ~req s body | ||
|
||
let real_proxy __context vm req _ vnc_port s = | ||
let vm_id = Ref.string_of vm in | ||
let pool = Helpers.get_pool ~__context in | ||
let is_limit_enabled = | ||
|
@@ -241,7 +253,7 @@ let real_proxy __context vm _ _ vnc_port s = | |
(fun () -> real_proxy' ~__context ~vm vnc_port s) | ||
(fun () -> Connection_limit.drop vm_id) | ||
else | ||
Http_svr.headers s (Http.http_503_service_unavailable ()) | ||
respond_console_limit_exceeded ~__context req s | ||
|
||
let go_if_no_limit __context s f = | ||
let pool = Helpers.get_pool ~__context in | ||
|
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.
Do we want 403, not 503 as before?
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.
It's a client issue, not a server issue, so a 4xx response is warranted, maybe a 429 (too many requests) would be a better fit here?
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/429
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.
If we expect more specific error responses - does it make sense to factor this into a function that takes the error code and message as arguments?
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.
I think it is more like a service side issue. It's server that is applying the restriction.
How about 503 + a specific error message?
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.
Both 429 and 503 are reasonable to me.
Yeah, it's more of a serser side issue, because the server actively reject the connection.
I'll change this to 503.
Uh oh!
There was an error while loading. Please reload this page.
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, the specific error responses are contained in the body. See https://github.com/xapi-project/xen-api/pull/6710/files#diff-b467704b510207bfdab55411ab1ff91aae3f19c3e0ab0409f142fd1646595a3cR236
But yes, we can make this fucion more generic taking error code and messages as arguments. Will modify it.