Commit 7a6e2bd0 authored by Dmitrii Novikov (EPAM)'s avatar Dmitrii Novikov (EPAM) Committed by Riabokon Stanislav(EPAM)[GCP]
Browse files

Added new version info endpoint (GONRG-2681)

parent 4a0ec199
This diff is collapsed.
......@@ -65,7 +65,4 @@ go-swagger brings to the go community a complete suite of fully-featured, high-p
where indexpattern is the index pattern regular expression which you want to delete
indexpattern is defined in web.xml (in indexer) file with an environment variable as CRON_INDEX_CLEANUP_PATTERN
The scheduling of cron is done in the following repository:
https://slb-swt.visualstudio.com/data-management/_git/deployment-init-scripts?path=%2F3_post_deploy%2F1_appengine_cron%2Fcron.yaml&version=GBmaster
#New Update2
https://slb-swt.visualstudio.com/data-management/_git/deployment-init-scripts?path=%2F3_post_deploy%2F1_appengine_cron%2Fcron.yaml&version=GBmaster
\ No newline at end of file
......@@ -13,6 +13,8 @@ tags:
- name: search
description: Service endpoints to search data in datalake
- name: Search
- name: info
description: Version info endpoint
schemes:
- https
consumes:
......@@ -203,6 +205,21 @@ paths:
security:
- Bearer: []
- google_id_token: []
/info:
get:
tags:
- info
summary: "Version info"
description: "For deployment available public `/info` endpoint, \
\ which provides build and git related information."
operationId: "Version info"
produces:
- "application/json"
responses:
200:
description: "Version info."
schema:
$ref: "#/definitions/VersionInfo"
definitions:
AppError:
type: object
......@@ -395,6 +412,46 @@ definitions:
latitude: 36.450727
longitude: 122.174762
returnedFields: [Location]
VersionInfo:
type: "object"
properties:
groupId:
type: "string"
description: "Maven artifact group ID."
actifactId:
type: "string"
description: "Maven artifact ID."
version:
type: "string"
description: "Maven artifact version"
buildTime:
type: "string"
description: "Maven artifact build time"
branch:
type: "string"
description: "Current git branch"
commitId:
type: "string"
description: "Latest commit hash"
commitMessage:
type: "string"
description: "Latest commit message"
connectedOuterServices:
type: "array"
description: "Connected outer services information"
items:
$ref: "#/definitions/ConnectedOuterService"
description: "Version info."
ConnectedOuterService:
type: "object"
properties:
name:
type: "string"
description: "Connected outer service name."
version:
type: "string"
description: "Connected outer service version."
description: "Connected outer service information."
# This section is the general responses shared by all apis
GeneralResponse:
properties:
......
......@@ -26,6 +26,7 @@
- [Query With Cursor](#query-with-cursor)
- [Get indexing status](#get-indexing-status)
- [Permissions](#permissions)
- [Version info endpoint](#version-info-endpoint)
## Introduction <a name="introduction"></a>
......@@ -998,3 +999,39 @@ The above query will return all records which had problems due to fields mismatc
| /api/search/v2/query_with_cursor | POST | users.osdu.viewers | Yes |
[Back to table of contents](#TOC)
## Version info endpoint
For deployment available public `/info` endpoint, which provides build and git related information.
#### Example response:
```json
{
"groupId": "org.opengroup.osdu",
"artifactId": "storage-gcp",
"version": "0.10.0-SNAPSHOT",
"buildTime": "2021-07-09T14:29:51.584Z",
"branch": "feature/GONRG-2681_Build_info",
"commitId": "7777",
"commitMessage": "Added copyright to version info properties file",
"connectedOuterServices": [
{
"name": "elasticSearch",
"version":"..."
},
{
"name": "postgresSql",
"version":"..."
},
{
"name": "redis",
"version":"..."
}
]
}
```
This endpoint takes information from files, generated by `spring-boot-maven-plugin`,
`git-commit-id-plugin` plugins. Need to specify paths for generated files to matching
properties:
- `version.info.buildPropertiesPath`
- `version.info.gitPropertiesPath`
[Back to table of contents](#TOC)
\ No newline at end of file
......@@ -44,7 +44,7 @@
<log4j-core.version>2.13.2</log4j-core.version>
<google-oauth-client.version>1.31.0</google-oauth-client.version>
<commons-compress.version>1.20</commons-compress.version>
<osdu.oscorecommon.version>0.10.0</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.11.0-SNAPSHOT</osdu.oscorecommon.version>
<tomcat-embed-core.version>9.0.45</tomcat-embed-core.version>
</properties>
......@@ -374,4 +374,44 @@
</profile>
</profiles>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.5</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>
${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -39,7 +39,7 @@
<aws.version>1.11.637</aws.version>
<deployment.environment>dev</deployment.environment>
<version.number>0.0.4-SNAPSHOT</version.number>
<osdu.oscorecommon.version>0.10.0</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.11.0-SNAPSHOT</osdu.oscorecommon.version>
</properties>
<dependencies>
......
......@@ -14,6 +14,7 @@
package org.opengroup.osdu.search.provider.aws.provider.impl;
import java.util.ArrayList;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService;
......@@ -45,6 +46,11 @@ public class CrossTenantInfoServiceAwsImpl implements ITenantInfoService, ICross
return tenantInfo;
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
@Override
public List<TenantInfo> getAllTenantsFromPartitionId() {
List<TenantInfo> tenantInfos = new LinkedList<>();
......
......@@ -73,4 +73,4 @@ service.policy.id=search
PARTITION_API=${ENTITLEMENTS_BASE_URL}/api/partition/v1
aws.environment=${ENVIRONMENT}
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
\ No newline at end of file
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
......@@ -37,7 +37,7 @@
<project.main.basedir>${project.parent.basedir}</project.main.basedir>
<springboot.version>2.1.7.RELEASE</springboot.version>
<osdu.corelibazure.version>0.10.1</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.10.0</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.11.0-SNAPSHOT</osdu.oscorecommon.version>
<osdu.search-core.version>0.11.0-SNAPSHOT</osdu.search-core.version>
<spatial4j.version>0.7</spatial4j.version>
<jts-io-common.version>1.15.0</jts-io-common.version>
......
......@@ -14,6 +14,7 @@ package org.opengroup.osdu.search.provider.azure.provider.impl;
// limitations under the License.
import java.util.ArrayList;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
......@@ -44,6 +45,11 @@ public class CrossTenantInfoServiceImpl implements ITenantInfoService, ICrossTen
return tenantInfo;
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
public String getPartitionId(){
return dpsHeaders.getPartitionId();
}
......
......@@ -30,12 +30,15 @@
</parent>
<properties>
<java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.war.plugin>2.6</maven.war.plugin>
<appengine.maven.plugin>1.0.0</appengine.maven.plugin>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.main.basedir>${project.parent.basedir}</project.main.basedir>
<osdu.oscorecommon.version>0.11.0-SNAPSHOT</osdu.oscorecommon.version>
</properties>
<dependencies>
......@@ -48,7 +51,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.10.0</version>
<version>${osdu.oscorecommon.version}</version>
</dependency>
<dependency>
......@@ -95,24 +98,26 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>
org.opengroup.osdu.search.provider.byoc.SearchApplication
</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>
org.opengroup.osdu.search.provider.byoc.SearchApplication
</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
\ No newline at end of file
......@@ -15,6 +15,7 @@
package org.opengroup.osdu.search.provider.byoc.provider.impl;
import java.util.ArrayList;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService;
......@@ -46,6 +47,11 @@ public class CrossTenantInfoServiceImpl implements ITenantInfoService, ICrossTen
return tenantInfo;
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
@Override
public List<TenantInfo> getAllTenantsFromPartitionId() {
List<TenantInfo> tenantInfos = new LinkedList<>();
......
......@@ -37,6 +37,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.main.basedir>${project.parent.basedir}</project.main.basedir>
<osdu.oscorecommon.version>0.11.0-SNAPSHOT</osdu.oscorecommon.version>
</properties>
<dependencies>
......@@ -54,7 +55,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.10.0</version>
<version>${osdu.oscorecommon.version}</version>
</dependency>
<dependency>
......
......@@ -14,9 +14,12 @@
package org.opengroup.osdu.search.provider.gcp.provider.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
import org.opengroup.osdu.core.common.model.http.AppException;
......@@ -46,6 +49,11 @@ public class CrossTenantInfoServiceImpl implements ITenantInfoService, ICrossTen
return tenantInfo;
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
@Override
public List<TenantInfo> getAllTenantsFromPartitionId() {
List<TenantInfo> tenantInfos = new LinkedList<>();
......@@ -58,5 +66,4 @@ public class CrossTenantInfoServiceImpl implements ITenantInfoService, ICrossTen
}
return tenantInfos;
}
}
......@@ -14,21 +14,22 @@
package org.opengroup.osdu.search.provider.gcp.service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.inject.Inject;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.model.search.ClusterSettings;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.provider.interfaces.IElasticRepository;
import org.opengroup.osdu.core.common.model.indexer.IElasticSettingService;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.indexer.IElasticSettingService;
import org.opengroup.osdu.core.common.model.search.ClusterSettings;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.multitenancy.ITenantInfoService;
import org.opengroup.osdu.core.common.provider.interfaces.IElasticRepository;
import org.opengroup.osdu.search.config.SearchConfigurationProperties;
import org.opengroup.osdu.search.provider.gcp.cache.ElasticCredentialsCache;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
@Service
public class ElasticSettingServiceImpl implements IElasticSettingService {
......@@ -49,10 +50,22 @@ public class ElasticSettingServiceImpl implements IElasticSettingService {
@Override
public ClusterSettings getElasticClusterInformation() {
TenantInfo tenantInfo = this.tenantInfoServiceProvider.get().getTenantInfo();
return getClusterSettingsByTenantInfo(tenantInfo);
}
@Override
public Map<String, ClusterSettings> getAllClustersSettings() {
List<TenantInfo> tenantInfos = tenantInfoServiceProvider.get().getAllTenantInfos();
return tenantInfos.stream()
.collect(Collectors.toMap(TenantInfo::getDataPartitionId,
this::getClusterSettingsByTenantInfo));
}
private ClusterSettings getClusterSettingsByTenantInfo(TenantInfo tenantInfo) {
String cacheKey = String.format("%s-%s", searchConfigurationProperties.getDeployedServiceId(),
tenantInfo.getName());
String cacheKey = String.format("%s-%s", searchConfigurationProperties.getDeployedServiceId(), tenantInfo.getName());
ClusterSettings clusterInfo = this.elasticCredentialCache.get(cacheKey);
if (clusterInfo != null) {
return clusterInfo;
......@@ -61,7 +74,8 @@ public class ElasticSettingServiceImpl implements IElasticSettingService {
clusterInfo = this.elasticRepository.getElasticClusterSettings(tenantInfo);
if (clusterInfo == null) {
throw new AppException(HttpStatus.SC_NOT_FOUND, "Tenant not found", "No information about the given tenant was found");
throw new AppException(HttpStatus.SC_NOT_FOUND,
"Tenant not found", "No information about the given tenant was found");
}
this.elasticCredentialCache.put(cacheKey, clusterInfo);
......
......@@ -25,7 +25,7 @@
<properties>
<os-core-lib-ibm.version>0.10.0</os-core-lib-ibm.version>
<start-class>org.opengroup.osdu.search.provider.ibm.app.SearchIBMApplication</start-class>
<osdu.oscorecommon.version>0.10.0</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.11.0-SNAPSHOT</osdu.oscorecommon.version>
</properties>
......
......@@ -5,6 +5,7 @@
package org.opengroup.osdu.search.provider.ibm.provider.impl;
import java.util.ArrayList;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
......@@ -41,6 +42,11 @@ public class CrossTenantInfoServiceImpl implements ITenantInfoService, ICrossTen
return tenantInfo;
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
@Override
public List<TenantInfo> getAllTenantsFromPartitionId() {
List<TenantInfo> tenantInfos = new LinkedList<>();
......
......@@ -22,6 +22,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.main.basedir>${project.parent.basedir}</project.main.basedir>
<osdu.oscorecommon.version>0.11.0-SNAPSHOT</osdu.oscorecommon.version>
</properties>
<dependencies>
......@@ -33,7 +34,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.10.0</version>
<version>${osdu.oscorecommon.version}</version>
</dependency>
<dependency>
......
......@@ -17,6 +17,7 @@
package org.opengroup.osdu.search.provider.reference.provider.impl;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.inject.Inject;
......@@ -47,6 +48,11 @@ public class CrossTenantInfoServiceImpl implements ITenantInfoService, ICrossTen
return tenantInfo;
}
@Override
public List<TenantInfo> getAllTenantInfos() {
return new ArrayList<>(tenantFactory.listTenantInfo());
}
@Override
public List<TenantInfo> getAllTenantsFromPartitionId() {
List<TenantInfo> tenantInfos = new LinkedList<>();
......
......@@ -38,9 +38,15 @@
<project.main.basedir>${project.basedir}</project.main.basedir>
<nimbus-jose-jwt.version>9.1.2</nimbus-jose-jwt.version>
<elasticsearch.version>7.8.1</elasticsearch.version>
<osdu.oscorecommon.version>0.11.0-SNAPSHOT</osdu.oscorecommon.version>
</properties>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>${osdu.oscorecommon.version}</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment