Skip to content

Commit

Permalink
sync with main, and clenup
Browse files Browse the repository at this point in the history
  • Loading branch information
npalm committed Mar 13, 2023
1 parent cbff3d2 commit f17ee22
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 9 deletions.
3 changes: 3 additions & 0 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,7 @@ module "runners" {
# enable_workflow_job_events_queue = true

enable_user_data_debug_logging_runner = true

# prefix GitHub runners with the environment name
runner_name_prefix = local.environment
}
1 change: 0 additions & 1 deletion modules/runners/lambdas/runners/src/aws/runners.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@ function createRunnerConfig(runnerConfig: RunnerConfig): RunnerInputParameters {
},
subnets: ['subnet-123', 'subnet-456'],
amiIdSsmParameterName: runnerConfig.amiIdSsmParameterName,
runnerNamePrefix: RUNNER_NAME_PREFIX,
};
}

Expand Down
1 change: 0 additions & 1 deletion modules/runners/lambdas/runners/src/aws/runners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export interface RunnerInputParameters {
instanceAllocationStrategy: EC2.SpotAllocationStrategy;
};
numberOfRunners?: number;
runnerNamePrefix: string;
amiIdSsmParameterName?: string;
}

Expand Down
2 changes: 0 additions & 2 deletions modules/runners/lambdas/runners/src/pool/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export async function adjust(event: PoolEvent): Promise<void> {
const instanceAllocationStrategy = process.env.INSTANCE_ALLOCATION_STRATEGY || 'lowest-price'; // same as AWS default
const runnerOwner = process.env.RUNNER_OWNER;
const amiIdSsmParameterName = process.env.AMI_ID_SSM_PARAMETER_NAME;
const runnerNamePrefix = process.env.RUNNER_NAME_PREFIX || '';

let ghesApiUrl = '';
if (ghesBaseUrl) {
Expand Down Expand Up @@ -112,7 +111,6 @@ export async function adjust(event: PoolEvent): Promise<void> {
subnets,
numberOfRunners: topUp,
amiIdSsmParameterName,
runnerNamePrefix,
},
githubInstallationClient,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const EXPECTED_RUNNER_PARAMS: RunnerInputParameters = {
},
ssmTokenPath: '/github-action-runners/default/runners/config',
subnets: ['subnet-123'],
runnerNamePrefix: 'unit-test',
};
let expectedRunnerParams: RunnerInputParameters;

Expand Down
3 changes: 0 additions & 3 deletions modules/runners/lambdas/runners/src/scale-runners/scale-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ interface CreateEC2RunnerConfig {
ec2instanceCriteria: RunnerInputParameters['ec2instanceCriteria'];
numberOfRunners?: number;
amiIdSsmParameterName?: string;
runnerNamePrefix: string;
}

function generateRunnerServiceConfig(githubRunnerConfig: CreateGitHubRunnerConfig, token: string) {
Expand Down Expand Up @@ -157,7 +156,6 @@ export async function scaleUp(eventSource: string, payload: ActionRequestMessage
const instanceAllocationStrategy = process.env.INSTANCE_ALLOCATION_STRATEGY || 'lowest-price'; // same as AWS default
const enableJobQueuedCheck = yn(process.env.ENABLE_JOB_QUEUED_CHECK, { default: true });
const amiIdSsmParameterName = process.env.AMI_ID_SSM_PARAMETER_NAME;
const runnerNamePrefix = process.env.RUNNER_NAME_PREFIX || '';

if (ephemeralEnabled && payload.eventType !== 'workflow_job') {
logger.warn(
Expand Down Expand Up @@ -223,7 +221,6 @@ export async function scaleUp(eventSource: string, payload: ActionRequestMessage
ssmTokenPath,
subnets,
amiIdSsmParameterName,
runnerNamePrefix,
},
githubInstallationClient,
);
Expand Down
4 changes: 3 additions & 1 deletion modules/runners/templates/start-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ echo "Retrieved INSTANCE_ID from AWS API ($instance_id)"
%{ if metadata_tags == "enabled" }
environment=$(curl -f -H "X-aws-ec2-metadata-token: $token" -v http://169.254.169.254/latest/meta-data/tags/instance/ghr:environment)
ssm_config_path=$(curl -f -H "X-aws-ec2-metadata-token: $token" -v http://169.254.169.254/latest/meta-data/tags/instance/ghr:ssm_config_path)
runner_name_prefix=$(curl -f -H "X-aws-ec2-metadata-token: $token" -v http://169.254.169.254/latest/meta-data/tags/instance/ghr:runner_name_prefix) || true

%{ else }
tags=$(aws ec2 describe-tags --region "$region" --filters "Name=resource-id,Values=$instance_id")
echo "Retrieved tags from AWS API ($tags)"

environment=$(echo "$tags" | jq -r '.Tags[] | select(.Key == "ghr:environment") | .Value')
ssm_config_path=$(echo "$tags" | jq -r '.Tags[] | select(.Key == "ghr:ssm_config_path") | .Value')
runner_name_prefix=$(echo "$tags" | jq -r '.Tags[] | select(.Key == "ghr:runner_name_prefix") | .Value')

%{ endif }

echo "Retrieved ghr:environment tag - ($environment)"
echo "Retrieved ghr:ssm_config_path tag - ($ssm_config_path)"
runner_name_prefix=$(curl -f -H "X-aws-ec2-metadata-token: $token" -v http://169.254.169.254/latest/meta-data/tags/instance/ghr:runner_name_prefix) || true
echo "Retrieved ghr:runner_name_prefix tag - ($runner_name_prefix)"

parameters=$(aws ssm get-parameters-by-path --path "$ssm_config_path" --region "$region" --query "Parameters[*].{Name:Name,Value:Value}")
Expand Down

0 comments on commit f17ee22

Please sign in to comment.