-
Notifications
You must be signed in to change notification settings - Fork 292
[From REQ-477] Cherry-pick addition of iSCSI IQN and multipathing changes #3470
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
Conversation
This looks fine to me. |
dcdea9f
to
2c2fb14
Compare
Rebased on master now #3468 has merged :) |
This needs a rebase |
2c2fb14
to
cbde7b3
Compare
cbde7b3
to
2382edb
Compare
Fixup: Moved test_host_helpers.ml to ocaml/tests/ |
We should replace |
2382edb
to
198c509
Compare
Replaced |
ocaml/idl/datamodel_host.ml
Outdated
field ~qualifier:DynamicRO ~lifecycle:[Published, rel_falcon, ""] ~ty:(Set (Ref _feature)) "features" "List of features available on this host" | ||
field ~qualifier:DynamicRO ~lifecycle:[Published, rel_falcon, ""] ~ty:(Set (Ref _feature)) "features" "List of features available on this host"; | ||
field ~qualifier:StaticRO ~lifecycle:[Published, rel_kolkata, ""] ~default_value:(Some (VString "")) ~ty:String "iscsi_iqn" "The initiator IQN for the host"; | ||
field ~qualifier:StaticRO ~lifecycle:[Published, rel_kolkata, ""] ~default_value:(Some (VBool false)) ~ty:Bool "multipathing" "Specifies whether multipathing is enabled"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely need a run of ocp-indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly have minor changes. I am bit scared on some potential failures and the need of the weird set+other_config flow
Test_network_event_loop.test; | ||
Test_network.test; | ||
Test_pusb.test; | ||
Test_host_helpers.test; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From now on, when we introduce new tests we should probably use Alcotest
from the start. No change needed, this can be ported later with the other tests
ocaml/idl/datamodel_host.ml
Outdated
field ~qualifier:DynamicRO ~lifecycle:[Published, rel_falcon, ""] ~ty:(Set (Ref _feature)) "features" "List of features available on this host" | ||
field ~qualifier:DynamicRO ~lifecycle:[Published, rel_falcon, ""] ~ty:(Set (Ref _feature)) "features" "List of features available on this host"; | ||
field ~qualifier:StaticRO ~lifecycle:[Published, rel_kolkata, ""] ~default_value:(Some (VString "")) ~ty:String "iscsi_iqn" "The initiator IQN for the host"; | ||
field ~qualifier:StaticRO ~lifecycle:[Published, rel_kolkata, ""] ~default_value:(Some (VBool false)) ~ty:Bool "multipathing" "Specifies whether multipathing is enabled"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the new fields break update/compatibility or they are safe? I am assuming the second, but I can never remember which fields are a problem and which not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed today new fields are safe.
Db.Host.add_to_other_config ~__context ~self:host1 ~key:"multipathing" ~value:"false"; | ||
let _token = watcher token in | ||
assert_equal !calls [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are testing "success" cases, do we have understood failure cases that also would make sense to check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that setting multipathing should fail (unless the DB itself fails)
if value = "" then raise Api_errors.(Server_error (invalid_value, ["value"; value])); | ||
(* Note, the following sequence is carefully written - see the | ||
other-config watcher thread in xapi_host_helpers.ml *) | ||
Db.Host.remove_from_other_config ~__context ~self:host ~key:"iscsi_iqn"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is out of scope for this PR, and I suggest not to touch it. But, as a remark for the future, we really need a with_other_config_update
and replace_in_other_config
pair of helpers. I have seen quite a few instances of these patterns...
iqn hostname_chopped | ||
|
||
let set_initiator_name iqn = | ||
let hostname = Unix.gethostname () in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we protect this against Unix_error
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd let this one to be treated as an internal error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure 👍
ocaml/xapi/xapi_host_helpers.ml
Outdated
let flag = !Xapi_globs.multipathing_config_file in | ||
if enabled then Unixext.touch_file flag | ||
else begin | ||
if Sys.file_exists flag then Sys.remove flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wary of Sys
... we cannot catch the errors properly when using it. Can we do this using Unix and maybe handle potential exceptions with internal_error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with Unixext.unlink_safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! That also prevents potential error in case of races, although I don't think it would have been the case for this.
other-config watcher thread in xapi_host_helpers.ml *) | ||
Db.Host.remove_from_other_config ~__context ~self:host ~key:"iscsi_iqn"; | ||
Db.Host.set_iscsi_iqn ~__context ~self:host ~value; | ||
Db.Host.add_to_other_config ~__context ~self:host ~key:"iscsi_iqn" ~value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This re-triggers the loop and an rpc call to set the iscsi_iqn, thing that we have "kind of" just done above.
Why such a complicated flow?
Update: the rpc call is ignored because we compare with the db record, still it is quite a compilcate flow and the comment on the careful ordering could benefit from more context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a comment attempting to explain my understanding of it:
+ (* we need to first set the iscsi_iqn field and then the other-config field:
+ * setting the other-config field triggers and update on the iscsi_iqn
+ * field if they are different
+ *
+ * we want to keep the legacy `other_config:iscsi_iqn` and the new `iscsi_iqn`
+ * fields in sync:
+ * when you update the `iscsi_iqn` field we want to update `other_config`,
+ * but when updating `other_config` we want to update `iscsi_iqn` too.
+ * we have to be careful not to introduce an infinite loop of updates.
+ * *)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it's clearer. Thanks
ocaml/xapi/xapi_host_helpers.mli
Outdated
* GNU Lesser General Public License for more details. | ||
*) | ||
|
||
(** Common code between for dealing with Hosts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably between
is a leftover from an old version
intended to be run on the master. The returned function has type | ||
[token -> token], where [token] is a string. The initial value should be | ||
the empty string, and the returned value should be used for further | ||
invocations. This function is exposed only for unit testing, and should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is annoying that for unit testing we need to do this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a ppx to do inline testing, but that would require using yet another ppx...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I know, I wasn't suggesting to do anything. It's unfortunate, I only wish there was some compiler level support for tests behind mli
As per current discussion, we need to update: |
Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com> Note: Manually applied the patch from datamodel.ml to datamodel_host.ml Signed-off-by: Callum McIntyre <callum.mcintyre@citrix.com>
Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com> Note: Manually applied the patch from datamodel.ml to datamodel_host.ml Signed-off-by: Callum McIntyre <callum.mcintyre@citrix.com>
Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
This adds the functions that set the initiatorname.iscsi file and the thread that watches the database for host.other-config:iscsi_iqn changes. When that thread is running a change to the other-config field will trigger a call to Host.set_iscsi_iqn. Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
198c509
to
bc3f1d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what concerns me, with this last comment (that practically reflects also what happens in the multipath case), this is good to go.
Before merging, please squash the fixups
It's got to coexist with the other-config watcher Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
Signed-off-by: Gabor Igloi <gabor.igloi@citrix.com>
Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
And keep it up to date with the value of the multipath key in other_config for backward compatibility. The file /var/run/nonpersistent/multipath_enabled is touched / removed when multipathing is enabled / disabled. Signed-off-by: Gabor Igloi <gabor.igloi@citrix.com> Note: Manually applied the patch from datamodel.ml to datamodel_host.ml Signed-off-by: Callum McIntyre <callum.mcintyre@citrix.com>
We have to make sure these are handled correctly on startup, in case there was a hard reboot and had to recover from a redo log, or when one of these are in a nonpersistent file. We cannot know the state of these config files before xapi started, so it's the safest to sync them at startup. Signed-off-by: Gabor Igloi <gabor.igloi@citrix.com>
Because it's invalid. Signed-off-by: Gabor Igloi <gabor.igloi@citrix.com>
Signed-off-by: Mark Syms <mark.syms@citrix.com>
I tested this on a DT box and it properly updated the other-config and iscsi_iqn host param. Signed-off-by: Edwin Török <edvin.torok@citrix.com>
f7c6931
to
2629e6b
Compare
Thanks for the review, lets wait until Travis build finishes. |
This adds the iSCSI IQN functionality and multipatching changes (they were closely intertwined, and only 2 commits were identified initially as multipathing anyway so I combined them here).
Note that the changes to
datamodel.ml
in a few commits were manually patched intodatamodel_host.ml
since the split was done since those commits were made.