backport of commit 8da40465af3133df150cf0e0d10c7e1b36fd2151 (#18625)

Co-authored-by: Phil Renaud <phil.renaud@hashicorp.com>
This commit is contained in:
hc-github-team-nomad-core 2023-09-29 14:21:01 -05:00 committed by GitHub
parent 00cf4f973d
commit 269111a369
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

3
.changelog/18621.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: using start/stop from the job page in the UI will no longer fail when the job lacks HCL submission data
```

View File

@ -71,8 +71,17 @@ export default class Title extends Component {
*/
@task(function* (withNotifications = false) {
const job = this.job;
const specification = yield job.fetchRawSpecification();
job.set('_newDefinition', specification.Source);
// Try to get the submission/hcl sourced specification first.
// In the event that this fails, fall back to the raw definition.
try {
const specification = yield job.fetchRawSpecification();
job.set('_newDefinition', specification.Source);
} catch {
const definition = yield job.fetchRawDefinition();
delete definition.Stop;
job.set('_newDefinition', JSON.stringify(definition));
}
try {
yield job.parse();