From e1b2712ddcd9e2ed8e5e28ff3bc4e466612e41f7 Mon Sep 17 00:00:00 2001 From: Bengang Yuan Date: Fri, 2 Aug 2024 09:48:31 +0100 Subject: [PATCH] CA-396540: Update bundle syncing failure description Update bundle syncing failure description to: Syncing with bundle repository failed. Signed-off-by: Bengang Yuan --- ocaml/idl/datamodel_errors.ml | 2 ++ ocaml/xapi-consts/api_errors.ml | 2 ++ ocaml/xapi/xapi_pool.ml | 9 ++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ocaml/idl/datamodel_errors.ml b/ocaml/idl/datamodel_errors.ml index 921a289f04..3071a4add4 100644 --- a/ocaml/idl/datamodel_errors.ml +++ b/ocaml/idl/datamodel_errors.ml @@ -1927,6 +1927,8 @@ let _ = () ; error Api_errors.reposync_failed [] ~doc:"Syncing with remote YUM repository failed." () ; + error Api_errors.bundle_sync_failed [] + ~doc:"Syncing with bundle repository failed." () ; error Api_errors.invalid_repomd_xml [] ~doc:"The repomd.xml is invalid." () ; error Api_errors.invalid_updateinfo_xml [] ~doc:"The updateinfo.xml is invalid." () ; diff --git a/ocaml/xapi-consts/api_errors.ml b/ocaml/xapi-consts/api_errors.ml index 0ade8d9cdb..53d9684561 100644 --- a/ocaml/xapi-consts/api_errors.ml +++ b/ocaml/xapi-consts/api_errors.ml @@ -1338,6 +1338,8 @@ let sync_bundle_in_progress = add_error "SYNC_BUNDLE_IN_PROGRESS" let reposync_failed = add_error "REPOSYNC_FAILED" +let bundle_sync_failed = add_error "BUNDLE_SYNC_FAILED" + let createrepo_failed = add_error "CREATEREPO_FAILED" let invalid_updateinfo_xml = add_error "INVALID_UPDATEINFO_XML" diff --git a/ocaml/xapi/xapi_pool.ml b/ocaml/xapi/xapi_pool.ml index 7ae0e8b33e..b94566da24 100644 --- a/ocaml/xapi/xapi_pool.ml +++ b/ocaml/xapi/xapi_pool.ml @@ -3790,9 +3790,12 @@ let put_bundle_handler (req : Request.t) s _ = TaskHelper.set_progress ~__context 0.8 ; finally (fun () -> - sync_repos ~__context ~self:pool ~repos:[repo] ~force:true - ~token:"" ~token_id:"" - |> ignore + try + sync_repos ~__context ~self:pool ~repos:[repo] ~force:true + ~token:"" ~token_id:"" + |> ignore + with _ -> + raise Api_errors.(Server_error (bundle_sync_failed, [])) ) (fun () -> Unixext.rm_rec !Xapi_globs.bundle_repository_dir) | Error e ->