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
No related branches found
No related tags found
No related merge requests found
...@@ -27,17 +27,17 @@ public class ElasticsearchReconciler implements Reconciler<OzgCloudElasticsearch ...@@ -27,17 +27,17 @@ public class ElasticsearchReconciler implements Reconciler<OzgCloudElasticsearch
public UpdateControl<OzgCloudElasticsearchCustomResource> reconcile(OzgCloudElasticsearchCustomResource resource, public UpdateControl<OzgCloudElasticsearchCustomResource> reconcile(OzgCloudElasticsearchCustomResource resource,
Context<OzgCloudElasticsearchCustomResource> context) { Context<OzgCloudElasticsearchCustomResource> context) {
try { try {
LOG.info("{}: Reconcile user", resource.getCRDName()); LOG.info("{}: Reconcile user", resource.getMetadata().getName());
var namespace = resource.getMetadata().getNamespace(); var namespace = resource.getMetadata().getNamespace();
var secret = service.getOrCreateCredentialSecret(resource, context); var secret = service.getOrCreateCredentialSecret(resource, context);
service.createIndexIfMissing(namespace); service.createIndexIfMissing(namespace);
service.createSecurityRoleIfMissing(namespace); service.createSecurityRoleIfMissing(namespace);
service.createSecurityUserIfMissing(namespace, getPassword(secret)); service.createSecurityUserIfMissing(namespace, getPassword(secret));
service.createCertificateIfMissing(namespace); 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(); return OzgCloudElasticsearchUpdateControlBuilder.fromResource(resource).withStatus(CustomResourceStatus.OK).build();
} catch (Exception exception) { } catch (Exception exception) {
LOG.warn(resource.getCRDName() + ": Reconcile user failed.", exception); LOG.warn(resource.getMetadata().getName() + ": Reconcile user failed.", exception);
return buildExceptionUpdateControl(resource, exception); return buildExceptionUpdateControl(resource, exception);
} }
} }
......
...@@ -23,9 +23,9 @@ public class ElasticsearchRemoteService { ...@@ -23,9 +23,9 @@ public class ElasticsearchRemoteService {
public boolean existsIndex(String index) throws Exception { public boolean existsIndex(String index) throws Exception {
try { 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(); var exists = client.indices().exists(builder -> builder.index(index)).value();
LOG.debug("Elasticsearch index exists: {}", exists); LOG.debug("{}: Elasticsearch index exists: {}", exists);
return exists; return exists;
} catch (ElasticsearchException | IOException e) { } catch (ElasticsearchException | IOException e) {
throw new RuntimeException("Error checking index '" + index, e); throw new RuntimeException("Error checking index '" + index, e);
...@@ -34,9 +34,9 @@ public class ElasticsearchRemoteService { ...@@ -34,9 +34,9 @@ public class ElasticsearchRemoteService {
public void createIndex(String indexName) throws Exception { public void createIndex(String indexName) throws Exception {
try { try {
LOG.info("Create elasticsearch index {}", indexName); LOG.info("{}: Create elasticsearch index", indexName);
client.indices().create(builder -> builder.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) { } catch (Exception e) {
throw new RuntimeException("Create elasticsearch index " + indexName + "failed.", e); throw new RuntimeException("Create elasticsearch index " + indexName + "failed.", e);
} }
...@@ -48,9 +48,9 @@ public class ElasticsearchRemoteService { ...@@ -48,9 +48,9 @@ public class ElasticsearchRemoteService {
public void createSecurityRole(PutRoleRequestData requestData) throws Exception { public void createSecurityRole(PutRoleRequestData requestData) throws Exception {
try { try {
LOG.info("Create elasticsearch role {}", requestData.getName()); LOG.info("{}: Create elasticsearch role ", requestData.getName());
client.security().putRole(createPutRoleRequest(requestData)); client.security().putRole(createPutRoleRequest(requestData));
LOG.info("Create elasticsearch role {} successful", requestData.getName()); LOG.info("{}: Create elasticsearch role successful", requestData.getName());
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Create elasticsearch role " + requestData.getName() + "failed.", e); throw new RuntimeException("Create elasticsearch role " + requestData.getName() + "failed.", e);
} }
...@@ -80,9 +80,9 @@ public class ElasticsearchRemoteService { ...@@ -80,9 +80,9 @@ public class ElasticsearchRemoteService {
public void createSecurityUser(PutUserRequestData requestData) throws Exception { public void createSecurityUser(PutUserRequestData requestData) throws Exception {
try { try {
LOG.info("Create elasticsearch user {}", requestData.getUsername()); LOG.info("{}: Create elasticsearch user", requestData.getUsername());
client.security().putUser(createPutUserRequest(requestData)); client.security().putUser(createPutUserRequest(requestData));
LOG.info("Create elasticsearch user {} successful", requestData.getUsername()); LOG.info("{}: Create elasticsearch user successful", requestData.getUsername());
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Create elasticsearch user " + requestData.getUsername() + "failed.", e); throw new RuntimeException("Create elasticsearch user " + requestData.getUsername() + "failed.", e);
} }
...@@ -102,9 +102,9 @@ public class ElasticsearchRemoteService { ...@@ -102,9 +102,9 @@ public class ElasticsearchRemoteService {
public void deleteIndex(String indexName) throws Exception { public void deleteIndex(String indexName) throws Exception {
try { try {
LOG.info("Delete elasticsearch index {}", indexName); LOG.info("{}: Delete elasticsearch index", indexName);
client.indices().delete(builder -> builder.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) { } catch (Exception e) {
throw new RuntimeException("Delete elasticsearch index " + indexName + "failed.", e); throw new RuntimeException("Delete elasticsearch index " + indexName + "failed.", e);
} }
...@@ -112,9 +112,9 @@ public class ElasticsearchRemoteService { ...@@ -112,9 +112,9 @@ public class ElasticsearchRemoteService {
public void deleteSecurityRole(String roleName) throws Exception { public void deleteSecurityRole(String roleName) throws Exception {
try { try {
LOG.info("Delete elasticsearch role {}", roleName); LOG.info("{}: Delete elasticsearch role", roleName);
client.security().deleteRole(builder -> builder.name(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) { } catch (Exception e) {
throw new RuntimeException("Delete elasticsearch role " + roleName + "failed.", e); throw new RuntimeException("Delete elasticsearch role " + roleName + "failed.", e);
} }
...@@ -122,9 +122,9 @@ public class ElasticsearchRemoteService { ...@@ -122,9 +122,9 @@ public class ElasticsearchRemoteService {
public void deleteSecurityUser(String userName) throws Exception { public void deleteSecurityUser(String userName) throws Exception {
try { try {
LOG.info("Delete elasticsearch user {}", userName); LOG.info("{}: Delete elasticsearch user", userName);
client.security().deleteUser(builder -> builder.username(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) { } catch (Exception e) {
throw new RuntimeException("Delete elasticsearch user " + userName + "failed.", 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