Skip to content

Commit 53e883d

Browse files
committed
[HWORKS-547][APPEND] allow AGENT user to trigger reindex (#1561)
1 parent f4cf4df commit 53e883d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

hopsworks-api/src/main/java/io/hops/hopsworks/api/admin/SystemAdminService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,15 @@ public Response getElasticAdminToken(@Context SecurityContext sc) throws OpenSea
232232
@GET
233233
@Path("/search/featurestore/status")
234234
@Produces(MediaType.APPLICATION_JSON)
235+
@JWTRequired(acceptedTokens={Audience.API}, allowedUserRoles={"HOPS_ADMIN", "AGENT"})
235236
public Response statusSearchFeatureStore(@Context SecurityContext sc, @Context HttpServletRequest req) {
236237
SearchFSCommandStatus status = searchFSReindexer.status();
237238
return Response.ok().entity(status).build();
238239
}
239240

240241
@POST
241242
@Path("/search/featurestore/reindex")
243+
@JWTRequired(acceptedTokens={Audience.API}, allowedUserRoles={"HOPS_ADMIN", "AGENT"})
242244
public Response reindexSearchFeatureStoreIndex(@Context SecurityContext sc, @Context HttpServletRequest req)
243245
throws OpenSearchException, FeaturestoreException, CommandException {
244246
searchFSReindexer.reindex();

hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSReindexer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ public void reindex() throws OpenSearchException, FeaturestoreException, Command
7474
throw new CommandException(RESTCodes.CommandErrorCode.INVALID_SQL_QUERY, Level.INFO, msg);
7575
}
7676
LOGGER.info("reindexing featurestore search");
77-
searchClient.mngIndexDelete(Settings.FEATURESTORE_INDEX);
77+
try {
78+
searchClient.mngIndexDelete(Settings.FEATURESTORE_INDEX);
79+
} catch(OpenSearchException e) {
80+
if(e.getErrorCode().equals(RESTCodes.OpenSearchErrorCode.OPENSEARCH_INDEX_NOT_FOUND)) {
81+
//index doesn't exist, nothing to delete
82+
return;
83+
}
84+
}
7885
for (Featurestore featureStore : featurestoreFacade.findAll()) {
7986
reindex(featureStore);
8087
}

0 commit comments

Comments
 (0)