aboutsummaryrefslogtreecommitdiffstats
path: root/lib/policy.js
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2018-02-21 15:51:56 -0500
committerAlex Shatov <alexs@att.com>2018-02-21 15:51:56 -0500
commit66215a25d592c76d9babfc480c80c74e561f5126 (patch)
treeff02141e352ea9472b8567969ac8789ec58712ff /lib/policy.js
parent8accefe3dfc0d07ff7a8609ef681bab44aa9e986 (diff)
bug fix - pass all policy versions to plugin
- on queuing of policy-update messages the deployment-handler erroneously calculated the delta versus current state instead of incremented stat. - This bug only manifests when queuing of more than one policy-update to the same deployment - relaxed mapping of policies to components on not to compare the policy versions and always map to the policy-filters - the fix lets the policy-update plugin to reduce the collection of multiple policies with the same policy_id in the message and do the final comparison against the presence of the policy and the version of the policy on component Change-Id: I5621439a60b59ac9683e7eccfa5481562d3a0d95 Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-356
Diffstat (limited to 'lib/policy.js')
-rw-r--r--lib/policy.js17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/policy.js b/lib/policy.js
index 0c635e5..4bc40fe 100644
--- a/lib/policy.js
+++ b/lib/policy.js
@@ -110,11 +110,10 @@ function policyUpdate(req, res, next) {
const latest_policy = policy_update.latest_policies[policy_id];
if (policy_update.removed_policies[policy_id]
|| (policy_update.catch_up
- && deployed_policy.policy_body
&& !latest_policy
- && !policy_update.errored_policies[policy_id])
+ && !policy_update.errored_policies[policy_id]
&& !is_policy_in_errored_scopes(policy_id)
- && is_policy_in_scopes(policy_id)) {
+ && is_policy_in_scopes(policy_id))) {
have_policies = true;
deployment.removed_policy_ids[policy_id] = true;
policy_update.removed_policy_ids[policy_id] = true;
@@ -123,11 +122,11 @@ function policyUpdate(req, res, next) {
}
if (!latest_policy || !latest_policy.policy_body
- || isNaN(latest_policy.policy_body.policyVersion)
- || latest_policy.policy_body.policyVersion
- === (deployed_policy.policy_body && deployed_policy.policy_body.policyVersion)) {
- return;
- }
+ || isNaN(latest_policy.policy_body.policyVersion)) {return;}
+ // || latest_policy.policy_body.policyVersion
+ // === (deployed_policy.policy_body && deployed_policy.policy_body.policyVersion)) {
+ // return;
+ // }
have_policies = true;
deployment.updated_policies[policy_id] = latest_policy;
policy_update.updated_policy_ids[policy_id] = true;
@@ -140,7 +139,7 @@ function policyUpdate(req, res, next) {
logger.debug(req.dcaeReqId, "matching latest policies to policy_filters[" + policy_filter_ids.length + "] on node_instance: " + JSON.stringify(node_instance));
try {
Object.keys(policy_update.latest_policies).forEach(policy_id => {
- if (deployment.updated_policies[policy_id] || deployed_policies[policy_id]) {return;}
+ // if (deployment.updated_policies[policy_id] || deployed_policies[policy_id]) {return;}
const latest_policy = policy_update.latest_policies[policy_id];
const policy_body = latest_policy && latest_policy.policy_body;