From e5a9a52ee46b6a2a0e6b508c86b1d646586d342d Mon Sep 17 00:00:00 2001 From: RyanHolstien Date: Thu, 5 May 2022 18:35:35 -0500 Subject: [PATCH] fix(policies): change order of operations for policies bootstrap step to update index after database (#4841) --- .../metadata/boot/steps/IngestPoliciesStep.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/metadata-service/factories/src/main/java/com/linkedin/metadata/boot/steps/IngestPoliciesStep.java b/metadata-service/factories/src/main/java/com/linkedin/metadata/boot/steps/IngestPoliciesStep.java index a4f5c95f503930..f04453318987e3 100644 --- a/metadata-service/factories/src/main/java/com/linkedin/metadata/boot/steps/IngestPoliciesStep.java +++ b/metadata-service/factories/src/main/java/com/linkedin/metadata/boot/steps/IngestPoliciesStep.java @@ -67,11 +67,6 @@ public void execute() throws IOException, URISyntaxException { String.format("Found malformed policies file, expected an Array but found %s", policiesObj.getNodeType())); } - // If search index for policies is empty, send MCLs for all policies to ingest policies into the search index - if (_entitySearchService.docCount(Constants.POLICY_ENTITY_NAME) == 0) { - updatePolicyIndex(); - } - // 2. For each JSON object, cast into a DataHub Policy Info object. for (final JsonNode policyObj : policiesObj) { final Urn urn = Urn.createFromString(policyObj.get("urn").asText()); @@ -99,6 +94,11 @@ public void execute() throws IOException, URISyntaxException { } } } + // If search index for policies is empty, update the policy index with the ingested policies from previous step. + // Directly update the ES index, does not produce MCLs + if (_entitySearchService.docCount(Constants.POLICY_ENTITY_NAME) == 0) { + updatePolicyIndex(); + } log.info("Successfully ingested default access policies."); }