Skip to content

Parse M.2s, propagate parent information about zpools to Nexus#2708

Merged
smklein merged 13 commits into
mainfrom
m2
Apr 14, 2023
Merged

Parse M.2s, propagate parent information about zpools to Nexus#2708
smklein merged 13 commits into
mainfrom
m2

Conversation

@smklein

@smklein smklein commented Mar 30, 2023

Copy link
Copy Markdown
Collaborator

Sled Agent (and illumos-utils, sled-hardware)

  • Parse Zpools with the oxi_ prefix, in addition to those with the oxp_ prefix
  • Pass information about the parent disk up to Nexus when notifying about zpools.
    • This is necessary for Nexus to identify "what should be provisioned to this zpool", by correlating the pool with the corresponding physical disk.

Nexus

  • Update the "Zpool PUT" API to include the identifying information for the parent disk
  • As part of the implementation of Zpool PUT, look up the parent disk, and insert that parent disk UUID into the Zpool DB row.

This is the first part of #2688

@smklein smklein marked this pull request as ready for review March 30, 2023 02:25
@smklein smklein requested a review from davepacheco March 30, 2023 02:29
})?;
let id = Uuid::from_str(s).map_err(|e| e.to_string())?;
Ok(ZpoolName(id))
if let Some(s) = s.strip_prefix(ZPOOL_EXTERNAL_PREFIX) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: this looks duplicated from above. I think you could just call one impl from the other?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure, updated to have the serde impl call from_str.

Comment thread common/src/sql/dbinit.sql

/* TODO: Could also store physical disk FK here */
/* FK into the Physical Disk table */
physical_disk_id UUID NOT NULL,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It seems like we're officially baking in the assumption that each zpool is backed by exactly one physical disk here. I guess we should update the comment above.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure, updated (from "Typically these are backed by a single physical disk" to simply "These are backed by a single physical disk").

.filter(dsl::serial.eq(serial.clone()))
.filter(dsl::model.eq(model.clone()))
.select(PhysicalDisk::as_select())
.first_async(self.pool())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: pool_authorized()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated

.map_err(|e| public_error_from_diesel_pool(e, ErrorHandler::Server))
}

pub async fn physical_disk_lookup(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we have a physical_disk LookupPath type?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I believe we already do:

lookup_resource! {
name = "PhysicalDisk",
ancestors = [],
children = [],
lookup_by_name = false,
soft_deletes = true,
primary_key_columns = [ { column_name = "id", rust_type = Uuid } ]
}

The primary key is already an ID, but I'm not sure how to say "this object can also be uniquely looked-up by vendor/serial/model".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Went ahead and updated the PK columns here: 1563a70 -- seems to work

@smklein smklein Apr 14, 2023

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Okay, actually, this required some follow-up changes in d997cc3 too

Comment thread nexus/types/src/internal_api/params.rs Outdated
pub size: ByteCount,

// Information to identify the disk to which this zpool belongs
pub vendor: String,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: prefix here, like "disk_vendor"? (it seems a little confusing to call these the "vendor", "serial", and "model" of the zpool)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated for vendor, serial, and model.

// NOTE: This relies on the name being a UUID exactly.
// We could be more flexible...
Ok(Pool { id: name.id(), info, zones: HashMap::new(), disk_path })
Ok(Pool { name, info, zones: HashMap::new(), parent })

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The comment above this line seems not quite true?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment removed

@smklein smklein merged commit ae0cc5b into main Apr 14, 2023
@smklein smklein deleted the m2 branch April 14, 2023 22:41
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.

2 participants