Skip to content
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] Preserve HCL2 on stop/start via the web UI #18120

Merged
merged 4 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/18120.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: maintain HCL2 jobspec when using Start Job in the web ui
```
6 changes: 2 additions & 4 deletions ui/app/components/job-page/parts/title.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ export default class Title extends Component {
*/
@task(function* (withNotifications = false) {
const job = this.job;
const definition = yield job.fetchRawDefinition();

delete definition.Stop;
job.set('_newDefinition', JSON.stringify(definition));
const specification = yield job.fetchRawSpecification();
job.set('_newDefinition', specification.Source);

try {
yield job.parse();
Expand Down
2 changes: 1 addition & 1 deletion ui/mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function () {
200,
{},
JSON.stringify({
Source: 'the job source v0',
Source: `job "${req.params.id}" {`,
Format: 'hcl2',
VariableFlags: { X: 'x', Y: '42', Z: 'true' },
Variables: 'var file content',
Expand Down
7 changes: 1 addition & 6 deletions ui/tests/integration/components/job-page/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,12 @@ export async function purgeJob() {

export function expectStartRequest(assert, server, job) {
const expectedURL = jobURL(job);

const request = server.pretender.handledRequests
.filterBy('method', 'POST')
.find((req) => req.url === expectedURL);

const requestPayload = JSON.parse(request.requestBody).Job;

assert.ok(request, 'POST URL was made correctly');
assert.ok(
requestPayload.Stop == null,
'The Stop signal is not sent in the POST request'
);
}

export async function expectError(assert, title) {
Expand Down
3 changes: 2 additions & 1 deletion ui/tests/integration/components/job-page/periodic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module('Integration | Component | job-page/periodic', function (hooks) {
this.server = startMirage();
this.server.create('namespace');
this.server.create('node-pool');
this.server.create('node');
});

hooks.afterEach(function () {
Expand Down Expand Up @@ -194,7 +195,7 @@ module('Integration | Component | job-page/periodic', function (hooks) {
});

test('Starting a job sends a post request for the job using the current definition', async function (assert) {
assert.expect(2);
assert.expect(1);

const mirageJob = this.server.create('job', 'periodic', {
childrenCount: 0,
Expand Down
4 changes: 2 additions & 2 deletions ui/tests/integration/components/job-page/service-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module('Integration | Component | job-page/service', function (hooks) {
this.server = startMirage();
this.server.create('namespace');
this.server.create('node-pool');
this.server.create('node');
});

hooks.afterEach(function () {
Expand Down Expand Up @@ -109,7 +110,7 @@ module('Integration | Component | job-page/service', function (hooks) {
});

test('Starting a job sends a post request for the job using the current definition', async function (assert) {
assert.expect(2);
assert.expect(1);

const mirageJob = makeMirageJob(this.server, { status: 'dead' });
await this.store.findAll('job');
Expand Down Expand Up @@ -137,7 +138,6 @@ module('Integration | Component | job-page/service', function (hooks) {
await render(commonTemplate);

await startJob();

await expectError(assert, 'Could Not Start Job');
});

Expand Down
Loading