Skip to content

Commit 1c83d6d

Browse files
authored
CA-426596: Supports SM feature removing (#7042)
In current xapi_sm.ml, the quired new sm features at XAPI start goes to pending_features. After all hosts reporting the new sm features, they are set in xapi-db. However, when the sm feature is removed, the item still exists. For example, xapi-storage-plugins-xfs remove SR_PROB as it is not implemented, but XAPI doesn't detect it. It leads to fresh-installed host (withour xfs SR_PROB) can't join the pool (with xfs SR_PROB) due to POOL_JOINING_SM_FEATURES_INCOMPATIBLE. Considering the pending_features, it wants to keep the minimal common features all over the hosts. As the same principle, the removed feature shall be removed immediately in the pool-level sm table. If one host reports the feature is removed, it should be removed from pool-level db.
2 parents d317bbf + f44069e commit 1c83d6d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

ocaml/xapi/xapi_sm.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,24 @@ let update_from_query_result ~__context (self, r) q_result =
109109
if _type <> "storage_access" then (
110110
let driver_filename = Sm_exec.cmd_name q_result.driver in
111111
let existing_features = Db.SM.get_features ~__context ~self in
112+
let query_features = Smint.Feature.parse_string_int64 q_result.features in
113+
let removed_features =
114+
Listext.List.set_difference existing_features query_features
115+
in
116+
List.iter
117+
(fun (f, v) -> debug "%s: removing features %s:%Ld" __FUNCTION__ f v)
118+
removed_features ;
119+
let retained_features =
120+
Listext.List.set_difference existing_features removed_features
121+
in
112122
let new_features =
113-
Smint.Feature.parse_string_int64 q_result.features
123+
query_features
114124
|> find_pending_features existing_features
115125
|> addto_pending_hosts_features ~__context self
116126
|> valid_hosts_pending_features ~__context
117127
in
118128
remove_valid_features_from_pending ~__context ~self new_features ;
119-
let features = existing_features @ new_features in
129+
let features = retained_features @ new_features in
120130
List.iter
121131
(fun (f, v) -> debug "%s: declaring new features %s:%Ld" __FUNCTION__ f v)
122132
new_features ;

0 commit comments

Comments
 (0)