Fix Update Issue in MetadataService in case the ES config is updated (#11885)

This commit is contained in:
Mohit Yadav 2023-06-06 00:22:33 +05:30 committed by GitHub
parent d867a3ab40
commit 146a7b285c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -7,6 +7,8 @@ import org.openmetadata.service.Entity;
import org.openmetadata.service.resources.services.database.DatabaseServiceResource;
public class MetadataServiceRepository extends ServiceEntityRepository<MetadataService, MetadataConnection> {
private static final String UPDATE_FIELDS = "owner,tags,connection";
public MetadataServiceRepository(CollectionDAO dao) {
super(
DatabaseServiceResource.COLLECTION_PATH,
@ -14,6 +16,7 @@ public class MetadataServiceRepository extends ServiceEntityRepository<MetadataS
dao,
dao.metadataServiceDAO(),
MetadataConnection.class,
UPDATE_FIELDS,
ServiceType.METADATA);
}
}

View File

@ -1,5 +1,7 @@
package org.openmetadata.service.resources.services.metadata;
import static org.openmetadata.service.Entity.ADMIN_USER_NAME;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -98,8 +100,10 @@ public class MetadataServiceResource
if (servicesList.size() == 1) {
MetadataService service = servicesList.get(0);
service.setConnection(metadataConnection);
service.setUpdatedBy(ADMIN_USER_NAME);
service.setUpdatedAt(System.currentTimeMillis());
dao.setFullyQualifiedName(service);
dao.initializeEntity(service);
dao.createOrUpdate(null, service);
} else {
throw new IOException("Only one Openmetadata Service can be initialized from the Data.");
}