Skip to content

Commit

Permalink
[MOSIP-32507] Fixed application service run, Datasync run, Batchjob r…
Browse files Browse the repository at this point in the history
…un failures

Signed-off-by: Aiham <[email protected]>
  • Loading branch information
aihamh committed Jun 14, 2024
1 parent 8df7a7d commit 47b79d5
Show file tree
Hide file tree
Showing 20 changed files with 251 additions and 187 deletions.
16 changes: 3 additions & 13 deletions apitest/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:21-jre-alpine
FROM mosipdev/openjdk-21-jre:latest

ARG SOURCE
ARG COMMIT_HASH
Expand All @@ -16,23 +16,13 @@ ARG container_user=mosip
ARG container_user_group=mosip

# can be passed during Docker build as build time environment for github branch to pickup configuration from.
ARG container_user_uid=1002
ARG container_user_uid=1001

# can be passed during Docker build as build time environment for github branch to pickup configuration from.
ARG container_user_gid=1001

ARG KUBECTL_VERSION=1.22.9


# install packages and create user
RUN apk -q update \
&& apk add -q unzip jq \
&& addgroup -g ${container_user_gid} ${container_user_group} \
&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \
&& curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \
&& chmod +x kubectl \
&& mv kubectl /usr/local/bin/

# set working directory for the user
WORKDIR /home/${container_user}

Expand Down Expand Up @@ -64,4 +54,4 @@ ENV ENV_USER=
ENV ENV_ENDPOINT=
ENV ENV_TESTLEVEL=smokeAndRegression

ENTRYPOINT ["./entrypoint.sh"]
ENTRYPOINT ["./entrypoint.sh"]
1 change: 0 additions & 1 deletion pre-registration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
<modelmapper.version>0.7.4</modelmapper.version>
<java.interceptor.version>1.2</java.interceptor.version>
<icu.version>63.1</icu.version>
<io.micrometer.prometheus.version>1.4.2</io.micrometer.prometheus.version>

