Skip to content

Commit

Permalink
Change allocation count calculation
Browse files Browse the repository at this point in the history
The API includes CurrentWriters and CurrentReaders in the
collection response, so this uses that instead of counting
WriteAllocs and ReadAllocs, which are not returned in the
collection.

The individual volume response doesn’t include CurrentWriters
and CurrentReaders but their absence doesn’t erase the values.
  • Loading branch information
backspace committed Dec 3, 2020
1 parent 2b7f04d commit 94247f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ui/app/models/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export default class Volume extends Model {
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() topologies;
@attr('string') accessMode;
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/csi/volumes/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
({{row.model.nodesHealthy}}/{{row.model.nodesExpected}})
</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>
</t.body>
</ListTable>
Expand Down
3 changes: 3 additions & 0 deletions ui/mirage/serializers/csi-volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export default ApplicationSerializer.extend({
});

function serializeVolumeFromArray(volume) {
volume.CurrentWriters = volume.WriteAllocs.length;
delete volume.WriteAllocs;

volume.CurrentReaders = volume.ReadAllocs.length;
delete volume.ReadAllocs;
}

Expand Down

0 comments on commit 94247f3

Please sign in to comment.