Skip to content

Conversation

lindig
Copy link
Contributor

@lindig lindig commented Nov 13, 2018

This is work in progress. On joining a pool, the SR for the Guest Tools ISO is a special case. This series of commits tries to avoid that multiple such SRs are present in the final pool.

try
Client.SR.get_all_records ~rpc ~session_id
|> List.find (fun (_, sr) -> sr.API.sR_is_tools_sr)
|> (fun (ref,_) -> ref)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check that the device config is the same and what should happen if it isn't?
What would happen if you start a VM with the tools ISO plugged in, and migrate it to a host which has a newer tools SR? (e.g. during an RPU)
If the contents of the tools ISO is different then I think the SRs should have different UUIDs to avoid accidentally changing the contents of a plugged ISO in a guest.

Copy link
Contributor Author

@lindig lindig Nov 13, 2018

Choose a reason for hiding this comment

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

This is a good point. Should we scan for VMs that have a tools ISO attached?

Copy link
Member

Choose a reason for hiding this comment

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

The host that is joining a pool cannot have any running VMs (another pre-join check further up in this file), so this should not be a problem. This function is not related to RPU either.

@coveralls
Copy link

coveralls commented Nov 13, 2018

Coverage Status

Coverage increased (+0.005%) to 20.924% when pulling 9721c33 on lindig:CA-300103 into 8f94e0e on xapi-project:master.

Copy link
Member

@robhoes robhoes left a comment

Choose a reason for hiding this comment

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

A couple of points to address.

Client.SR.get_by_uuid ~rpc ~session_id ~uuid:my_uuid
with _ ->
if sr.API.sR_is_tools_sr then
(* find the tools ISO and return it *)
Copy link
Member

Choose a reason for hiding this comment

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

"tools SR"

|> List.find (fun (_, sr) -> sr.API.sR_is_tools_sr)
|> (fun (ref,_) -> ref)
with Not_found ->
let msg = Printf.sprintf "can't find SR of tools iso %s" my_uuid in
Copy link
Member

Choose a reason for hiding this comment

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

"tools SR %s"

] in
let destroy self =
try Db.SR.destroy ~__context ~self with e ->
info "failed to destroy bogus tools SR %s: %s"
Copy link
Member

Choose a reason for hiding this comment

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

warn is probably appropriate.

Db.SR.set_is_tools_sr ~__context ~self:sr ~value:true; sr
| sr :: others ->
Db.SR.set_is_tools_sr ~__context ~self:sr ~value:true;
List.iter destroy others; (* destroy bogus Tool SRs CA-300103 *)
Copy link
Member

Choose a reason for hiding this comment

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

We want to do this cleanup of the "old" and "bogus" Tools SRs also if we did find a Tools SR (with is_tools_sr = true), so in the | sr :: [] case.

By the way, the commit message is not quite right: this is not executed on pool join, but when the master xapi starts. Pool join is fixed by the previous commit already. This code is meant to fix things up for pools that already have the bogus tools SRs due the bug that the previous commit fixes.

@robhoes
Copy link
Member

robhoes commented Nov 15, 2018

Avoid duplicated tool ISOs on pool join

"tools SRs"

@lindig
Copy link
Contributor Author

lindig commented Nov 15, 2018

I have addressed to comments in a new commit but would merge this into one coherent commit before we merge this.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
We need to make sure that only a single Tools SR exists. This commit
ensures this by:

* use sR_is_tools_sr to find all Tools SR rather than a heuristic
* if multiple such SRs exists, destroy all but one and destroy all
  legacy SRs
* if only legacy SRs exists, select one, promote it, and
  destroy the others
* if none exist, create one
* make sure that the elected Tool ISO SR has the correct device config -
  especially when it was imported.
* remove update_tools_sr_pbd_device_config from upgrade rules.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
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.

The build failure in xenserver-buildenv is because it hasn't caught up with the build from Jenkins yet

@robhoes
Copy link
Member

robhoes commented Nov 16, 2018

It may be worth adding some unit tests to test_dbsync_master.ml. That would give us more confidence that the corner cases are working.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
@lindig
Copy link
Contributor Author

lindig commented Nov 16, 2018

I have added two unit tests.

@robhoes robhoes changed the title WIP CA-300103 Avoid duplicated tool ISOs on pool join CA-300103 Avoid duplicated tools SRs on pool join Nov 16, 2018
@robhoes robhoes merged commit bc557fc into xapi-project:master Nov 16, 2018
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.

4 participants