From e415fe42c971e663cdf21c9288d66248df52ddef Mon Sep 17 00:00:00 2001 From: Andrii Kalinich Date: Mon, 13 Apr 2020 20:36:55 -0400 Subject: [PATCH 1/3] Fix missing request type in OnSystemRequest There was found a few issues while working with HMI in ExternalPolicies = true mode: 1. HMI is sending OnSystemRequest twice 2. First OnSystremRequest notification does not contain requestType parameter To fix that, HMI logic was updated to launch retry sequence only after the response received by pack client. By some reason, retry sequence was additionally been started right after GetPolicyConfigurationData response. This extra call has been removed to make HMI send notification just once. Also, retry sequence function was updated to use request params received by pack client (if available). --- app/controller/SettingsController.js | 21 +++++++++++++++------ ffw/BasicCommunicationRPC.js | 5 +---- ffw/ExternalPolicies.js | 8 +------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controller/SettingsController.js b/app/controller/SettingsController.js index 11cccff69..6becc7cb3 100644 --- a/app/controller/SettingsController.js +++ b/app/controller/SettingsController.js @@ -332,9 +332,10 @@ SDL.SettingsController = Em.Object.create( * Method responsible for PolicyUpdate retry sequence * abort parameter if set to true means that retry sequence if finished * - * @param {Boolean} abort + * @param {String} action + * @param {Object} request_params */ - policyUpdateRetry: function(abort) { + policyUpdateRetry: function(action, request_params) { if(SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress) { return; } @@ -343,10 +344,18 @@ SDL.SettingsController = Em.Object.create( var sendOnSystemRequest = function() { SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = false; + const default_params = { + requestType: 'PROPRIETARY', + fileName: SDL.SettingsController.policyUpdateFile, + url: SDL.SDLModel.data.policyURLs[0] + }; + const params_to_send = request_params ? request_params : default_params; + FFW.BasicCommunication.OnSystemRequest( - 'PROPRIETARY', - SDL.SettingsController.policyUpdateFile, - SDL.SDLModel.data.policyURLs[0] + params_to_send.requestType, + params_to_send.fileName, + params_to_send.url, + params_to_send.appID ); } if(!SDL.SDLModel.data.policyUpdateRetry.isRetry) { @@ -363,7 +372,7 @@ SDL.SettingsController = Em.Object.create( if(length == SDL.SDLModel.data.policyUpdateRetry.try) { SDL.SDLModel.data.policyUpdateRetry.isRetry = false; } - if (abort !== 'ABORT' && SDL.SDLModel.data.policyUpdateRetry.isRetry) { + if (action !== 'ABORT' && SDL.SDLModel.data.policyUpdateRetry.isRetry) { SDL.SDLModel.data.policyUpdateRetry.oldTimer = SDL.SDLModel.data.policyUpdateRetry.retry[SDL.SDLModel.data.policyUpdateRetry.try] * 1000; diff --git a/ffw/BasicCommunicationRPC.js b/ffw/BasicCommunicationRPC.js index 6fc4ea84c..71e00c431 100644 --- a/ffw/BasicCommunicationRPC.js +++ b/ffw/BasicCommunicationRPC.js @@ -287,9 +287,6 @@ FFW.BasicCommunication = FFW.RPCObserver } else { SDL.SettingsController.requestPTUFromEndpoint(SDL.SettingsController.policyUpdateFile, data[key].default); } - if (FLAGS.ExternalPolicies === true) { - SDL.SettingsController.policyUpdateRetry(); - } } } } @@ -463,7 +460,7 @@ FFW.BasicCommunication = FFW.RPCObserver messageCode = 'StatusNeeded'; if (FLAGS.ExternalPolicies === true && SDL.SDLModel.data.policyUpdateRetry.isRetry) { - SDL.SettingsController.policyUpdateRetry(); + SDL.SettingsController.policyUpdateRetry('RETRY'); } break; } diff --git a/ffw/ExternalPolicies.js b/ffw/ExternalPolicies.js index 79897a48b..2fcf8e7c5 100644 --- a/ffw/ExternalPolicies.js +++ b/ffw/ExternalPolicies.js @@ -90,15 +90,9 @@ FFW.ExternalPolicies = Em.Object.create({ onPackMessage: function(evt) { Em.Logger.log('ExternalPolicies onWSMessage ' + evt.data); this.packResponseReady = true; - FFW.BasicCommunication.OnSystemRequest( - this.sysReqParams.type, - this.sysReqParams.fileName, - this.sysReqParams.url, - this.sysReqParams.appID - ); + SDL.SettingsController.policyUpdateRetry('RETRY', this.sysReqParams); this.sysReqParams = {}; - }, onUnpackMessage: function(evt) { Em.Logger.log('ExternalPolicies onWSMessage ' + evt.data); From 9567fea1b63184985283456c4a26ec6c17b515d4 Mon Sep 17 00:00:00 2001 From: Andrii Kalinich Date: Tue, 21 Apr 2020 18:25:46 -0400 Subject: [PATCH 2/3] fixup! Fix missing request type in OnSystemRequest --- app/controller/SettingsController.js | 68 ++++++++++++++++------------ ffw/BasicCommunicationRPC.js | 4 +- ffw/ExternalPolicies.js | 2 +- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/app/controller/SettingsController.js b/app/controller/SettingsController.js index 6becc7cb3..8750af031 100644 --- a/app/controller/SettingsController.js +++ b/app/controller/SettingsController.js @@ -332,13 +332,14 @@ SDL.SettingsController = Em.Object.create( * Method responsible for PolicyUpdate retry sequence * abort parameter if set to true means that retry sequence if finished * - * @param {String} action * @param {Object} request_params */ - policyUpdateRetry: function(action, request_params) { - if(SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress) { + policyUpdateRetry: function(request_params) { + if (SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress) { + Em.Logger.log('PTU retry: iteration is in progress'); return; } + clearTimeout(SDL.SDLModel.data.policyUpdateRetry.timer); SDL.SDLModel.data.policyUpdateRetry.timer = null; @@ -358,7 +359,9 @@ SDL.SettingsController = Em.Object.create( params_to_send.appID ); } - if(!SDL.SDLModel.data.policyUpdateRetry.isRetry) { + + if (!SDL.SDLModel.data.policyUpdateRetry.isRetry) { + Em.Logger.log('PTU retry: starting retry sequence'); SDL.SDLModel.data.policyUpdateRetry.isRetry = true; SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = true; SDL.SDLModel.data.policyUpdateRetry.timer = setTimeout( @@ -368,33 +371,42 @@ SDL.SettingsController = Em.Object.create( ); return; } + var length = SDL.SDLModel.data.policyUpdateRetry.retry.length; - if(length == SDL.SDLModel.data.policyUpdateRetry.try) { - SDL.SDLModel.data.policyUpdateRetry.isRetry = false; - } - if (action !== 'ABORT' && SDL.SDLModel.data.policyUpdateRetry.isRetry) { - - SDL.SDLModel.data.policyUpdateRetry.oldTimer = - SDL.SDLModel.data.policyUpdateRetry.retry[SDL.SDLModel.data.policyUpdateRetry.try] * 1000; - - SDL.SDLModel.data.policyUpdateRetry.timer = setTimeout( - function() { - sendOnSystemRequest(); - }, SDL.SDLModel.data.policyUpdateRetry.oldTimer - ); - SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = true; - SDL.SDLModel.data.policyUpdateRetry.try++; - } else { + if (length == SDL.SDLModel.data.policyUpdateRetry.try) { + Em.Logger.log('PTU retry: retry attempts are over'); SDL.SDLModel.data.policyUpdateRetry.isRetry = false; - clearTimeout(SDL.SDLModel.data.policyUpdateRetry.timer); - SDL.SDLModel.data.policyUpdateRetry = { - timeout: null, - retry: [], - try: null, - timer: null, - oldTimer: 0 - }; + return; } + + SDL.SDLModel.data.policyUpdateRetry.oldTimer = + SDL.SDLModel.data.policyUpdateRetry.retry[SDL.SDLModel.data.policyUpdateRetry.try] * 1000; + + SDL.SDLModel.data.policyUpdateRetry.timer = setTimeout( + function() { + sendOnSystemRequest(); + }, SDL.SDLModel.data.policyUpdateRetry.oldTimer + ); + + SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = true; + SDL.SDLModel.data.policyUpdateRetry.try++; + Em.Logger.log(`PTU retry: retry attempt #${SDL.SDLModel.data.policyUpdateRetry.try}`); + }, + + /** + * @description Aborts policy table update retry sequence + */ + policyUpdateAbort: function() { + Em.Logger.log('PTU retry: retry sequence was aborted'); + SDL.SDLModel.data.policyUpdateRetry.isRetry = false; + clearTimeout(SDL.SDLModel.data.policyUpdateRetry.timer); + SDL.SDLModel.data.policyUpdateRetry = { + timeout: null, + retry: [], + try: null, + timer: null, + oldTimer: 0 + }; }, /** diff --git a/ffw/BasicCommunicationRPC.js b/ffw/BasicCommunicationRPC.js index 71e00c431..f9b0bbce9 100644 --- a/ffw/BasicCommunicationRPC.js +++ b/ffw/BasicCommunicationRPC.js @@ -440,7 +440,7 @@ FFW.BasicCommunication = FFW.RPCObserver messageCode = 'StatusUpToDate'; //Update is complete, stop retry sequence if (FLAGS.ExternalPolicies === true) { - SDL.SettingsController.policyUpdateRetry('ABORT'); + SDL.SettingsController.policyUpdateAbort(); } SDL.SettingsController.policyUpdateFile = null; this.GetPolicyConfigurationData({ @@ -460,7 +460,7 @@ FFW.BasicCommunication = FFW.RPCObserver messageCode = 'StatusNeeded'; if (FLAGS.ExternalPolicies === true && SDL.SDLModel.data.policyUpdateRetry.isRetry) { - SDL.SettingsController.policyUpdateRetry('RETRY'); + SDL.SettingsController.policyUpdateRetry(null); } break; } diff --git a/ffw/ExternalPolicies.js b/ffw/ExternalPolicies.js index 2fcf8e7c5..ece7cdbb5 100644 --- a/ffw/ExternalPolicies.js +++ b/ffw/ExternalPolicies.js @@ -90,7 +90,7 @@ FFW.ExternalPolicies = Em.Object.create({ onPackMessage: function(evt) { Em.Logger.log('ExternalPolicies onWSMessage ' + evt.data); this.packResponseReady = true; - SDL.SettingsController.policyUpdateRetry('RETRY', this.sysReqParams); + SDL.SettingsController.policyUpdateRetry(this.sysReqParams); this.sysReqParams = {}; }, From 19f83d0aa5641af329cd4153b7e34a76a3288e4f Mon Sep 17 00:00:00 2001 From: Andrii Kalinich Date: Thu, 23 Apr 2020 19:17:14 -0400 Subject: [PATCH 3/3] fixup! Fix missing request type in OnSystemRequest --- app/controller/SettingsController.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controller/SettingsController.js b/app/controller/SettingsController.js index 8750af031..38de16eaf 100644 --- a/app/controller/SettingsController.js +++ b/app/controller/SettingsController.js @@ -374,8 +374,14 @@ SDL.SettingsController = Em.Object.create( var length = SDL.SDLModel.data.policyUpdateRetry.retry.length; if (length == SDL.SDLModel.data.policyUpdateRetry.try) { - Em.Logger.log('PTU retry: retry attempts are over'); + Em.Logger.log('PTU retry: retry attempts exceeded. Sending the last system request'); SDL.SDLModel.data.policyUpdateRetry.isRetry = false; + SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = true; + SDL.SDLModel.data.policyUpdateRetry.timer = setTimeout( + function() { + sendOnSystemRequest(); + }, 1000 + ); return; }