Skip to content

Commit

Permalink
fix: ORV2-2698 Vault Audit - Refactor env variables for scheduler (#1555
Browse files Browse the repository at this point in the history
)
  • Loading branch information
praju-aot authored Aug 27, 2024
1 parent 1104ef8 commit 28f105e
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
4 changes: 3 additions & 1 deletion charts/onroutebc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ scheduler:
command:
- "sh"
- "-c"
- "source /vault/secrets/keycloak-{{.Values.global.vault.zone}} && source /vault/secrets/mssql-{{.Values.global.vault.zone}} && source /vault/secrets/s3-{{.Values.global.vault.zone}} && source /vault/secrets/scheduler-{{.Values.global.vault.zone}} && npm run start:prod"
- "source /vault/secrets/keycloak-{{.Values.global.vault.zone}} && source /vault/secrets/mssql-{{.Values.global.vault.zone}} && source /vault/secrets/s3-{{.Values.global.vault.zone}} && source /vault/secrets/scheduler-{{.Values.global.vault.zone}} && source /vault/secrets/cfs-{{.Values.global.vault.zone}} && source /vault/secrets/tps-{{.Values.global.vault.zone}} && npm run start:prod"
registry: '{{ .Values.global.registry }}'
repository: '{{ .Values.global.repository }}' # example, it includes registry and repository
image: scheduler
Expand Down Expand Up @@ -541,6 +541,8 @@ scheduler:
- "mssql-{{tpl $.Values.vault.zone $}}"
- "scheduler-{{tpl $.Values.vault.zone $}}"
- "s3-{{tpl $.Values.vault.zone $}}"
- "cfs-{{tpl $.Values.vault.zone $}}"
- "tps-{{tpl $.Values.vault.zone $}}"
zone: "{{.Values.global.vault.zone}}"

policy:
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ services:
dockerfile: Dockerfile
environment:
NODE_ENV: development
TPS_API_LOG_LEVEL: ${TPS_API_LOG_LEVEL}
TPS_API_TYPEORM_LOG_LEVEL: ${TPS_API_TYPEORM_LOG_LEVEL}
TPS_API_MAX_QUERY_EXECUTION_TIME_MS: ${TPS_API_MAX_QUERY_EXECUTION_TIME_MS}
SCHEDULER_API_LOG_LEVEL: ${SCHEDULER_API_LOG_LEVEL}
SCHEDULER_API_TYPEORM_LOG_LEVEL: ${SCHEDULER_API_TYPEORM_LOG_LEVEL}
SCHEDULER_API_MAX_QUERY_EXECUTION_TIME_MS: ${SCHEDULER_API_MAX_QUERY_EXECUTION_TIME_MS}
DB_TYPE: ${DB_TYPE}
MSSQL_HOST: sql-server-db
MSSQL_PORT: ${MSSQL_PORT}
Expand Down
6 changes: 3 additions & 3 deletions scheduler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ ENV NODE_ENV ${NODE_ENV}