<sonar.coverage.exclusions>
**/code/**,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package io.mosip.preregistration.application.config;

import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -12,17 +12,29 @@

@Configuration
public class LoginConfig {
private OpenApiProperties openApiProperties;

@Autowired
public LoginConfig(OpenApiProperties openApiProperties) {
this.openApiProperties = openApiProperties;
}

@Bean
public OpenAPI openApi(@Autowired OpenApiProperties openApiProperties) {
public OpenAPI openApi() {
OpenAPI api = new OpenAPI().components(new Components())
.info(new Info().title(openApiProperties.getInfo().getTitle())
.version(openApiProperties.getInfo().getVersion())
.description(openApiProperties.getInfo().getDescription())
.license(new License().name(openApiProperties.getInfo().getLicense().getName())
.url(openApiProperties.getInfo().getLicense().getUrl())));

openApiProperties.getService().getServers().forEach(
server -> api.addServersItem(new Server().description(server.getDescription()).url(server.getUrl())));
return api;
}

@Bean
public GroupedOpenApi groupedOpenApi() {
return GroupedOpenApi.builder().group(openApiProperties.getGroup().getName())
.pathsToMatch(openApiProperties.getGroup().getPaths().stream().toArray(String[]::new)).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,9 @@ public String getJson(String filename) {
log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, ExceptionUtils.getStackTrace(ex));
log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,
"In pre-registration service util of getPreregistrationIdentityJson- " + ex.getMessage());
throw new SystemFileIOException(DemographicErrorCodes.PRG_PAM_APP_018.getCode(),
DemographicErrorMessages.UBALE_TO_READ_IDENTITY_JSON.getMessage(), null);
// throw new SystemFileIOException(DemographicErrorCodes.PRG_PAM_APP_018.getCode(),
// DemographicErrorMessages.UBALE_TO_READ_IDENTITY_JSON.getMessage(), null);
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ management.endpoints.web.exposure.include=info,health,refresh

server.servlet.context-path=/preregistration/v1

mosip.preregistration.captcha.enable=true
mosip.preregistration.captcha.enable=false


#disabling health check so that client doesnt try to load properties from sprint config server every
Expand All @@ -27,13 +27,13 @@ mosip.preregistration.demographic.id.create=mosip.pre-registration.demographic.c
mosip.preregistration.demographic.id.update=mosip.pre-registration.demographic.update
mosip.preregistration.demographic.id.retrieve.date=mosip.pre-registration.demographic.retrieve.date
appId: prereg
mosip.base.url=https://api-internal.dev.mosip.net
mosip.base.url=https://api-internal.dev1.mosip.net
application.id: pre-registration
appointmentResourse.url: ${mosip.base.url}/preregistration/v1
audit.service.contextpath: auditmanager
audit.service.env: http://kernel-auditmanager-service
audit.url: ${mosip.base.url}/v1/auditmanager/audits
auth-token-generator.rest.issuerUrl:https://iam.dev.mosip.net/auth/realms/mosip
auth-token-generator.rest.issuerUrl:https://iam.dev1.mosip.net/auth/realms/mosip
auth.server.admin.validate.url:${mosip.base.url}/v1/authmanager/authorize/admin/validateToken
auth.server.validate.url: ${mosip.base.url}/v1/authmanager/authorize/admin/validateToken
batch.appointment.cancel: ${mosip.base.url}/preregistration/v1/internal/applications/appointment/{preRegistrationId}
Expand Down Expand Up @@ -79,8 +79,8 @@ hibernate.show_sql: false
holiday.exceptional.url: ${mosip.base.url}/v1/masterdata/exceptionalholidays/
holiday.url: ${mosip.base.url}/v1/masterdata/getregistrationcenterholidays/
javax.persistence.jdbc.driver: org.postgresql.Driver
javax.persistence.jdbc.password: OfUQvf4kUK
javax.persistence.jdbc.url=jdbc:postgresql://api-internal.dev.mosip.net:5432/mosip_prereg
javax.persistence.jdbc.password: aRWP1G52uu
javax.persistence.jdbc.url=jdbc:postgresql://api-internal.dev1.mosip.net:5432/mosip_prereg
javax.persistence.jdbc.user: postgres
kernel.auth.contextpath: authmanager
kernel.auth.env: ${mosip.base.url}
Expand Down Expand Up @@ -293,7 +293,7 @@ preregistration.workflow.documentupload: true/false
qrversion: V1
regCenter.url: ${mosip.base.url}/v1/masterdata/registrationcenters
resource.template.url: ${mosip.base.url}/v1/masterdata/templates
secretKey: 0xUtDcxYE8rfYMc6
secretKey: lJmGIMqcfgsZiHh9
sendOtp.resource.url: ${mosip.base.url}/v1/authmanager
server.max-http-request-header-size: 10000000
sms.acknowledgement.template: SMS-Acknowledgement
Expand Down Expand Up @@ -422,11 +422,11 @@ mosip.lostuin.applicationdetails.ara= \u0627\u0644\u062D\u062C\u0632 \u0644\u062

# To generate token from keycloak. Use by kernel auth adapter.
mosip.iam.adapter.clientid=mosip-prereg-client
mosip.iam.adapter.clientsecret= 0xUtDcxYE8rfYMc6
mosip.iam.adapter.clientsecret= lJmGIMqcfgsZiHh9
mosip.iam.adapter.appid=prereg

# URL to get new Auth Token from OIDC provider & to do online validation of auth token with OIDC provider.
auth.server.admin.issuer.uri=https://iam.dev.mosip.net/auth/realms/
auth.server.admin.issuer.uri=https://iam.dev1.mosip.net/auth/realms/

# Map to find the realm for the inputted appid to get the token from OIDC provider.
mosip.kernel.auth.appids.realm.map={prereg:'mosip',ida:'mosip',registrationclient:'mosip',regproc:'mosip',partner:'mosip',resident:'mosip',admin:'mosip',crereq:'mosip',creser:'mosip',datsha:'mosip',idrepo:'mosip',hotlist:'mosip'}
Expand Down
13 changes: 11 additions & 2 deletions pre-registration/pre-registration-batchjob/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
<properties>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-bom</artifactId>
<version>${kernel.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -51,12 +62,10 @@
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>${io.micrometer.prometheus.version}</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>${io.micrometer.prometheus.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,38 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;

import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig;

/**
* This class is used to define the start of the Booking application.
*
* @author Kishan Rathore
* @since 1.0.0
* @author Aiham Hasan
* @since 1.2.0
*
*/

