Skip to content

Commit

Permalink
DOP-4451 fixing cluster, logging
Browse files Browse the repository at this point in the history
  • Loading branch information
anabellabuckvar committed May 6, 2024
1 parent 6281f69 commit df2894e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions api/controllers/v2/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,14 @@ export const triggerSmokeTestAutomatedBuild = async (event: APIGatewayEvent): Pr

async function runAdditionalECSTasks() {
const { TASK_DEFINITION, CLUSTER, SUBNETS } = process.env;
console.log('RUN');

if (!TASK_DEFINITION) throw new Error('ERROR! process.env.TASK_DEFINITION is not defined');
if (!CLUSTER) throw new Error('ERROR! process.env.CLUSTER is not defined');
if (!SUBNETS) throw new Error('ERROR! process.env.SUBNETS is not defined');

console.log('Env Vars exist for run');

const client = new ECSClient({
region: 'us-east-2',
});
Expand Down Expand Up @@ -234,15 +237,13 @@ export const triggerSmokeTestAutomatedBuild = async (event: APIGatewayEvent): Pr
repoOwner,
});

//add logic for getting master branch, latest stable branch
const job = await prepGithubPushPayload(body, payload, jobTitle);

try {
consoleLogger.info(job.title, 'Creating Job');
const jobId = await jobRepository.insertJob(job, c.get('jobsQueueUrl'));
jobRepository.notify(jobId, c.get('jobUpdatesQueueUrl'), JobStatus.inQueue, 0);
consoleLogger.info(job.title, `Created Job ${jobId}`);
runAdditionalECSTasks();
return jobId;
} catch (err) {
consoleLogger.error('TriggerBuildError', `${err} Error inserting job for ${repoName}`);
Expand All @@ -254,7 +255,7 @@ export const triggerSmokeTestAutomatedBuild = async (event: APIGatewayEvent): Pr

try {
const returnVal = await createAndInsertJob();
// run tasks here
await runAdditionalECSTasks();
return {
statusCode: 202,
headers: { 'Content-Type': 'text/plain' },
Expand Down
5 changes: 3 additions & 2 deletions cdk-infra/lib/constructs/api/webhook-api-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ interface WebhookApiConstructProps {
environment: Record<string, string>;
vpc: IVpc;
taskDefinition: TaskDefinition;
clusterName: string;
}

export class WebhookApiConstruct extends Construct {
constructor(
scope: Construct,
id: string,
{ jobsQueue, jobUpdatesQueue, environment, vpc, taskDefinition }: WebhookApiConstructProps
{ jobsQueue, jobUpdatesQueue, environment, vpc, taskDefinition, clusterName }: WebhookApiConstructProps
) {
super(scope, id);

Expand Down Expand Up @@ -90,7 +91,7 @@ export class WebhookApiConstruct extends Construct {
environment: {
TASK_DEFINITION: taskDefinition.taskDefinitionArn,
SUBNETS: JSON.stringify(vpc.privateSubnets.map((subnet) => subnet.subnetId)),
...environment,
CLUSTER: clusterName,
},
timeout,
});
Expand Down

0 comments on commit df2894e

Please sign in to comment.