mirror of
https://github.com/ansible/awx.git
synced 2026-04-10 12:39:22 -02:30
fix race condition with status socket
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', '$rootScope', 'moment', '$stateParams', 'i18n', 'fieldChoices', 'fieldLabels', 'workflowResultsService',
|
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', '$rootScope', 'moment', '$stateParams', 'i18n', 'fieldChoices', 'fieldLabels', 'workflowResultsService', 'statusSocket',
|
||||||
function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet, $rootScope, moment, $stateParams, i18n, fieldChoices, fieldLabels, workflowResultsService) {
|
function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet, $rootScope, moment, $stateParams, i18n, fieldChoices, fieldLabels, workflowResultsService, statusSocket) {
|
||||||
var toDestroy = [];
|
var toDestroy = [];
|
||||||
var cancelRequests = false;
|
var cancelRequests = false;
|
||||||
var runTimeElapsedTimer = null;
|
var runTimeElapsedTimer = null;
|
||||||
@@ -664,6 +664,14 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// get previously set up socket messages from resolve
|
||||||
|
if (statusSocket[0].job_status) {
|
||||||
|
$scope.job_status = statusSocket[0].job_status;
|
||||||
|
}
|
||||||
|
if ($scope.job_status === "running") {
|
||||||
|
runTimeElapsedTimer = workflowResultsService.createOneSecondTimer(moment(), updateJobElapsedTimer);
|
||||||
|
}
|
||||||
|
|
||||||
// Processing of job-status messages from the websocket
|
// Processing of job-status messages from the websocket
|
||||||
toDestroy.push($scope.$on(`ws-jobs`, function(e, data) {
|
toDestroy.push($scope.$on(`ws-jobs`, function(e, data) {
|
||||||
if (parseInt(data.unified_job_id, 10) ===
|
if (parseInt(data.unified_job_id, 10) ===
|
||||||
@@ -671,7 +679,9 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
|||||||
// controller is defined, so set the job_status
|
// controller is defined, so set the job_status
|
||||||
$scope.job_status = data.status;
|
$scope.job_status = data.status;
|
||||||
if (data.status === "running") {
|
if (data.status === "running") {
|
||||||
runTimeElapsedTimer = workflowResultsService.createOneSecondTimer(moment(), updateJobElapsedTimer);
|
if (!runTimeElapsedTimer) {
|
||||||
|
runTimeElapsedTimer = workflowResultsService.createOneSecondTimer(moment(), updateJobElapsedTimer);
|
||||||
|
}
|
||||||
} else if (data.status === "successful" ||
|
} else if (data.status === "successful" ||
|
||||||
data.status === "failed" ||
|
data.status === "failed" ||
|
||||||
data.status === "error" ||
|
data.status === "error" ||
|
||||||
@@ -699,7 +709,12 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
statusSocket[1]();
|
||||||
|
|
||||||
$scope.$on('$destroy', function(){
|
$scope.$on('$destroy', function(){
|
||||||
|
if (statusSocket[1]) {
|
||||||
|
statusSocket[1]();
|
||||||
|
}
|
||||||
$( ".JobResultsStdOut-aLineOfStdOut" ).remove();
|
$( ".JobResultsStdOut-aLineOfStdOut" ).remove();
|
||||||
cancelRequests = true;
|
cancelRequests = true;
|
||||||
eventQueue.initialize();
|
eventQueue.initialize();
|
||||||
|
|||||||
@@ -36,6 +36,16 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
|
statusSocket: ['$rootScope', '$stateParams', function($rootScope, $stateParams) {
|
||||||
|
var preScope = {};
|
||||||
|
var eventOn = $rootScope.$on(`ws-jobs`, function(e, data) {
|
||||||
|
if (parseInt(data.unified_job_id, 10) ===
|
||||||
|
parseInt($stateParams.id,10)) {
|
||||||
|
preScope.job_status = data.status;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return [preScope, eventOn];
|
||||||
|
}],
|
||||||
// the GET for the particular job
|
// the GET for the particular job
|
||||||
jobData: ['Rest', 'GetBasePath', '$stateParams', '$q', '$state', 'Alert', 'jobResultsService', function(Rest, GetBasePath, $stateParams, $q, $state, Alert, jobResultsService) {
|
jobData: ['Rest', 'GetBasePath', '$stateParams', '$q', '$state', 'Alert', 'jobResultsService', function(Rest, GetBasePath, $stateParams, $q, $state, Alert, jobResultsService) {
|
||||||
return jobResultsService.getJobData($stateParams.id);
|
return jobResultsService.getJobData($stateParams.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user