Properly manage the lifecycle of allocations for storage nodes and controllers

This commit is contained in:
Michael Lange
2020-05-11 19:59:38 -07:00
parent cb6b9dc1f2
commit 32b4e5e8ab
4 changed files with 32 additions and 26 deletions

View File

@@ -1,7 +1,23 @@
import { alias } from '@ember/object/computed';
import AllocationRow from 'nomad-ui/components/allocation-row';
export default AllocationRow.extend({
pluginAllocation: null,
allocation: alias('pluginAllocation.allocation'),
allocation: null,
didReceiveAttrs() {
this.setAllocation();
},
// The allocation for the plugin's controller or storage plugin needs
// to be imperatively fetched since these plugins are Fragments which
// can't have relationships.
async setAllocation() {
if (this.pluginAllocation && !this.allocation) {
const allocation = await this.pluginAllocation.getAllocation();
if (!this.isDestroyed) {
this.set('allocation', allocation);
this.updateStatsTracker();
}
}
},
});