-
Notifications
You must be signed in to change notification settings - Fork 2k
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
csi/api: populate ReadAllocs/WriteAllocs fields #9377
Conversation
ui/app/serializers/volume.js
Outdated
hash.ReadAllocations = Object.keys(readAllocs).map(bindIDToAlloc(readAllocs)); | ||
hash.WriteAllocations = Object.keys(writeAllocs).map(bindIDToAlloc(writeAllocs)); | ||
hash.ReadAllocations = Object.keys(readAllocs).map(bindIDToAlloc(hash.Allocations)); | ||
hash.WriteAllocations = Object.keys(writeAllocs).map(bindIDToAlloc(hash.Allocations)); |
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.
Question for reviewers: would it save browser memory if we nulled-out the hash.Allocations
, hash.ReadAllocs
and hash.WriteAllocs
fields after we're done with them here? Or is this object so ephemeral that it's meaningless to do so?
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.
I don't know off the top of my head if hash sticks around or if a copy is what gets inserted into the store. It wouldn't hurt to add a delete hash.Allocations
just to err on the side of caution.
Ember Asset Size actionAs of efdce68 Files that got Bigger 🚨:
Files that stayed the same size 🤷:
|
Ember Test Audit comparison
|
80cd829
to
6b246ee
Compare
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.
The golang side is LGTM.
|
||
// WriteAllocs is a map of allocation IDs for tracking writer claim | ||
// status. The Allocation value will always be nil; clients can populate | ||
// this data by iterating over the Allocations field. | ||
WriteAllocs map[string]*Allocation |
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.
Curious why we chose this representation? If the map value is never a populated alloc, how does it compare to using map[string]bool
(explicitly meaningless value) or a plain slice []string
(avoid value but losing uniqueness)? Not advocating for changing it, specially if we are constrained by compatibility.
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.
It's solely constrained by compatibility at this point, unfortunately.
With 20/20 hindsight, we would have had the nomad/structs
version store only the CSIVolumeClaim
s and not allocations (which has been a huge complication with respect to garbage collected jobs and allocations), and then had this API struct return WriteAllocs map[string]*AllocationListStub
and ReadAllocs map[string]*AllocationListStub
, without an Allocations
field at all. See #8734 for more
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.
I had a note on performance, but I'll let you decide if it's worth changing.
ui/app/serializers/volume.js
Outdated
hash.ReadAllocations = Object.keys(readAllocs).map(bindIDToAlloc(readAllocs)); | ||
hash.WriteAllocations = Object.keys(writeAllocs).map(bindIDToAlloc(writeAllocs)); | ||
hash.ReadAllocations = Object.keys(readAllocs).map(bindIDToAlloc(hash.Allocations)); | ||
hash.WriteAllocations = Object.keys(writeAllocs).map(bindIDToAlloc(hash.Allocations)); |
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.
I don't know off the top of my head if hash sticks around or if a copy is what gets inserted into the store. It wouldn't hurt to add a delete hash.Allocations
just to err on the side of caution.
The API is missing values for `ReadAllocs` and `WriteAllocs` fields, resulting in allocation claims not being populated in the web UI. These fields mirror the fields in `nomad/structs.CSIVolume`. Returning a separate list of stubs for read and write would be ideal, but this can't be done without either bloating the API response with repeated full `Allocation` data, or causing a panic in previous versions of the CLI. The `nomad/structs` fields are persisted with nil values and are populated during RPC, so we'll do the same in the HTTP API and populate the `ReadAllocs` and `WriteAllocs` fields with a map of allocation IDs, but with null values. The web UI will then create its `ReadAllocations` and `WriteAllocations` fields by mapping from those IDs to the values in `Allocations`, instead of flattening the map into a list.
6b246ee
to
198264e
Compare
198264e
to
d095329
Compare
d095329
to
efdce68
Compare
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Fixes #9215
The API is missing values for
ReadAllocs
andWriteAllocs
fields, resultingin allocation claims not being populated in the web UI. These fields mirror
the fields in
nomad/structs.CSIVolume
. Returning a separate list of stubsfor read and write would be ideal, but this can't be done without either
bloating the API response with repeated full
Allocation
data, or causing apanic in previous versions of the CLI.
The
nomad/structs
fields are persisted with nil values and are populatedduring RPC, so we'll do the same in the HTTP API and populate the
ReadAllocs
and
WriteAllocs
fields with a map of allocation IDs, but with nullvalues. The web UI will then create its
ReadAllocations
andWriteAllocations
fields by mapping from those IDs to the values inAllocations
, instead of flattening the map into a list.I've tested this out via the web UI and verified
nomad volume status
,nomad alloc status
, andnomad node status
aren't broken, including with a v0.12.8 version of the command line.