diff --git a/hopsworks-api/src/main/java/io/hops/hopsworks/api/admin/SystemAdminService.java b/hopsworks-api/src/main/java/io/hops/hopsworks/api/admin/SystemAdminService.java index e383f3daa7..bc1504e671 100644 --- a/hopsworks-api/src/main/java/io/hops/hopsworks/api/admin/SystemAdminService.java +++ b/hopsworks-api/src/main/java/io/hops/hopsworks/api/admin/SystemAdminService.java @@ -232,6 +232,7 @@ 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(); @@ -239,6 +240,7 @@ public Response statusSearchFeatureStore(@Context SecurityContext sc, @Context H @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(); diff --git a/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSReindexer.java b/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSReindexer.java index 75a7b7ebd7..fd61fe4cf9 100644 --- a/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSReindexer.java +++ b/hopsworks-common/src/main/java/io/hops/hopsworks/common/commands/featurestore/search/SearchFSReindexer.java @@ -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); }