Skip to content

Commit 5fa500c

Browse files
authored
Merge pull request #5904 from BengangY/private/bengangy/non-cdn-bug-fix
Non-CDN updates bug fix
2 parents 5c68118 + 65e35bc commit 5fa500c

File tree

4 files changed

+57
-34
lines changed

4 files changed

+57
-34
lines changed

ocaml/idl/datamodel_errors.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,6 +1927,8 @@ let _ =
19271927
() ;
19281928
error Api_errors.reposync_failed []
19291929
~doc:"Syncing with remote YUM repository failed." () ;
1930+
error Api_errors.bundle_sync_failed []
1931+
~doc:"Syncing with bundle repository failed." () ;
19301932
error Api_errors.invalid_repomd_xml [] ~doc:"The repomd.xml is invalid." () ;
19311933
error Api_errors.invalid_updateinfo_xml []
19321934
~doc:"The updateinfo.xml is invalid." () ;

ocaml/xapi-consts/api_errors.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,8 @@ let sync_bundle_in_progress = add_error "SYNC_BUNDLE_IN_PROGRESS"
13381338

13391339
let reposync_failed = add_error "REPOSYNC_FAILED"
13401340

1341+
let bundle_sync_failed = add_error "BUNDLE_SYNC_FAILED"
1342+
13411343
let createrepo_failed = add_error "CREATEREPO_FAILED"
13421344

13431345
let invalid_updateinfo_xml = add_error "INVALID_UPDATEINFO_XML"

ocaml/xapi/xapi_globs.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,8 @@ let ignore_vtpm_unimplemented = ref false
957957

958958
let evacuation_batch_size = ref 10
959959

960-
(* Max size limit of bundle file: 500 MB*)
961-
let bundle_max_size_limit = ref (Int64.of_int (500 * 1024 * 1024))
960+
(* Max size limit of bundle file: 1 GB*)
961+
let bundle_max_size_limit = ref (Int64.of_int (1024 * 1024 * 1024))
962962

963963
type xapi_globs_spec =
964964
| Float of float ref

ocaml/xapi/xapi_pool.ml

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3774,37 +3774,56 @@ let put_bundle_handler (req : Request.t) s _ =
37743774
~doc:"pool.sync_bundle" ~op:`sync_bundle
37753775
@@ fun () ->
37763776
Http_svr.headers s (Http.http_200_ok ()) ;
3777-
let repo =
3778-
Repository_helpers.get_single_enabled_update_repository ~__context
3779-
in
3780-
match Db.Repository.get_origin ~__context ~self:repo with
3781-
| `bundle -> (
3782-
let result =
3783-
Tar_ext.unpack_tar_file
3784-
~dir:!Xapi_globs.bundle_repository_dir
3785-
~ifd:s
3786-
~max_size_limit:!Xapi_globs.bundle_max_size_limit
3777+
let repo_opt =
3778+
try
3779+
let repo =
3780+
Repository_helpers.get_single_enabled_update_repository ~__context
37873781
in
3788-
match result with
3789-
| Ok () ->
3790-
TaskHelper.set_progress ~__context 0.8 ;
3791-
finally
3792-
(fun () ->
3793-
sync_repos ~__context ~self:pool ~repos:[repo] ~force:true
3794-
~token:"" ~token_id:""
3795-
|> ignore
3796-
)
3797-
(fun () -> Unixext.rm_rec !Xapi_globs.bundle_repository_dir)
3798-
| Error e ->
3799-
error "%s: Failed to unpack bundle with error %s" __FUNCTION__
3800-
(Tar_ext.unpack_error_to_string e) ;
3801-
TaskHelper.failed ~__context
3802-
Api_errors.(
3803-
Server_error
3804-
(bundle_unpack_failed, [Tar_ext.unpack_error_to_string e])
3805-
) ;
3806-
Http_svr.headers s (Http.http_400_badrequest ())
3807-
)
3808-
| `remote ->
3809-
raise Api_errors.(Server_error (bundle_repo_not_enabled, []))
3782+
Some repo
3783+
with e ->
3784+
TaskHelper.failed ~__context e ;
3785+
Http_svr.headers s (Http.http_400_badrequest ()) ;
3786+
None
3787+
in
3788+
match repo_opt with
3789+
| Some repo -> (
3790+
match Db.Repository.get_origin ~__context ~self:repo with
3791+
| `bundle -> (
3792+
let result =
3793+
Tar_ext.unpack_tar_file
3794+
~dir:!Xapi_globs.bundle_repository_dir
3795+
~ifd:s
3796+
~max_size_limit:!Xapi_globs.bundle_max_size_limit
3797+
in
3798+
match result with
3799+
| Ok () ->
3800+
TaskHelper.set_progress ~__context 0.8 ;
3801+
finally
3802+
(fun () ->
3803+
try
3804+
sync_repos ~__context ~self:pool ~repos:[repo] ~force:true
3805+
~token:"" ~token_id:""
3806+
|> ignore
3807+
with _ ->
3808+
raise Api_errors.(Server_error (bundle_sync_failed, []))
3809+
)
3810+
(fun () -> Unixext.rm_rec !Xapi_globs.bundle_repository_dir)
3811+
| Error e ->
3812+
error "%s: Failed to unpack bundle with error %s" __FUNCTION__
3813+
(Tar_ext.unpack_error_to_string e) ;
3814+
TaskHelper.failed ~__context
3815+
Api_errors.(
3816+
Server_error
3817+
(bundle_unpack_failed, [Tar_ext.unpack_error_to_string e])
3818+
) ;
3819+
Http_svr.headers s (Http.http_400_badrequest ())
3820+
)
3821+
| `remote ->
3822+
error "%s: Bundle repo is not enabled" __FUNCTION__ ;
3823+
TaskHelper.failed ~__context
3824+
Api_errors.(Server_error (bundle_repo_not_enabled, [])) ;
3825+
Http_svr.headers s (Http.http_400_badrequest ())
3826+
)
3827+
| None ->
3828+
()
38103829
)

0 commit comments

Comments
 (0)