Fix allocation count in CSI volumes table (#9515)
This closes #9495. As detailed in there, the collection query GET /v1/volumes?type=csi doesn’t return ReadAllocs and WriteAllocs, so the # Allocs cell was always showing 0 upon first load because it was derived from the lengths of those arrays. This uses the heretofore-ignored CurrentReaders and CurrentWriters values to calculate the total instead. The single-resource query GET /v1/volume/csi%2F:id doesn’t return CurrentReaders and CurrentWriters that absence doesn’t override the stored values when visiting an individual item. Thanks to @apollo13 for reporting this and to @tgross for the API logs and suggestion.
This commit is contained in:
parent
2d344179d3
commit
543fb24764
|
@ -18,6 +18,14 @@ export default class Volume extends Model {
|
||||||
return [...this.writeAllocations.toArray(), ...this.readAllocations.toArray()];
|
return [...this.writeAllocations.toArray(), ...this.readAllocations.toArray()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@attr('number') currentWriters;
|
||||||
|
@attr('number') currentReaders;
|
||||||
|
|
||||||
|
@computed('currentWriters', 'currentReaders')
|
||||||
|
get allocationCount() {
|
||||||
|
return this.currentWriters + this.currentReaders;
|
||||||
|
}
|
||||||
|
|
||||||
@attr('string') externalId;
|
@attr('string') externalId;
|
||||||
@attr() topologies;
|
@attr() topologies;
|
||||||
@attr('string') accessMode;
|
@attr('string') accessMode;
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
({{row.model.nodesHealthy}}/{{row.model.nodesExpected}})
|
({{row.model.nodesHealthy}}/{{row.model.nodesExpected}})
|
||||||
</td>
|
</td>
|
||||||
<td data-test-volume-provider>{{row.model.provider}}</td>
|
<td data-test-volume-provider>{{row.model.provider}}</td>
|
||||||
<td data-test-volume-allocations>{{row.model.allocations.length}}</td>
|
<td data-test-volume-allocations>{{row.model.allocationCount}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</t.body>
|
</t.body>
|
||||||
</ListTable>
|
</ListTable>
|
||||||
|
|
|
@ -14,7 +14,7 @@ export default ApplicationSerializer.extend({
|
||||||
serialize() {
|
serialize() {
|
||||||
var json = ApplicationSerializer.prototype.serialize.apply(this, arguments);
|
var json = ApplicationSerializer.prototype.serialize.apply(this, arguments);
|
||||||
if (json instanceof Array) {
|
if (json instanceof Array) {
|
||||||
json.forEach(serializeVolume);
|
json.forEach(serializeVolumeFromArray);
|
||||||
} else {
|
} else {
|
||||||
serializeVolume(json);
|
serializeVolume(json);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,14 @@ export default ApplicationSerializer.extend({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function serializeVolumeFromArray(volume) {
|
||||||
|
volume.CurrentWriters = volume.WriteAllocs.length;
|
||||||
|
delete volume.WriteAllocs;
|
||||||
|
|
||||||
|
volume.CurrentReaders = volume.ReadAllocs.length;
|
||||||
|
delete volume.ReadAllocs;
|
||||||
|
}
|
||||||
|
|
||||||
function serializeVolume(volume) {
|
function serializeVolume(volume) {
|
||||||
volume.WriteAllocs = groupBy(volume.WriteAllocs, 'ID');
|
volume.WriteAllocs = groupBy(volume.WriteAllocs, 'ID');
|
||||||
volume.ReadAllocs = groupBy(volume.ReadAllocs, 'ID');
|
volume.ReadAllocs = groupBy(volume.ReadAllocs, 'ID');
|
||||||
|
|
Loading…
Reference in New Issue