Skip to content
Snippets Groups Projects
Commit f5597eec authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'OZG-4453-SearchIndexOperator' of...

Merge branch 'OZG-4453-SearchIndexOperator' of git.ozg-sh.de:ozgcloud-devops/operator into OZG-4453-SearchIndexOperator
parents 97433c6a be213525
Branches
Tags
No related merge requests found
......@@ -27,17 +27,17 @@ public class ElasticsearchReconciler implements Reconciler<OzgCloudElasticsearch
public UpdateControl<OzgCloudElasticsearchCustomResource> reconcile(OzgCloudElasticsearchCustomResource resource,
Context<OzgCloudElasticsearchCustomResource> context) {
try {
LOG.info("{}: Reconcile user", resource.getCRDName());
LOG.info("{}: Reconcile user", resource.getMetadata().getName());
var namespace = resource.getMetadata().getNamespace();
var secret = service.getOrCreateCredentialSecret(resource, context);
service.createIndexIfMissing(namespace);
service.createSecurityRoleIfMissing(namespace);
service.createSecurityUserIfMissing(namespace, getPassword(secret));
service.createCertificateIfMissing(namespace);
LOG.info("{}: Reconcile user successful.", resource.getCRDName());
LOG.info("{}: Reconcile user successful.", resource.getMetadata().getName());
return OzgCloudElasticsearchUpdateControlBuilder.fromResource(resource).withStatus(CustomResourceStatus.OK).build();
} catch (Exception exception) {
LOG.warn(resource.getCRDName() + ": Reconcile user failed.", exception);
LOG.warn(resource.getMetadata().getName() + ": Reconcile user failed.", exception);
return buildExceptionUpdateControl(resource, exception);
}
}
......
......@@ -23,9 +23,9 @@ public class ElasticsearchRemoteService {
public boolean existsIndex(String index) throws Exception {
try {
LOG.debug("Test if elasticsearch index {} exits.", index);
LOG.debug("{}: Test if elasticsearch index exits.", index);
var exists = client.indices().exists(builder -> builder.index(index)).value();
LOG.debug("Elasticsearch index exists: {}", exists);
LOG.debug("{}: Elasticsearch index exists: {}", exists);
return exists;
} catch (ElasticsearchException | IOException e) {
throw new RuntimeException("Error checking index '" + index, e);
......@@ -34,9 +34,9 @@ public class ElasticsearchRemoteService {
public void createIndex(String indexName) throws Exception {
try {
LOG.info("Create elasticsearch index {}", indexName);
LOG.info("{}: Create elasticsearch index", indexName);
client.indices().create(builder -> builder.index(indexName));
LOG.info("Create elasticsearch index {} successful", indexName);
LOG.info("{}: Create elasticsearch index successful", indexName);
} catch (Exception e) {
throw new RuntimeException("Create elasticsearch index " + indexName + "failed.", e);
}
......@@ -48,9 +48,9 @@ public class ElasticsearchRemoteService {
public void createSecurityRole(PutRoleRequestData requestData) throws Exception {
try {
LOG.info("Create elasticsearch role {}", requestData.getName());
LOG.info("{}: Create elasticsearch role ", requestData.getName());
client.security().putRole(createPutRoleRequest(requestData));
LOG.info("Create elasticsearch role {} successful", requestData.getName());
LOG.info("{}: Create elasticsearch role successful", requestData.getName());
} catch (Exception e) {
throw new RuntimeException("Create elasticsearch role " + requestData.getName() + "failed.", e);
}
......@@ -80,9 +80,9 @@ public class ElasticsearchRemoteService {
public void createSecurityUser(PutUserRequestData requestData) throws Exception {
try {
LOG.info("Create elasticsearch user {}", requestData.getUsername());
LOG.info("{}: Create elasticsearch user", requestData.getUsername());
client.security().putUser(createPutUserRequest(requestData));
LOG.info("Create elasticsearch user {} successful", requestData.getUsername());
LOG.info("{}: Create elasticsearch user successful", requestData.getUsername());
} catch (Exception e) {
throw new RuntimeException("Create elasticsearch user " + requestData.getUsername() + "failed.", e);
}
......@@ -102,9 +102,9 @@ public class ElasticsearchRemoteService {
public void deleteIndex(String indexName) throws Exception {
try {
LOG.info("Delete elasticsearch index {}", indexName);
LOG.info("{}: Delete elasticsearch index", indexName);
client.indices().delete(builder -> builder.index(indexName));
LOG.info("Delete elasticsearch index {} successful", indexName);
LOG.info("{}: Delete elasticsearch index successful", indexName);
} catch (Exception e) {
throw new RuntimeException("Delete elasticsearch index " + indexName + "failed.", e);
}
......@@ -112,9 +112,9 @@ public class ElasticsearchRemoteService {
public void deleteSecurityRole(String roleName) throws Exception {
try {
LOG.info("Delete elasticsearch role {}", roleName);
LOG.info("{}: Delete elasticsearch role", roleName);
client.security().deleteRole(builder -> builder.name(roleName));
LOG.info("Delete elasticsearch role {} successful", roleName);
LOG.info("{}: Delete elasticsearch role successful", roleName);
} catch (Exception e) {
throw new RuntimeException("Delete elasticsearch role " + roleName + "failed.", e);
}
......@@ -122,9 +122,9 @@ public class ElasticsearchRemoteService {
public void deleteSecurityUser(String userName) throws Exception {
try {
LOG.info("Delete elasticsearch user {}", userName);
LOG.info("{}: Delete elasticsearch user", userName);
client.security().deleteUser(builder -> builder.username(userName));
LOG.info("Delete elasticsearch user {} successful", userName);
LOG.info("{}: Delete elasticsearch user successful", userName);
} catch (Exception e) {
throw new RuntimeException("Delete elasticsearch user " + userName + "failed.", e);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment