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

CP-51835: Keep the HTTP /repository handler enabled #6072

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions ocaml/xapi/repository.ml
Original file line number Diff line number Diff line change
Expand Up @@ -488,18 +488,14 @@ let get_host_updates_in_json ~__context ~installed =
(ExnHelper.string_of_exn e) ;
raise Api_errors.(Server_error (get_host_updates_failed, [ref]))

(* This handler hosts HTTP endpoint '/repository' which will be available iif
* 'is_local_pool_repo_enabled' returns true with 'with_pool_repositories' being called by
* others.
*)
let get_repository_handler (req : Http.Request.t) s _ =
let open Http in
let open Xapi_stdext_std.Xstringext in
debug "Repository.get_repository_handler URL %s" req.Request.uri ;
req.Request.close <- true ;
if Fileserver.access_forbidden req s then
Http_svr.response_forbidden ~req s
else if is_local_pool_repo_enabled () then
BengangY marked this conversation as resolved.
Show resolved Hide resolved
else
let can_be_authorized =
try
Xapi_http.with_context "get_repository_handler" req s (fun _ -> ()) ;
Expand Down Expand Up @@ -536,10 +532,6 @@ let get_repository_handler (req : Http.Request.t) s _ =
(ExnHelper.string_of_exn e) ;
Http_svr.response_forbidden ~req s
)
else (
error "Rejecting request: local pool repository is not enabled" ;
Http_svr.response_forbidden ~req s
)

let consolidate_updates_of_hosts ~repository_name ~updates_info ~hosts =
Hashtbl.fold
Expand Down
13 changes: 3 additions & 10 deletions ocaml/xapi/repository_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open Updateinfo
module LivePatchSet = Set.Make (LivePatch)
module RpmFullNameSet = Set.Make (String)

let exposing_pool_repo_mutex = Mutex.create ()
let pool_update_ops_mutex = Mutex.create ()

module Pkgs = (val Pkg_mgr.get_pkg_mgr)

Expand Down Expand Up @@ -234,17 +234,10 @@ let assert_gpgkey_path_is_valid path =
let with_pool_repositories f =
Xapi_stdext_pervasives.Pervasiveext.finally
(fun () ->
Mutex.lock exposing_pool_repo_mutex ;
Mutex.lock pool_update_ops_mutex ;
f ()
)
(fun () -> Mutex.unlock exposing_pool_repo_mutex)

let is_local_pool_repo_enabled () =
if Mutex.try_lock exposing_pool_repo_mutex then (
Mutex.unlock exposing_pool_repo_mutex ;
false
) else
true
(fun () -> Mutex.unlock pool_update_ops_mutex)

let with_updateinfo_xml gz_path f =
let tmpfile, tmpch =
Expand Down
Loading