-
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
UI: Preemptions #5594
UI: Preemptions #5594
Changes from all commits
cf1d4a3
c456c5e
384a0e5
dca386c
a33b105
7ae2081
400deae
4752950
4c773a1
d4ae0a2
c7e1598
5aa938e
d092723
4166a71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ export default Controller.extend(Sortable, Searchable, { | |
searchTerm: 'search', | ||
sortProperty: 'sort', | ||
sortDescending: 'desc', | ||
onlyPreemptions: 'preemptions', | ||
}, | ||
|
||
currentPage: 1, | ||
|
@@ -20,10 +21,25 @@ export default Controller.extend(Sortable, Searchable, { | |
|
||
searchProps: computed(() => ['shortId', 'name']), | ||
|
||
listToSort: alias('model.allocations'), | ||
onlyPreemptions: false, | ||
|
||
visibleAllocations: computed( | ||
'model.allocations.[]', | ||
'preemptions.[]', | ||
'onlyPreemptions', | ||
function() { | ||
return this.onlyPreemptions ? this.preemptions : this.model.allocations; | ||
} | ||
), | ||
|
||
listToSort: alias('visibleAllocations'), | ||
listToSearch: alias('listSorted'), | ||
sortedAllocations: alias('listSearched'), | ||
|
||
preemptions: computed('[email protected]', function() { | ||
return this.model.allocations.filterBy('wasPreempted'); | ||
}), | ||
|
||
sortedEvents: computed('[email protected]', function() { | ||
return this.get('model.events') | ||
.sortBy('time') | ||
|
@@ -38,5 +54,9 @@ export default Controller.extend(Sortable, Searchable, { | |
gotoAllocation(allocation) { | ||
this.transitionToRoute('allocations.allocation', allocation); | ||
}, | ||
|
||
setPreemptionFilter(value) { | ||
this.set('onlyPreemptions', value); | ||
}, | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import Model from 'ember-data/model'; | ||
import attr from 'ember-data/attr'; | ||
import { fragmentArray } from 'ember-data-model-fragments/attributes'; | ||
import { hasMany } from 'ember-data/relationships'; | ||
|
||
export default Model.extend({ | ||
diff: attr(), | ||
failedTGAllocs: fragmentArray('placement-failure', { defaultValue: () => [] }), | ||
preemptions: hasMany('allocation'), | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
setupController(controller, model) { | ||
// Suppress the preemptedByAllocation fetch error in the event it's a 404 | ||
if (model) { | ||
const setPreempter = () => controller.set('preempter', model.preemptedByAllocation); | ||
model.preemptedByAllocation.then(setPreempter, setPreempter); | ||
} | ||
|
||
return this._super(...arguments); | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { assign } from '@ember/polyfills'; | ||
import ApplicationSerializer from './application'; | ||
import { get } from '@ember/object'; | ||
|
||
export default ApplicationSerializer.extend({ | ||
normalize(typeHash, hash) { | ||
const failures = hash.FailedTGAllocs || {}; | ||
hash.FailedTGAllocs = Object.keys(failures).map(key => { | ||
return assign({ Name: key }, failures[key] || {}); | ||
}); | ||
hash.PreemptionIDs = (get(hash, 'Annotations.PreemptedAllocs') || []).mapBy('ID'); | ||
return this._super(...arguments); | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,6 @@ | |
|
||
&.is-right { | ||
margin-left: $gutter-width; | ||
overflow-x: auto; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to include this here? Would this mean you can't pan on mobile anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did mean to include this. It was causing the icon tooltip to be clipped on the left side where it goes out of the bounds of the page-column. As for panning on mobile, good question. I just checked and it appears to still work. |
||
} | ||
|
||
@media #{$mq-hidden-gutter} { | ||
|
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.
Wondering if this boolean casting would be done by the
attr('boolean')
in the model?Also I had a quick scan over the docs here:
https://www.nomadproject.io/docs/internals/scheduling/preemption.html#preemptedbyallocid
Does
hash.PreemptedByAllocationID
==PreemptedByAllocID
? (Allocation vs Alloc). Thinking it could be something wrong in the docs, thought I'd mention just incase?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 boolean casting is probably taken care of by the
boolean
transformer, yes, but I'm not sure I want to rely on a transformer for it.Yes, the docs are wrong in this case. Here's the go struct to confirm: https://github.com/hashicorp/nomad/blob/master/nomad/structs/structs.go#L7261-L7267