Skip to content
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

Add disk generation to inventory #7162

Merged
merged 4 commits into from
Nov 26, 2024
Merged

Conversation

andrewjstone
Copy link
Contributor

This is the first PR related to fixing #7098

This is the first PR related to fixing 7098
@@ -0,0 +1,3 @@
ALTER TABLE omicron.public.inv_sled_agent
ADD COLUMN IF NOT EXISTS omicrion_physical_disks_generation INT8
NOT NULL DEFAULT 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was wondering whether or not "zero" would be an invalid generation number -- since we start counting from "1":

https://github.com/oxidecomputer/omicron/blob/main/common/src/api/external/mod.rs#L755-L757

But weirdly this seems to be fine. A "zero value generation number" is still a valid u64, and would succeed when parsed out of the database as an i64:

https://github.com/oxidecomputer/omicron/blob/main/common/src/api/external/mod.rs#L808-L817

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is intentional. Zero is less than any valid generation number, and therefore will always indicate that we don't know if the sled-agent has seen any OmicronPhysicalDisksConfig. We could have used a NULL column, but this is only for backfilling, and moving forward we won't want a NULL here at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is intentional. Zero is less than any valid generation number, and therefore will always indicate that we don't know if the sled-agent has seen any OmicronPhysicalDisksConfig. We could have used a NULL column, but this is only for backfilling, and moving forward we won't want a NULL here at all.

I suppose since the StorageResources always returns Generation::new which will be in any new inventory, we may actually want to default this to 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it from 0 to 1 in 6d9616e

Copy link
Collaborator

Choose a reason for hiding this comment

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

eh, was gonna say, 0 would actually be okay to me, because any place we'd compare it with the "initial inventory collection, with value of 1", the real data would evaluate as "greater than" the stub value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I had the same thought. What convinced me to change it was that an empty inventory reports as Generation 1 after this PR and not 0. So we still need any "real" disk inventory to have Generation 2 to notice a change in the planner. This argues for some consistency, but is a somewhat weak argument.

Copy link
Contributor

Choose a reason for hiding this comment

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

Light 👍 on 1 over 0; generation 1 is already "the initial/empty set" for zones and datasets, so I assume that's true for disks too? (Or should be if it isn't!). Also it shouldn't really matter much, I think? Inventory turns over pretty quickly, so whatever default we have here should be gone after a few minutes.

@andrewjstone andrewjstone enabled auto-merge (squash) November 25, 2024 20:16
@andrewjstone andrewjstone merged commit 03ede4a into main Nov 26, 2024
17 checks passed
@andrewjstone andrewjstone deleted the disk-generation-in-inventory branch November 26, 2024 06:22
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