# Set environment variables
ENV DB_TYPE ${DB_TYPE}
ENV TPS_API_LOG_LEVEL ${TPS_API_LOG_LEVEL}
ENV TPS_API_TYPEORM_LOG_LEVEL ${TPS_API_TYPEORM_LOG_LEVEL}
ENV TPS_API_MAX_QUERY_EXECUTION_TIME_MS ${TPS_API_MAX_QUERY_EXECUTION_TIME_MS}
ENV SCHEDULER_API_LOG_LEVEL ${SCHEDULER_API_LOG_LEVEL}
ENV SCHEDULER_API_TYPEORM_LOG_LEVEL ${SCHEDULER_API_TYPEORM_LOG_LEVEL}
ENV SCHEDULER_API_MAX_QUERY_EXECUTION_TIME_MS ${SCHEDULER_API_MAX_QUERY_EXECUTION_TIME_MS}
ENV MSSQL_HOST ${MSSQL_HOST}
ENV MSSQL_PORT ${MSSQL_PORT}
ENV MSSQL_DB ${MSSQL_DB}
Expand Down
6 changes: 3 additions & 3 deletions scheduler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ TPS_POLL_LIMIT = 50
TPS_PENDING_POLLING_INTERVAL = '0 */1 * * * *'
TPS_ERROR_POLLING_INTERVAL = '0 0 */3 * * *'
TPS_MONITORING_POLLING_INTERVAL = '0 0 1 * * *'
TPS_API_LOG_LEVEL= debug
TPS_API_TYPEORM_LOG_LEVEL= query,error,warn,info,log,schema
TPS_API_MAX_QUERY_EXECUTION_TIME_MS= 5000
SCHEDULER_API_LOG_LEVEL= debug
SCHEDULER_API_TYPEORM_LOG_LEVEL= query,error,warn,info,log,schema
SCHEDULER_API_MAX_QUERY_EXECUTION_TIME_MS= 5000
NODE_ENV=local
DB_TYPE=mssql
MSSQL_HOST= localhost
Expand Down
4 changes: 2 additions & 2 deletions scheduler/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const envPath = path.resolve(process.cwd() + '/../');
autoLoadEntities: true, // Auto load all entities regiestered by typeorm forFeature method.
synchronize: false, // This changes the DB schema to match changes to entities, which we might not want.
maxQueryExecutionTime:
+process.env.TPS_API_MAX_QUERY_EXECUTION_TIME_MS || 5000, //5 seconds by default
+process.env.SCHEDULER_API_MAX_QUERY_EXECUTION_TIME_MS || 5000, //5 seconds by default
logger: new TypeormCustomLogger(
getTypeormLogLevel(process.env.TPS_API_TYPEORM_LOG_LEVEL),
getTypeormLogLevel(process.env.SCHEDULER_API_TYPEORM_LOG_LEVEL),
),
}),
CacheModule.register({
Expand Down
4 changes: 2 additions & 2 deletions scheduler/src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export class AppService {
private featureFlagsService: FeatureFlagsService,
) {}

getHealthCheck(): string {
getHealthCheck(): string {
return 'TPS Migration Healthcheck!';
}

@LogAsyncMethodExecution({ printMemoryStats: true })
async initializeCache() {
const startDateTime = new Date();
const featureFlags = await this.featureFlagsService.findAll();

await addToCache(
this.cacheManager,
CacheKey.FEATURE_FLAG_TYPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function LogAsyncMethodExecution(logMethodOptions?: {
descriptor.value = async function (...args: any[]) {
if (
logMethodOptions?.printMemoryStats &&
process.env.TPS_API_LOG_LEVEL === 'debug'
process.env.SCHEDULER_API_LOG_LEVEL === 'debug'
) {
const memoryStats = process.memoryUsage();
memoryUsage = `, Memory usage: ${JSON.stringify(memoryStats)}`;
Expand All @@ -30,7 +30,7 @@ export function LogAsyncMethodExecution(logMethodOptions?: {
const executionTime = end - start;
if (
logMethodOptions?.printMemoryStats &&
process.env.TPS_API_LOG_LEVEL === 'debug'
process.env.SCHEDULER_API_LOG_LEVEL === 'debug'
) {
const memoryStats = process.memoryUsage();
memoryUsage = `, Memory usage: ${JSON.stringify(memoryStats)}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function LogMethodExecution(logMethodOptions?: {
descriptor.value = function (...args: any[]) {
if (
logMethodOptions?.printMemoryStats &&
process.env.TPS_API_LOG_LEVEL === 'debug'
process.env.SCHEDULER_API_LOG_LEVEL === 'debug'
) {
const memoryStats = process.memoryUsage();
memoryUsage = `, Memory usage: ${JSON.stringify(memoryStats)}`;
Expand All @@ -30,7 +30,7 @@ export function LogMethodExecution(logMethodOptions?: {
const executionTime = end - start;
if (
logMethodOptions?.printMemoryStats &&
process.env.TPS_API_LOG_LEVEL === 'debug'
process.env.SCHEDULER_API_LOG_LEVEL === 'debug'
) {
const memoryStats = process.memoryUsage();
memoryUsage = `, Memory usage: ${JSON.stringify(memoryStats)}`;
Expand Down
2 changes: 1 addition & 1 deletion scheduler/src/common/logger/logger.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const errorStack: winston.Logform.Format = winston.format.combine(
export const customLogger: LoggerService = WinstonModule.createLogger({
transports: [
new winston.transports.Console({
level: process.env.TPS_API_LOG_LEVEL || 'silly',
level: process.env.SCHEDULER_API_LOG_LEVEL || 'silly',
format: winston.format.combine(
globalLoggerFormat,
localLoggerFormat,
Expand Down

0 comments on commit 28f105e

Please sign in to comment.