Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 665e1a6

Browse files
authored
fix(logging): Adjusting scale logging messages and levels (#1286)
1 parent 5a758b5 commit 665e1a6

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

Diff for: modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ async function createAuth(installationId: number | undefined, ghesApiUrl: string
5252
};
5353
if (installationId) authOptions = { ...authOptions, installationId };
5454

55-
console.debug(ghesApiUrl);
5655
if (ghesApiUrl) {
5756
authOptions.request = request.defaults({
5857
baseUrl: ghesApiUrl,

Diff for: modules/runners/lambdas/runners/src/scale-runners/runners.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export async function terminateRunner(instanceId: string): Promise<void> {
7272
InstanceIds: [instanceId],
7373
})
7474
.promise();
75-
console.debug(`Runner ${instanceId} has been terminated.`);
75+
console.info(`Runner ${instanceId} has been terminated.`);
7676
}
7777

7878
export async function createRunner(runnerParameters: RunnerInputParameters, launchTemplateName: string): Promise<void> {

Diff for: modules/runners/lambdas/runners/src/scale-runners/scale-down.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ async function listGitHubRunners(runner: RunnerInfo): Promise<GhRunners> {
5151
return cachedRunners;
5252
}
5353

54-
const client = await getOrCreateOctokit(runner);
5554
console.debug(`[listGithubRunners] Cache miss for ${key}`);
55+
const client = await getOrCreateOctokit(runner);
5656
const runners =
5757
runner.type === 'Org'
5858
? await client.paginate(client.actions.listSelfHostedRunnersForOrg, {
@@ -104,7 +104,7 @@ async function removeRunner(ec2runner: RunnerInfo, ghRunnerId: number): Promise<
104104
console.error(`Failed to de-register GitHub runner: ${result.status}`);
105105
}
106106
} catch (e) {
107-
console.debug(`Runner '${ec2runner.instanceId}' cannot be de-registered, most likely the runner is active.`);
107+
console.info(`Runner '${ec2runner.instanceId}' cannot be de-registered, most likely the runner is active.`);
108108
}
109109
}
110110

@@ -117,23 +117,23 @@ async function evaluateAndRemoveRunners(
117117

118118
for (const ownerTag of ownerTags) {
119119
const ec2RunnersFiltered = ec2Runners.filter((runner) => runner.owner === ownerTag);
120-
console.debug(`Found: '${ec2RunnersFiltered.length}' active GitHub runners with owner tag: '${ownerTag}'`);
120+
console.info(`Found: '${ec2RunnersFiltered.length}' active GitHub runners with owner tag: '${ownerTag}'`);
121121
for (const ec2Runner of ec2RunnersFiltered) {
122122
const ghRunners = await listGitHubRunners(ec2Runner);
123123
const ghRunner = ghRunners.find((runner) => runner.name === ec2Runner.instanceId);
124124
if (ghRunner) {
125125
if (runnerMinimumTimeExceeded(ec2Runner)) {
126126
if (idleCounter > 0) {
127127
idleCounter--;
128-
console.debug(`Runner '${ec2Runner.instanceId}' will kept idle.`);
128+
console.info(`Runner '${ec2Runner.instanceId}' will kept idle.`);
129129
} else {
130-
console.debug(`Runner '${ec2Runner.instanceId}' will be terminated.`);
130+
console.info(`Runner '${ec2Runner.instanceId}' will be terminated.`);
131131
await removeRunner(ec2Runner, ghRunner.id);
132132
}
133133
}
134134
} else {
135135
if (bootTimeExceeded(ec2Runner)) {
136-
console.debug(`Runner '${ec2Runner.instanceId}' is orphaned and will be removed.`);
136+
console.info(`Runner '${ec2Runner.instanceId}' is orphaned and will be removed.`);
137137
terminateOrphan(ec2Runner.instanceId);
138138
} else {
139139
console.debug(`Runner ${ec2Runner.instanceId} has not yet booted.`);

Diff for: modules/runners/lambdas/runners/src/scale-runners/scale-up.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export const scaleUp = async (eventSource: string, payload: ActionRequestMessage
2020
const environment = process.env.ENVIRONMENT;
2121
const ghesBaseUrl = process.env.GHES_URL;
2222

23+
console.info(`Received ${payload.eventType} from ${payload.repositoryOwner}/${payload.repositoryName}`);
24+
2325
let ghesApiUrl = '';
2426
if (ghesBaseUrl) {
2527
ghesApiUrl = `${ghesBaseUrl}/api/v3`;
@@ -58,6 +60,7 @@ export const scaleUp = async (eventSource: string, payload: ActionRequestMessage
5860
console.info(`${runnerType} ${runnerOwner} has ${currentRunners.length}/${maximumRunners} runners`);
5961

6062
if (currentRunners.length < maximumRunners) {
63+
console.info(`Attempting to launch a new runner`);
6164
// create token
6265
const registrationToken = enableOrgLevel
6366
? await githubInstallationClient.actions.createRegistrationTokenForOrg({ org: payload.repositoryOwner })
@@ -81,7 +84,7 @@ export const scaleUp = async (eventSource: string, payload: ActionRequestMessage
8184
runnerType,
8285
});
8386
} else {
84-
console.info('No runner will be created, maximum number of runners reached.');
87+
console.warn('No runner created: maximum number of runners reached.');
8588
}
8689
}
8790
};
@@ -105,7 +108,7 @@ async function getJobStatus(githubInstallationClient: Octokit, payload: ActionRe
105108
} else {
106109
throw Error(`Event ${payload.eventType} is not supported`);
107110
}
108-
console.debug(`Job ${payload.id} is ${isQueued ? 'queued' : 'not queued'}`);
111+
console.info(`Job ${payload.id} is ${isQueued ? 'queued' : 'not queued'}`);
109112
return isQueued;
110113
}
111114

@@ -119,7 +122,7 @@ export async function createRunnerLoop(runnerParameters: RunnerInputParameters):
119122
launched = true;
120123
break;
121124
} catch (error) {
122-
console.debug(`Attempt '${i}' to launch instance using ${launchTemplateNames[i]} FAILED.`);
125+
console.warn(`Attempt '${i}' to launch instance using ${launchTemplateNames[i]} FAILED.`);
123126
console.error(error);
124127
}
125128
}

0 commit comments

Comments
 (0)