Skip to content

Commit 753a667

Browse files
authored
CA-404660: Refine repository enabling error message (#6235)
When enabling pool's repositories, if enabling bundle repo and remoe_pool repositories at the same time, it returns error message: `If the bundle repository or remote_pool repository is enabled, it should be the only one enabled repository of the pool. repo_types: bundle` The `repo_types` is confusing and tedious as only these 2 types of repository can meet this error. So remove the parameter `repo_types`.
2 parents 9fa5a04 + d976582 commit 753a667

File tree

3 files changed

+10
-51
lines changed

3 files changed

+10
-51
lines changed

ocaml/idl/datamodel_errors.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,10 +1933,10 @@ let _ =
19331933
"The currently enabled repositories do not support periodic automatic \
19341934
updates."
19351935
() ;
1936-
error Api_errors.repo_should_be_single_one_enabled ["repo_types"]
1936+
error Api_errors.repo_should_be_single_one_enabled []
19371937
~doc:
19381938
"If the bundle repository or remote_pool repository is enabled, it \
1939-
should be the only one enabled repository of the pool."
1939+
should be the only enabled repository of the pool."
19401940
() ;
19411941
error Api_errors.update_syncing_remote_pool_coordinator_connection_failed []
19421942
~doc:

ocaml/tests/test_pool_repository.ml

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,19 @@ let test_set_repositories () =
4141
Xapi_pool.set_repositories ~__context ~self ~value:[ref_bundle] ;
4242
Xapi_pool.set_repositories ~__context ~self ~value:[ref_remote_pool] ;
4343
Alcotest.check_raises "test_set_repositories_1"
44-
Api_errors.(
45-
Server_error
46-
( repo_should_be_single_one_enabled
47-
, [Record_util.origin_to_string `bundle]
48-
)
49-
)
44+
Api_errors.(Server_error (repo_should_be_single_one_enabled, []))
5045
(fun () ->
5146
Xapi_pool.set_repositories ~__context ~self
5247
~value:[ref_remote; ref_bundle]
5348
) ;
5449
Alcotest.check_raises "test_set_repositories_2"
55-
Api_errors.(
56-
Server_error
57-
( repo_should_be_single_one_enabled
58-
, [`bundle; `remote_pool] |> List.map Record_util.origin_to_string
59-
)
60-
)
50+
Api_errors.(Server_error (repo_should_be_single_one_enabled, []))
6151
(fun () ->
6252
Xapi_pool.set_repositories ~__context ~self
6353
~value:[ref_remote_pool; ref_bundle]
6454
) ;
6555
Alcotest.check_raises "test_set_repositories_3"
66-
Api_errors.(
67-
Server_error
68-
( repo_should_be_single_one_enabled
69-
, [Record_util.origin_to_string `remote_pool]
70-
)
71-
)
56+
Api_errors.(Server_error (repo_should_be_single_one_enabled, []))
7257
(fun () ->
7358
Xapi_pool.set_repositories ~__context ~self
7459
~value:[ref_remote; ref_remote_pool]
@@ -78,45 +63,25 @@ let test_set_repositories () =
7863
let test_add_repository () =
7964
on_repositories (fun __context self ref_remote ref_bundle ref_remote_pool ->
8065
Alcotest.check_raises "test_add_repository_1"
81-
Api_errors.(
82-
Server_error
83-
( repo_should_be_single_one_enabled
84-
, [Record_util.origin_to_string `bundle]
85-
)
86-
)
66+
Api_errors.(Server_error (repo_should_be_single_one_enabled, []))
8767
(fun () ->
8868
Xapi_pool.set_repositories ~__context ~self ~value:[ref_remote] ;
8969
Xapi_pool.add_repository ~__context ~self ~value:ref_bundle
9070
) ;
9171
Alcotest.check_raises "test_add_repository_2"
92-
Api_errors.(
93-
Server_error
94-
( repo_should_be_single_one_enabled
95-
, [Record_util.origin_to_string `remote_pool]
96-
)
97-
)
72+
Api_errors.(Server_error (repo_should_be_single_one_enabled, []))
9873
(fun () ->
9974
Xapi_pool.set_repositories ~__context ~self ~value:[ref_remote] ;
10075
Xapi_pool.add_repository ~__context ~self ~value:ref_remote_pool
10176
) ;
10277
Alcotest.check_raises "test_add_repository_3"
103-
Api_errors.(
104-
Server_error
105-
( repo_should_be_single_one_enabled
106-
, [`remote_pool; `bundle] |> List.map Record_util.origin_to_string
107-
)
108-
)
78+
Api_errors.(Server_error (repo_should_be_single_one_enabled, []))
10979
(fun () ->
11080
Xapi_pool.set_repositories ~__context ~self ~value:[ref_remote_pool] ;
11181
Xapi_pool.add_repository ~__context ~self ~value:ref_bundle
11282
) ;
11383
Alcotest.check_raises "test_add_repository_4"
114-
Api_errors.(
115-
Server_error
116-
( repo_should_be_single_one_enabled
117-
, [`bundle; `remote_pool] |> List.map Record_util.origin_to_string
118-
)
119-
)
84+
Api_errors.(Server_error (repo_should_be_single_one_enabled, []))
12085
(fun () ->
12186
Xapi_pool.set_repositories ~__context ~self ~value:[ref_bundle] ;
12287
Xapi_pool.add_repository ~__context ~self ~value:ref_remote_pool

ocaml/xapi/xapi_pool.ml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3466,13 +3466,7 @@ let assert_single_repo_can_be_enabled ~__context ~repos =
34663466
in
34673467
match (repos, origins) with
34683468
| _ :: _ :: _, _ :: _ ->
3469-
raise
3470-
Api_errors.(
3471-
Server_error
3472-
( repo_should_be_single_one_enabled
3473-
, origins |> List.map Record_util.origin_to_string
3474-
)
3475-
)
3469+
raise Api_errors.(Server_error (repo_should_be_single_one_enabled, []))
34763470
| _, _ ->
34773471
()
34783472

0 commit comments

Comments
 (0)