Skip to content

Commit

Permalink
Update node dependencies 2024-12-19 (#275)
Browse files Browse the repository at this point in the history
* Added back in the ec2-metadata-service call to getInstanceId

* Updated version and dependencies

- Updated lockfile to latest
- Updated Mocha to v11

* Updated Next.js to 15.1

* Fixed timeout issue in unit tests by only calling metadata service in AWS
  • Loading branch information
tkmcmaster authored Dec 19, 2024
1 parent 537c578 commit 3b58277
Show file tree
Hide file tree
Showing 8 changed files with 2,051 additions and 1,698 deletions.
4 changes: 2 additions & 2 deletions agent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fs/ppaas-agent",
"version": "3.3.4",
"version": "3.3.5",
"description": "Agent Service for running pewpew tests",
"main": "dist/src/app.js",
"scripts": {
Expand Down Expand Up @@ -58,7 +58,7 @@
"axios": "~1.7.0",
"chai": "^4.3.7",
"eslint": "^9.15.0",
"mocha": "^10.2.0",
"mocha": "^11.0.0",
"nyc": "^17.0.0",
"typescript": "^5.3.0"
}
Expand Down
5 changes: 3 additions & 2 deletions common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fs/ppaas-common",
"version": "3.3.4",
"version": "3.3.5",
"description": "Common Code for the PewPewController and PewPewAgent",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down Expand Up @@ -35,6 +35,7 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.363.0",
"@aws-sdk/client-sqs": "^3.363.0",
"@aws-sdk/ec2-metadata-service": "^3.363.0",
"@aws-sdk/lib-storage": "^3.363.0",
"bunyan": "~1.8.0",
"rimraf": "^5.0.0"
Expand All @@ -55,7 +56,7 @@
"dotenv": "^16.0.0",
"dotenv-flow": "^4.0.1",
"eslint": "^9.15.0",
"mocha": "^10.2.0",
"mocha": "^11.0.0",
"nyc": "^17.0.0",
"typescript": "^5.3.0"
}
Expand Down
24 changes: 24 additions & 0 deletions common/src/util/ec2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LogLevel, log } from "./log";
import { IS_RUNNING_IN_AWS } from "./util";
import { MetadataService } from "@aws-sdk/ec2-metadata-service";
import { exec as _exec } from "child_process";
import { promisify } from "util";
import { readFile } from "fs/promises";
Expand All @@ -8,7 +10,29 @@ export const INSTANCE_ID_FILE = "/var/lib/cloud/data/instance-id";
export const INSTANCE_ID_REGEX = /^i-[0-9a-z]+$/;
export const INSTANCE_FILE_REGEX = /^instance-id:\s*(i-[0-9a-z]+)$/;
export const INSTANCE_ID_COMMAND = "ec2-metadata --instance-id";

// Putting back code removed by https://github.com/fs-eng/ppaas-common/commit/397d38e31ebafa9551dec8d9a2082140e8d949ae#diff-b0083bb9a17262c7a014463e8dee3fd0489cad8cb220d19531f295b9592826a0L14
// AWS SDK V3 finally supports the MetadataService
const metadata: MetadataService = new MetadataService({
// host: "169.254.169.254"
});

export async function getInstanceId (): Promise<string> {
// Our current mocks do not support the metadata service. bypass when not in AWS so we don't timeout on integration and unit tests
if (IS_RUNNING_IN_AWS) {
try {
// curl http://169.254.169.254/latest/meta-data/instance-id -> "i-0cfd3309705a3ce79"
const instanceId: string = await metadata.request("/latest/meta-data/instance-id", {});
log("getInstanceId MetadataService /latest/meta-data/instance-id: " + instanceId, LogLevel.WARN, instanceId);
if (!INSTANCE_ID_REGEX.test(instanceId)) {
log(`InstanceId did not match regex [${instanceId}]`, LogLevel.WARN, { match: instanceId?.match(INSTANCE_ID_REGEX), INSTANCE_ID_REGEX });
throw new Error("InstanceId did not match regex");
}
return instanceId;
} catch (error: unknown) {
log("Could not load instanceId metadata", LogLevel.WARN, error);
}
}
// Try to load from file first
// $ cat /var/lib/cloud/data/instance-id -> "i-0cfd3309705a3ce79"
try {
Expand Down
1 change: 1 addition & 0 deletions common/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const CONTROLLER_APPLICATION_PREFIX: string = CONTROLLER_APPLICATION_NAME
export const SYSTEM_NAME: string = process.env.SYSTEM_NAME || "unittests";
export const CONTROLLER_ENV = process.env.CONTROLLER_ENV;
export const AGENT_ENV = process.env.AGENT_ENV;
export const IS_RUNNING_IN_AWS: boolean = process.env.APPLICATION_NAME !== undefined && process.env.SYSTEM_NAME !== undefined;

export const PEWPEW_BINARY_FOLDER: string = "pewpew";
export const PEWPEW_VERSION_LATEST: string = "latest";
Expand Down
2 changes: 1 addition & 1 deletion controller/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
10 changes: 5 additions & 5 deletions controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fs/ppaas-controller",
"version": "3.3.4",
"version": "3.3.5",
"description": "Controller Service for running pewpew tests",
"private": true,
"scripts": {
Expand Down Expand Up @@ -63,7 +63,7 @@
"formidable": "~3.5.0",
"js-cookie": "^3.0.5",
"js-yaml": "^4.1.0",
"next": "~15.0.3",
"next": "~15.1.0",
"next-cookies": "^2.0.3",
"openid-client": "~5.7.0",
"rc-progress": "^4.0.0",
Expand All @@ -84,7 +84,7 @@
"@aws-sdk/util-stream-node": "^3.363.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.8.0",
"@next/eslint-plugin-next": "~15.0.3",
"@next/eslint-plugin-next": "~15.1.0",
"@storybook/addon-actions": "~8.4.0",
"@storybook/addon-links": "~8.4.0",
"@storybook/nextjs": "~8.4.0",
Expand Down Expand Up @@ -115,13 +115,13 @@
"dotenv-flow": "^4.0.1",
"esbuild": ">=0.17",
"eslint": "^9.15.0",
"eslint-config-next": "~15.0.3",
"eslint-config-next": "~15.1.0",
"form-data": "^4.0.0",
"glob-parent": "^6.0.2",
"immer": "^10.0.2",
"jsdom": ">=23.0.0",
"jsdom-global": "^3.0.2",
"mocha": "^10.2.0",
"mocha": "^11.0.0",
"nyc": "^17.0.0",
"postcss": "^8.4.24",
"set-value": "^4.1.0",
Expand Down
Loading

0 comments on commit 3b58277

Please sign in to comment.