[ui] Adds a "Scheduling" filter to the job.allocations page (#17227)

* Basic filter concept

* Make sure NextAllocation gets sent up with allocation stub
This commit is contained in:
Phil Renaud 2023-05-18 16:24:41 -04:00 committed by GitHub
parent beba92ab36
commit 7e56ca62d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 96 additions and 14 deletions

View File

@ -326,6 +326,7 @@ func (a *Allocation) Stub() *AllocationListStub {
TaskStates: a.TaskStates,
DeploymentStatus: a.DeploymentStatus,
FollowupEvalID: a.FollowupEvalID,
NextAllocation: a.JobID,
RescheduleTracker: a.RescheduleTracker,
PreemptedAllocations: a.PreemptedAllocations,
PreemptedByAllocation: a.PreemptedByAllocation,
@ -379,6 +380,7 @@ type AllocationListStub struct {
TaskStates map[string]*TaskState
DeploymentStatus *AllocDeploymentStatus
FollowupEvalID string
NextAllocation string
RescheduleTracker *RescheduleTracker
PreemptedAllocations []string
PreemptedByAllocation string

View File

@ -10896,6 +10896,7 @@ func (a *Allocation) Stub(fields *AllocStubFields) *AllocListStub {
TaskStates: a.TaskStates,
DeploymentStatus: a.DeploymentStatus,
FollowupEvalID: a.FollowupEvalID,
NextAllocation: a.NextAllocation,
RescheduleTracker: a.RescheduleTracker,
PreemptedAllocations: a.PreemptedAllocations,
PreemptedByAllocation: a.PreemptedByAllocation,
@ -11058,6 +11059,7 @@ type AllocListStub struct {
TaskStates map[string]*TaskState
DeploymentStatus *AllocDeploymentStatus
FollowupEvalID string
NextAllocation string
RescheduleTracker *RescheduleTracker
PreemptedAllocations []string
PreemptedByAllocation string

View File

@ -9,14 +9,28 @@
<FlightIcon @name="info" />
</span>
</h4>
<ConditionalLinkTo
@condition={{this.shouldLinkToAllocations}}
@route="jobs.job.allocations"
@model={{@job}}
@query={{hash status=(concat '["failed", "lost", "unknown"]') version=(concat '[' @job.latestDeployment.versionNumber ']')}}
@label="View Allocations"
@class="failed-or-lost-link"
>
{{@allocs.length}}
</ConditionalLinkTo>
{{#if (eq @title "Rescheduled")}}
<ConditionalLinkTo
@condition={{this.shouldLinkToAllocations}}
@route="jobs.job.allocations"
@model={{@job}}
@query={{hash scheduling=(concat '["has-been-rescheduled"]') version=(concat '[' @job.latestDeployment.versionNumber ']')}}
@label="View Allocations"
@class="failed-or-lost-link"
>
{{@allocs.length}}
</ConditionalLinkTo>
{{/if}}
{{#if (eq @title "Restarted")}}
<ConditionalLinkTo
@condition={{this.shouldLinkToAllocations}}
@route="jobs.job.allocations"
@model={{@job}}
@query={{hash scheduling=(concat '["has-been-restarted"]') version=(concat '[' @job.latestDeployment.versionNumber ']')}}
@label="View Allocations"
@class="failed-or-lost-link"
>
{{@allocs.length}}
</ConditionalLinkTo>
{{/if}}
</section>

View File

@ -2,6 +2,6 @@ import Component from '@glimmer/component';
export default class JobStatusFailedOrLostComponent extends Component {
get shouldLinkToAllocations() {
return this.args.title !== 'Restarted' && this.args.allocs.length;
return this.args.allocs.length;
}
}

View File

@ -48,7 +48,7 @@
@condition={{not (eq type.label "unplaced")}}
@route="jobs.job.allocations"
@model={{@job}}
@query={{hash status=(concat '["' type.label '"]') version=(concat '[' (keys this.versions) ']')}}
@query={{hash status=(concat '["' type.label '"]') version=(concat '[' (map-by "version" this.versions) ']')}}
@class="legend-item {{if (eq (get (get (get (get this.allocBlocks type.label) 'healthy') 'nonCanary') "length") 0) "faded"}}"
@label="View {{type.label}} allocations"
>

View File

@ -49,6 +49,9 @@ export default class AllocationsController extends Controller.extend(
{
qpVersion: 'version',
},
{
qpScheduling: 'scheduling',
},
'activeTask',
];
@ -56,6 +59,7 @@ export default class AllocationsController extends Controller.extend(
qpClient = '';
qpTaskGroup = '';
qpVersion = '';
qpScheduling = '';
currentPage = 1;
pageSize = 25;
activeTask = null;
@ -80,7 +84,8 @@ export default class AllocationsController extends Controller.extend(
'selectionStatus',
'selectionClient',
'selectionTaskGroup',
'selectionVersion'
'selectionVersion',
'selectionScheduling'
)
get filteredAllocations() {
const {
@ -88,6 +93,7 @@ export default class AllocationsController extends Controller.extend(
selectionClient,
selectionTaskGroup,
selectionVersion,
selectionScheduling,
} = this;
return this.allocations.filter((alloc) => {
@ -115,6 +121,35 @@ export default class AllocationsController extends Controller.extend(
) {
return false;
}
if (selectionScheduling.length) {
if (
selectionScheduling.includes('will-not-reschedule') &&
!alloc.willNotReschedule
) {
return false;
}
if (
selectionScheduling.includes('will-not-restart') &&
!alloc.willNotRestart
) {
return false;
}
if (
selectionScheduling.includes('has-been-rescheduled') &&
!alloc.hasBeenRescheduled
) {
return false;
}
if (
selectionScheduling.includes('has-been-restarted') &&
!alloc.hasBeenRestarted
) {
return false;
}
return true;
}
return true;
});
}
@ -127,6 +162,7 @@ export default class AllocationsController extends Controller.extend(
@selection('qpClient') selectionClient;
@selection('qpTaskGroup') selectionTaskGroup;
@selection('qpVersion') selectionVersion;
@selection('qpScheduling') selectionScheduling;
@action
gotoAllocation(allocation) {
@ -198,6 +234,28 @@ export default class AllocationsController extends Controller.extend(
return versions.sort((a, b) => a - b).map((v) => ({ key: v, label: v }));
}
@computed('model.allocations.[]', 'selectionScheduling')
get optionsScheduling() {
return [
{
key: 'has-been-rescheduled',
label: 'Failed & Has Been Rescheduled',
},
{
key: 'will-not-reschedule',
label: "Failed & Won't Reschedule",
},
{
key: 'has-been-restarted',
label: 'Has Been Restarted',
},
{
key: 'will-not-restart',
label: "Won't Restart",
},
];
}
setFacetQueryParam(queryParam, selection) {
this.set(queryParam, serialize(selection));
}

View File

@ -4,7 +4,7 @@
~}}
<BasicDropdown
@horizontalPosition="left"
@horizontalPosition="auto"
@onOpen={{action
(queue (action (mut this.isOpen) true) (action this.capture))
}}

View File

@ -45,6 +45,12 @@
@selection={{this.selectionVersion}}
@onSelect={{action this.setFacetQueryParam "qpVersion"}}
/>
<MultiSelectDropdown
@label="Scheduling"
@options={{this.optionsScheduling}}
@selection={{this.selectionScheduling}}
@onSelect={{action this.setFacetQueryParam "qpScheduling"}}
/>
</div>
</div>
</div>