@SpringBootApplication
@ComponentScan(basePackages = "io.mosip.*", excludeFilters = {
@ComponentScan.Filter(type = FilterType.REGEX,
pattern = {"io\\.mosip\\.kernel\\.zkcryptoservice\\..*",
"io\\.mosip\\.kernel\\.tokenidgenerator\\..*",
"io\\.mosip\\.kernel\\.signature\\..*",
"io\\.mosip\\.kernel\\.partnercertservice\\..*",
"io\\.mosip\\.kernel\\.lkeymanager\\..*",
"io\\.mosip\\.kernel\\.keymanagerservice\\..*",
"io\\.mosip\\.kernel\\.keymanager\\..*",
"io\\.mosip\\.kernel\\.keygenerator\\..*",
"io\\.mosip\\.kernel\\.cryptomanager\\..*",
"io\\.mosip\\.kernel\\.crypto\\..*",
"io\\.mosip\\.kernel\\.clientcrypto\\..*",
}) })
@ComponentScan.Filter(type = FilterType.REGEX, pattern = { "io\\.mosip\\.kernel\\.zkcryptoservice\\..*",
"io\\.mosip\\.kernel\\.tokenidgenerator\\..*",
"io\\.mosip\\.kernel\\.signature\\..*",
"io\\.mosip\\.kernel\\.partnercertservice\\..*",
"io\\.mosip\\.kernel\\.lkeymanager\\..*",
"io\\.mosip\\.kernel\\.keymanagerservice\\..*",
"io\\.mosip\\.kernel\\.keymanager\\..*",
"io\\.mosip\\.kernel\\.keygenerator\\..*",
"io\\.mosip\\.kernel\\.cryptomanager\\..*",
"io\\.mosip\\.kernel\\.crypto\\..*",
"io\\.mosip\\.kernel\\.clientcrypto\\..*",
"io.mosip.kernel.dataaccess.hibernate.config.*",
}),
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = { HibernateDaoConfig.class })
})
public class PreRegistrationBatchJob {
/**
* @param args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig;

/**
* This class is used for Swagger configuration, also to configure Host and
Expand All @@ -24,6 +27,7 @@
*/
@Configuration
@ConfigurationProperties("mosip.preregistration.batchjob")
@Import({ HibernateDaoConfig.class })
public class BatchjobConfig {

/** The id. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
/**
* This entity class defines the database table details for PreRegistration.
*
* @author Kishan Rathore
* @since 1.0.0
* @author Aiham Hasan
* @since 1.2.0
*
*/
@Component
Expand All @@ -38,8 +38,8 @@ public class DemographicEntityConsumed implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 6705845720255847210L;

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "demographicEntity")
private List<DocumentEntity> documentEntity;
// @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "demographicEntity")
// private List<DocumentEntity> documentEntity;

// @OneToOne(fetch = FetchType.EAGER,cascade=CascadeType.ALL, mappedBy = "applicationId")
// private ApplicationEntity applicationEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -34,7 +35,7 @@

/**
* @author Aiham Hasan
* @since 1.0.0
* @since 1.2.0
*
*/
@Configuration
Expand All @@ -55,11 +56,12 @@ public class PreRegistrationBatchJobConfig {
@Autowired
private ApplicationsBookingCheckTasklet applicationBookingCheckTasklet;

@Bean
public PlatformTransactionManager transactionManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}

// Commeting it as transactionManager is imported from Kernel-Auth-Adapter Jar
// @Bean
// public PlatformTransactionManager transactionManager(DataSource dataSource) {
// return new DataSourceTransactionManager(dataSource);
// }

@Bean
public Step consumedStatusStep(JobRepository jobRepository, PlatformTransactionManager transactionManager) {
return new StepBuilder("consumedStatusStep", jobRepository).tasklet(consumedStatusTasklet, transactionManager)
Expand All @@ -86,31 +88,31 @@ public Step updateBookingInApplicationsStep(JobRepository jobRepository,
}

@Bean
public Job purgeExpiredSlotsJob(JobRepository jobRepository, Step purgeExpiredSlotsStep) {
public Job purgeExpiredSlotsJob(JobRepository jobRepository,@Qualifier("purgeExpiredSlotsStep") Step purgeExpiredSlotsStep) {
return new JobBuilder("purgeExpiredSlotsJob", jobRepository).incrementer(new RunIdIncrementer())
.start(purgeExpiredSlotsStep).build();
}

@Bean
public Job consumedStatusJob(JobRepository jobRepository, Step consumedStatusStep) {
public Job consumedStatusJob(JobRepository jobRepository,@Qualifier("consumedStatusStep") Step consumedStatusStep) {
return new JobBuilder("consumedStatusJob", jobRepository).incrementer(new RunIdIncrementer())
.start(consumedStatusStep).build();
}

@Bean
public Job expiredStatusJob(JobRepository jobRepository, Step expiredStatusStep) {
public Job expiredStatusJob(JobRepository jobRepository,@Qualifier("expiredStatusStep") Step expiredStatusStep) {
return new JobBuilder("expiredStatusJob", jobRepository).incrementer(new RunIdIncrementer())
.start(expiredStatusStep).build();
}

@Bean
public Job updateApplicationForBookingCheckJob(JobRepository jobRepository, Step updateBookingInApplicationsStep) {
public Job updateApplicationForBookingCheckJob(JobRepository jobRepository,@Qualifier("updateBookingInApplicationsStep") Step updateBookingInApplicationsStep) {
return new JobBuilder("updateApplicationForBookingCheckJob", jobRepository).incrementer(new RunIdIncrementer())
.start(updateBookingInApplicationsStep).build();
}

@Bean(name = "regCenterPartitionerJob")
public Job regCenterPartitionerJob(JobRepository jobRepository, Step slotGenerationStep) {
@Bean
public Job regCenterPartitionerJob(JobRepository jobRepository,@Qualifier("slotGenerationStep") Step slotGenerationStep) {
return new JobBuilder("regCenterPartitionerJob", jobRepository)
.preventRestart()
.incrementer(new RunIdIncrementer())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
Expand Down Expand Up @@ -44,18 +45,23 @@ public class PreregistrationBatchJobScheduler {
@Autowired
private JobLauncher jobLauncher;

@Qualifier("regCenterPartitionerJob")
@Autowired
private Job regCenterPartitionerJob;

@Qualifier("consumedStatusJob")
@Autowired
private Job consumedStatusJob;

@Qualifier("expiredStatusJob")
@Autowired
private Job expiredStatusJob;

@Qualifier("updateApplicationForBookingCheckJob")
@Autowired
private Job updateApplicationForBookingCheckJob;

@Qualifier("purgeExpiredSlotsJob")
@Autowired
private Job purgeExpiredSlotsJob;

Expand Down
Loading

0 comments on commit 47b79d5

Please sign in to comment.