Skip to content

CA-408048 remove SM plugins from DB if unavailable#6401

Merged
lindig merged 2 commits into
xapi-project:masterfrom
lindig:private/christianlin/CA-408048
Apr 8, 2025
Merged

CA-408048 remove SM plugins from DB if unavailable#6401
lindig merged 2 commits into
xapi-project:masterfrom
lindig:private/christianlin/CA-408048

Conversation

@lindig
Copy link
Copy Markdown
Contributor

@lindig lindig commented Apr 2, 2025

An SM plugin might become unavailable; we have to remove its record on xapi startup. The canonical case is an upgrade from XS8 to XS9.

@lindig lindig requested a review from incipit0 April 2, 2025 13:04
Copy link
Copy Markdown
Member

@psafont psafont left a comment

Choose a reason for hiding this comment

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

Is this independent from the protect SM plugin list in xapi.conf?

Copy link
Copy Markdown
Contributor

@incipit0 incipit0 left a comment

Choose a reason for hiding this comment

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

This LGTM, if a SM driver is not present in the file system, then there is no point creating an SM object in the database. But this won't help with the deletion of an existing SM though. Imagine an SM object is present in the db, and then it gets removed by the storage layer, then this code will not remove it, as it is not in the list existing

 List.iter
    (fun ty ->
      info
        "Unregistering SM plugin %s since not in the whitelist and not in-use"
        ty ;
      let self, _ = List.assoc ty existing in
      try Db.SM.destroy ~__context ~self with _ -> ()
    )
    (Listext.List.set_difference (List.map fst existing) to_keep) ;

@lindig
Copy link
Copy Markdown
Contributor Author

lindig commented Apr 2, 2025

My intention is to remove SM objects from the DB that have no corresponding plugin. I believe this is the root of the problem that we are trying to fix. Are you saying this is not sufficient? existing initially contains the list of SM objects present in the database.

@lindig
Copy link
Copy Markdown
Contributor Author

lindig commented Apr 3, 2025

This somehow ends up with two SM objects for ifs, gfs2, tmpfs but I don't understand why. This leads to failure of pool join where we check that each type exists once. These duplicates are types that are not in the (xapi.conf) whitelist.

"dummy","/opt/xensource/sm/DummySR"
"ext","/opt/xensource/sm/EXTSR"
"file","/opt/xensource/sm/FileSR"
"gfs2","/opt/xensource/sm/gfs2SR"
"gfs2","/opt/xensource/sm/gfs2SR"
"hba","/opt/xensource/sm/HBASR"
"iscsi","/opt/xensource/sm/ISCSISR"
"iso","/opt/xensource/sm/ISOSR"
"lvmofcoe","/opt/xensource/sm/LVMoFCoESR"
"lvmohba","/opt/xensource/sm/LVMoHBASR"
"lvmoiscsi","/opt/xensource/sm/LVMoISCSISR"
"lvm","/opt/xensource/sm/LVMSR"
"nfs","/opt/xensource/sm/NFSSR"
"smb","/opt/xensource/sm/SMBSR"
"tmpfs","/opt/xensource/sm/tmpfsSR"
"tmpfs","/opt/xensource/sm/tmpfsSR"
"udev","/opt/xensource/sm/udevSR"
"xfs","/opt/xensource/sm/xfsSR"
"xfs","/opt/xensource/sm/xfsSR"

@lindig lindig force-pushed the private/christianlin/CA-408048 branch from 38fbe79 to 4916089 Compare April 4, 2025 09:24
@lindig lindig marked this pull request as ready for review April 4, 2025 13:25
Comment thread ocaml/xapi/storage_access.ml Outdated
(* An SM is either implemented as a plugin - for which we check its
presence, or via an API *)
let is_available (_rf, rc) =
let ( >>= ) x y = String.compare x y >= 0 in
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not simply name it >=?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did not want to redefine >= and indicate that we are using a non-standard relation. In general, version strings are highly ambiguous unless you restrict their syntax. What does 3a mean? Is this a string? Or a number based on an alphabet that has 0..9 and a..z? Or is this actually two fields of a number and a character and how do you define an order over this? So I think these strings are problematic.

@lindig lindig force-pushed the private/christianlin/CA-408048 branch from 4916089 to d3031eb Compare April 7, 2025 14:23
Christian Lindig added 2 commits April 8, 2025 09:24
We want to handle version strings reliably and not re-doscovering their
problems over and over. Add a simple library together with tests.

Signed-off-by: Christian Lindig <christian.lindig@cloud.com>
An SM plugin might become unavailable; we have to remove its record on
xapi startup. The canonical case is an upgrade from XS8 to XS9.

Signed-off-by: Christian Lindig <christian.lindig@cloud.com>
@lindig lindig force-pushed the private/christianlin/CA-408048 branch from d3031eb to efc5b30 Compare April 8, 2025 08:24
@lindig lindig added this pull request to the merge queue Apr 8, 2025
Merged via the queue into xapi-project:master with commit 2c87860 Apr 8, 2025
17 checks passed
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