-
Notifications
You must be signed in to change notification settings - Fork 64
Drop as conversion in inventory
#9541
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
base: main
Are you sure you want to change the base?
Conversation
andrewjstone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for the fix!
|
Definitely like trading |
This came out of a comment from @andrewjstone #9524 (comment) To actually hit this panic, we'd either have to have a zone manifest from a sled return a wildly large size from one part of the databse query or the other omicron/nexus/db-queries/src/db/datastore/inventory.rs Lines 245 to 267 in 06c0808
omicron/nexus/db-queries/src/db/datastore/inventory.rs Lines 3601 to 3641 in 06c0808
we could either say this is unlikely enough to happen or I could attempt to do something like omicron/nexus/db-queries/src/db/datastore/inventory.rs Lines 166 to 184 in 06c0808
and return an internal error? |
|
That's what I would do (InternalError), but I realize that will require changing at least this function to be fallible and I don't know how big the blast radius is. But in general it doesn't seem great if reading bad data from the database can result in a panic. (Could uploading a TUF repo with bad metadata also trigger this?) |
I think you're correct that a bad manifest would potentially trigger this. I think both of these functions are already fallible so I don't think that would be extra work. I am going to raise the question if we don't just want to unwrap if returning an internal error is better for our purposes than the current behavior we get with |
I think it's definitely better than using as. We could accidentally end up with negative sizes otherwise or extremely large ones depending upon conversion direction. We'd want to know if the values are incorrect. I think in order of best to worst the preference should be: return an error, panic, use as And we should only panic if the data is untrusted, meaning it comes from code that generates it and not based on user input. |
Also, I had assumed, perhaps incorrectly that this was trusted data, which is why I figured panicking was fine. If not, I'd suggest returning an error if we can. We've definitely seen problems with sizes of things being incorrect and not discovering it for a while after it was silently causing issues. I think this was on disk sizes but I don't recall. For that reason, panicking is better than silently doing the wrong thing, but if we can not do the wrong thing and not crash, we are in a better place. |
`as` will silently succed which is not what we want
aswill silently succed which is not what we want