Skip to content

Commit

Permalink
fix(policies): change order of operations for policies bootstrap step…
Browse files Browse the repository at this point in the history
… to update index after database (datahub-project#4841)
  • Loading branch information
RyanHolstien authored and maggiehays committed Aug 1, 2022
1 parent 4b5c473 commit 4af099a
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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.");
}

Expand Down

0 comments on commit 4af099a

Please sign in to comment.