Skip to content

Commit

Permalink
feat(nanoid): move to nanoid from shortid (#170)
Browse files Browse the repository at this point in the history
* feat(nanoid): move to nanoid from shortid

* include oci-sdk upgrade

* move to node 22
  • Loading branch information
aaronkvanmeerten authored Dec 12, 2024
1 parent 3bceaac commit 5583e88
Show file tree
Hide file tree
Showing 7 changed files with 2,601 additions and 1,067 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$TARGETPLATFORM node:20
FROM --platform=$TARGETPLATFORM node:22
ARG TARGETPLATFORM

# install dependencies
Expand Down
3,642 changes: 2,587 additions & 1,055 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"node": ">=20"
},
"dependencies": {
"@types/shortid": "0.0.31",
"@types/sshpk": "^1.17.3",
"bee-queue": "^1.6.0",
"consul": "^2.0.1",
Expand All @@ -26,15 +25,15 @@
"got": "^11.8.6",
"ioredis": "^5.4.1",
"jsonwebtoken": "^9.0.2",
"nanoid": "^5.0.9",
"node-cache": "^5.1.2",
"oci-sdk": "^1.5.2",
"oci-sdk": "^2.100.0",
"prom-client": "^15.0.0",
"prometheus-query": "^3.4.1",
"prometheus-remote-write": "^0.4.1",
"redis": "^3.1.2",
"redlock": "^5.0.0-beta.2",
"sha256": "^0.2.0",
"shortid": "^2.2.16",
"winston": "^3.11.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Validator from './validator';
import Redis, { RedisOptions } from 'ioredis';
import * as promClient from 'prom-client';
import AutoscalerLogger from './logger';
import shortid from 'shortid';
import { nanoid } from 'nanoid/non-secure';
import { ASAPPubKeyFetcher } from './asap';
import { expressjwt } from 'express-jwt';
import { InstanceTracker } from './instance_tracker';
Expand Down Expand Up @@ -203,7 +203,7 @@ logger.info('Starting up autoscaler service with config', { config });

logger.info('Initializing instance group manager...');
const start = Date.now();
const initId = shortid.generate();
const initId = nanoid(10);
const initLogger = logger.child({ id: initId });
const initCtx = new context.Context(initLogger, start, initId);
instanceGroupManager.init(initCtx).catch((err) => {
Expand Down Expand Up @@ -297,7 +297,7 @@ const groupProcessingErrorCounter = new promClient.Counter({

async function createGroupProcessingJobs() {
const start = Date.now();
const pollId = shortid.generate();
const pollId = nanoid(10);
const pollLogger = logger.child({
id: pollId,
});
Expand All @@ -316,7 +316,7 @@ createSanityProcessingJobs();

async function createSanityProcessingJobs() {
const start = Date.now();
const pollId = shortid.generate();
const pollId = nanoid(10);
const pollLogger = logger.child({
id: pollId,
});
Expand Down
4 changes: 2 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Logger } from 'winston';
import { Request, Response, NextFunction } from 'express';
import shortid from 'shortid';
import { nanoid } from 'nanoid/non-secure';
import AutoscalerLogger from './logger';
import config from './config';

Expand All @@ -27,7 +27,7 @@ export class Context {
// context or anything it contains.
export function injectContext(req: Request, res: Response, next: NextFunction): void {
const start = Date.now();
const reqId = shortid.generate();
const reqId = nanoid(10);
const asLogger = new AutoscalerLogger({ logLevel: config.LogLevel });
const logger = asLogger.createLogger(config.LogLevel);

Expand Down
4 changes: 2 additions & 2 deletions src/job_manager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Queue, { DoneCallback, Job } from 'bee-queue';
import InstanceGroupManager from './instance_group';
import * as context from './context';
import shortid from 'shortid';
import { nanoid } from 'nanoid/non-secure';
import { Logger } from 'winston';
import { ClientOpts } from 'redis';
import InstanceLauncher from './instance_launcher';
Expand Down Expand Up @@ -149,7 +149,7 @@ export default class JobManager {

try {
const start = Date.now();
const pollId = shortid.generate();
const pollId = nanoid(10);
const pollLogger = this.logger.child({
id: pollId,
});
Expand Down
3 changes: 3 additions & 0 deletions src/oracle_instance_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { CloudRetryStrategy } from './cloud_manager';
import { AbstractCloudInstanceManager, CloudInstanceManager, CloudInstance } from './cloud_instance_manager';
import { InstanceGroup } from './instance_store';

// disable circuit breaker
common.CircuitBreaker.EnableGlobalCircuitBreaker = false;

interface FaultDomainMap {
[key: string]: string[];
}
Expand Down

0 comments on commit 5583e88

Please sign in to comment.