Skip to content

Commit

Permalink
Warnings shown at plan stage
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Nov 29, 2023
1 parent 906ffc8 commit 40fc25d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .changelog/19225.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: show plan output warnings alongside placement failures and dry-run info when running a job through the web ui
```
18 changes: 18 additions & 0 deletions ui/app/components/job-editor/review.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Component from '@glimmer/component';
import { htmlSafe } from '@ember/template';

export default class JobEditorReviewComponent extends Component {
// Slightly formats the warning string to be more readable
get warnings() {
return htmlSafe(
(this.args.data.planOutput.warnings || '')
.replace(/\n/g, '<br>')
.replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;')
);
}
}
4 changes: 3 additions & 1 deletion ui/app/models/job-plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default class JobPlan extends Model {
@attr() diff;
@fragmentArray('placement-failure', { defaultValue: () => [] })
failedTGAllocs;
// TODO: add warnings here?

@hasMany('allocation') preemptions;

@attr('string') warnings;
}
35 changes: 22 additions & 13 deletions ui/app/templates/components/job-editor/review.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,32 @@
/>
</div>
</div>
<div
class="boxed-section
{{if @data.planOutput.failedTGAllocs 'is-warning' 'is-primary'}}"
data-test-dry-run-message
>
<div class="boxed-section-head" data-test-dry-run-title>Scheduler dry-run</div>
<div class="boxed-section-body" data-test-dry-run-body>
{{!-- TODO: warnings here? --}}

<Hds::Alert @type="inline" @color={{if @data.planOutput.failedTGAllocs "critical" "success"}} data-test-dry-run-message as |A|>
<A.Title data-test-dry-run-title>Scheduler dry-run</A.Title>
<A.Description data-test-dry-run-body>
{{#if @data.planOutput.failedTGAllocs}}
{{#each @data.planOutput.failedTGAllocs as |placementFailure|}}
{{#each @data.planOutput.failedTGAllocs as |placementFailure|}}
<PlacementFailure @failedTGAlloc={{placementFailure}} />
{{/each}}
{{/each}}
{{else}}
All tasks successfully allocated.
All tasks successfully allocated.
{{/if}}
</div>
</div>
</A.Description>
</Hds::Alert>
<br>

{{#if this.warnings}}
<Hds::Alert @type="inline" @color="warning" as |A|>
<A.Description>
<p>
{{this.warnings}}
</p>
</A.Description>
</Hds::Alert>
<br>
{{/if}}

{{#if
(and
@data.planOutput.preemptions.isFulfilled @data.planOutput.preemptions.length
Expand Down

0 comments on commit 40fc25d

Please sign in to comment.