Skip to content

Commit

Permalink
[HWORKS-547][APPEND] allow AGENT user to trigger reindex (#1561)
Browse files Browse the repository at this point in the history
  • Loading branch information
o-alex committed Oct 2, 2023
1 parent f4cf4df commit 53e883d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,15 @@ public Response getElasticAdminToken(@Context SecurityContext sc) throws OpenSea
@GET
@Path("/search/featurestore/status")
@Produces(MediaType.APPLICATION_JSON)
@JWTRequired(acceptedTokens={Audience.API}, allowedUserRoles={"HOPS_ADMIN", "AGENT"})
public Response statusSearchFeatureStore(@Context SecurityContext sc, @Context HttpServletRequest req) {
SearchFSCommandStatus status = searchFSReindexer.status();
return Response.ok().entity(status).build();
}

@POST
@Path("/search/featurestore/reindex")
@JWTRequired(acceptedTokens={Audience.API}, allowedUserRoles={"HOPS_ADMIN", "AGENT"})
public Response reindexSearchFeatureStoreIndex(@Context SecurityContext sc, @Context HttpServletRequest req)
throws OpenSearchException, FeaturestoreException, CommandException {
searchFSReindexer.reindex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ public void reindex() throws OpenSearchException, FeaturestoreException, Command
throw new CommandException(RESTCodes.CommandErrorCode.INVALID_SQL_QUERY, Level.INFO, msg);
}
LOGGER.info("reindexing featurestore search");
searchClient.mngIndexDelete(Settings.FEATURESTORE_INDEX);
try {
searchClient.mngIndexDelete(Settings.FEATURESTORE_INDEX);
} catch(OpenSearchException e) {
if(e.getErrorCode().equals(RESTCodes.OpenSearchErrorCode.OPENSEARCH_INDEX_NOT_FOUND)) {
//index doesn't exist, nothing to delete
return;
}
}
for (Featurestore featureStore : featurestoreFacade.findAll()) {
reindex(featureStore);
}
Expand Down

0 comments on commit 53e883d

Please sign in to comment.