Skip to content

Conversation

minishrink
Copy link
Contributor

@minishrink minishrink commented Mar 8, 2018

CA-282006 raises the issue of host fencing when trying to reconfigure IP on a live cluster network. This PR asserts no clustering is enabled on the chosen network for calls such as PIF.reconfigure_IP(v6). and PIF.forget, as well as adding the relevant errors to the datamodel for these calls.

@minishrink minishrink force-pushed the feature/REQ477/CA-282006 branch from 54c3e8f to 4f3a76f Compare March 8, 2018 21:33
@coveralls
Copy link

coveralls commented Mar 8, 2018

Coverage Status

Coverage increased (+0.003%) to 18.664% when pulling 65e6a90 on minishrink:feature/REQ477/CA-282006 into f4c3a3a on xapi-project:feature/REQ477/master.

Copy link
Contributor

@edwintorok edwintorok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far, it rejects the unsafe IP changes. Now we need to consider how to allow the safe ones.

(* return ref of newly created pif record *)
pif

let assert_no_clustering_enabled ~__context ~network =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You moved this function twice in this PR, could you put it in the correct place in the first commit please?

~params: [ Ref _pif, "self", "Reference to the object"
; Bool, "value", "New value to set" ]
~allowed_roles:_R_POOL_OP
~errs:[Api_errors.clustering_enabled_on_network]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we are missing errs declarations on all the cluster APIs too. It would be nice if these errors were checked at compile time by the type system (e.g. by using a Result type) but that is probably a huge amount of work. For now can you open an internal minor ticket to fix the API error declarations on the cluster APIs?

~expr:Db_filter_types.(Eq(Field "network", Literal (Ref.string_of network))))
|> function
| [] -> ()
| _::_ -> raise Api_errors.(Server_error (clustering_enabled_on_network, [Ref.string_of network]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still want to allow IP address changes when in maintenance mode though, where clustering is temporarily disabled on a host. I think this function also needs to take a host parameter, and then use Xapi_clustering.is_clustering_disabled_on_host. If clustering is disabled allow the ip to be changed, otherwise forbid it.
You can test this with XenCenter by putting one host into maintenance mode, and then trying to change the IP. XenCenter should internally disable the cluster host, change IP, enable it again.
Or if you want to do it from the cli you can xe cluster-host-disable.

Copy link
Contributor Author

@minishrink minishrink Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should only check the network for clusters if clustering is enabled on the host?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@minishrink minishrink force-pushed the feature/REQ477/CA-282006 branch from 4f3a76f to 87715b8 Compare March 9, 2018 13:09
Copy link
Contributor

@edwintorok edwintorok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks the code looks ok now, one minor comment about the location of the tests.
Could you also please squash the last 2 commits into the earlier commits that they fix? (btw you can use git commit --fixup <commitid> when making the change so its easier to remember later which commits have to be squashed where.

finally
(fun () ->
(try
maybe_run_test "reconfigure-ip-cluster" (fun () -> Quicktest_ca282006.test s);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this go in the same file as the other clustering tests?

Copy link
Contributor Author

@minishrink minishrink Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quicktests compile to a different target than the unit tests. I think it might be doable with a bit of jbuild fiddling, but I'm not sure how well it would work.

Alternatively, if you think more quicktests might be necessary, there could just be a quicktest_cluster.ml so we don't just have a random quicktest for one ticket.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quicktest_cluster.ml would be fine, you are right they are different from unit tests, and this is the first clustering quicktest.

@minishrink minishrink force-pushed the feature/REQ477/CA-282006 branch from 4ebe276 to 01d8046 Compare March 12, 2018 10:55
Akanksha Mathur added 3 commits March 12, 2018 11:14
Refactor pif_has_clusters into assert_no_clustering_enabled,
add assertion to PIF.forget and PIF.reconfigure_ip(v4,v6)

CA-282006: Add host check to assert_no_clustering_enabled

Now assertion only checks for clusters attached to network if clustering is enabled on the host,
otherwise this check suffices.

Signed-off-by: Akanksha Mathur <akanksha.mathur@citrix.com>

Conflicts:
	ocaml/xapi/xapi_pif.ml
… datamodel with new errors

Signed-off-by: Akanksha Mathur <akanksha.mathur@citrix.com>
…configuring

CA-282006: Skip tests if no clusters found, don't fail on all API errors

- Remove logic to check for clusters
- Don't test PIF.reconfigure_IP without clustering
- Minor edits to debug lines and comments

Signed-off-by: Akanksha Mathur <akanksha.mathur@citrix.com>

CA-282006: Rename test to quicktest_cluster

Signed-off-by: Akanksha Mathur <akanksha.mathur@citrix.com>
@minishrink minishrink force-pushed the feature/REQ477/CA-282006 branch from 01d8046 to 65e6a90 Compare March 12, 2018 11:17
@edwintorok edwintorok merged commit 74adc41 into xapi-project:feature/REQ477/master Mar 12, 2018
@minishrink minishrink deleted the feature/REQ477/CA-282006 branch March 12, 2018 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants