Skip to content

Commit

Permalink
A few code comments and log cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Nov 7, 2024
1 parent 1090dc3 commit 97d3f8c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
14 changes: 14 additions & 0 deletions ui/app/adapters/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,25 @@ export default class JobAdapter extends WatchableNamespaceIDs {
summary: '/summary',
};

/**
* Gets the JSON definition of a job.
* Prior to Nomad 1.6, this was the only way to get job definition data.
* Now, this is included as a stringified JSON object when fetching raw specification (under .Source).
* This method is still important for backwards compatibility with older job versions, as well as a fallback
* for when fetching raw specification fails.
* @param {import('../models/job').default} job
*/
fetchRawDefinition(job) {
const url = this.urlForFindRecord(job.get('id'), 'job');
return this.ajax(url, 'GET');
}

/**
* Gets submission info for a job, including (if available) the raw HCL or JSON spec used to run it,
* including variable flags and literals.
* @param {import('../models/job').default} job
* @param {number} version
*/
fetchRawSpecification(job, version) {
const url = addToPath(
this.urlForFindRecord(job.get('id'), 'job', null, 'submission'),
Expand Down
6 changes: 4 additions & 2 deletions ui/app/routes/jobs/job/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ export default class DefinitionRoute extends Route {
if (!job) return;

let definition;
console.log('version', version);

if (version !== undefined) {
// version can be 0, can't !version check.
// Not (!version) because version can be 0
try {
const versionResponse = await job.getVersions();
const versions = versionResponse.Versions;
Expand All @@ -54,6 +53,8 @@ export default class DefinitionRoute extends Route {
definition = await job.fetchRawDefinition();
}

console.log({ definition });

let format = 'json'; // default to json in network request errors
let specification;
let variableFlags;
Expand All @@ -64,6 +65,7 @@ export default class DefinitionRoute extends Route {
variableFlags = specificationResponse?.VariableFlags ?? null;
variableLiteral = specificationResponse?.Variables ?? null;
format = specificationResponse?.Format ?? 'json';
console.log({ specification, variableFlags, variableLiteral, format });
} catch (e) {
// Swallow the error because Nomad job pre-1.6 will not have a specification
}
Expand Down
2 changes: 0 additions & 2 deletions ui/app/routes/jobs/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export default class JobsRunIndexRoute extends Route {
_newDefinition: templateRecord.items.template,
});
} else if (sourceString) {
// console.log('elsif', sourceString);
// Add an alert to the page to let the user know that they are submitting a job from a template, and that they should change the name!
return this.store.createRecord('job', {
_newDefinition: sourceString,
});
Expand Down
4 changes: 0 additions & 4 deletions ui/app/templates/components/job-version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
@color="secondary"
@size="small"
@isInline={{true}}
{{!-- @disabled={{this.revertTo.isRunning}} --}}
{{on "click" (action (mut this.cloneButtonStatus) "confirming")}}
/>

Expand All @@ -109,9 +108,6 @@


{{else if (eq this.cloneButtonStatus 'confirming')}}
{{!-- <span data-test-confirmation-message class="confirmation-text is-right-aligned has-text-inline">
Are you sure you want to revert to this version?
</span> --}}
<Hds::Button
data-test-cancel-clone
@text="Cancel"
Expand Down

0 comments on commit 97d3f8c

Please sign in to comment.