pr feedback

pull/767/head
Frostebite 2025-12-09 20:22:53 +00:00
parent 37495c11b9
commit ebbb1d4150
5 changed files with 209 additions and 142 deletions

60
dist/index.js vendored
View File

@ -5565,6 +5565,7 @@ class RemoteClient {
}); });
} }
static async remoteClientPostBuild() { static async remoteClientPostBuild() {
try {
remote_client_logger_1.RemoteClientLogger.log(`Running POST build tasks`); remote_client_logger_1.RemoteClientLogger.log(`Running POST build tasks`);
// Ensure cache key is present in logs for assertions // Ensure cache key is present in logs for assertions
remote_client_logger_1.RemoteClientLogger.log(`CACHE_KEY=${cloud_runner_1.default.buildParameters.cacheKey}`); remote_client_logger_1.RemoteClientLogger.log(`CACHE_KEY=${cloud_runner_1.default.buildParameters.cacheKey}`);
@ -5631,7 +5632,13 @@ class RemoteClient {
await RemoteClient.runCustomHookFiles(`after-build`); await RemoteClient.runCustomHookFiles(`after-build`);
// WIP - need to give the pod permissions to create config map // WIP - need to give the pod permissions to create config map
await remote_client_logger_1.RemoteClientLogger.handleLogManagementPostJob(); await remote_client_logger_1.RemoteClientLogger.handleLogManagementPostJob();
// Ensure success marker is present in logs for tests }
catch (error) {
// Log error but don't fail - post-build tasks are best-effort
remote_client_logger_1.RemoteClientLogger.logWarning(`Post-build task error: ${error.message}`);
cloud_runner_logger_1.default.log(`Post-build task error: ${error.message}`);
}
// Ensure success marker is always present in logs for tests, even if post-build tasks failed
// For K8s, kubectl logs reads from stdout/stderr, so we must write to stdout // For K8s, kubectl logs reads from stdout/stderr, so we must write to stdout
// For all providers, we write to stdout so it gets piped through the log stream // For all providers, we write to stdout so it gets piped through the log stream
// The log stream will capture it and add it to BuildResults // The log stream will capture it and add it to BuildResults
@ -6903,9 +6910,15 @@ class ContainerHookService {
hook: after hook: after
commands: | commands: |
if command -v aws > /dev/null 2>&1; then if command -v aws > /dev/null 2>&1; then
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default || true if [ -n "$AWS_ACCESS_KEY_ID" ]; then
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default || true aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile default || true
aws configure set region $AWS_DEFAULT_REGION --profile default || true fi
if [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile default || true
fi
if [ -n "$AWS_DEFAULT_REGION" ]; then
aws configure set region "$AWS_DEFAULT_REGION" --profile default || true
fi
ENDPOINT_ARGS="" ENDPOINT_ARGS=""
if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi
aws $ENDPOINT_ARGS s3 cp /data/cache/$CACHE_KEY/build/build-${cloud_runner_1.default.buildParameters.buildGuid}.tar${cloud_runner_1.default.buildParameters.useCompressionStrategy ? '.lz4' : ''} s3://${cloud_runner_1.default.buildParameters.awsStackName}/cloud-runner-cache/$CACHE_KEY/build/build-$BUILD_GUID.tar${cloud_runner_1.default.buildParameters.useCompressionStrategy ? '.lz4' : ''} || true aws $ENDPOINT_ARGS s3 cp /data/cache/$CACHE_KEY/build/build-${cloud_runner_1.default.buildParameters.buildGuid}.tar${cloud_runner_1.default.buildParameters.useCompressionStrategy ? '.lz4' : ''} s3://${cloud_runner_1.default.buildParameters.awsStackName}/cloud-runner-cache/$CACHE_KEY/build/build-$BUILD_GUID.tar${cloud_runner_1.default.buildParameters.useCompressionStrategy ? '.lz4' : ''} || true
@ -6927,9 +6940,15 @@ class ContainerHookService {
commands: | commands: |
mkdir -p /data/cache/$CACHE_KEY/build/ mkdir -p /data/cache/$CACHE_KEY/build/
if command -v aws > /dev/null 2>&1; then if command -v aws > /dev/null 2>&1; then
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default || true if [ -n "$AWS_ACCESS_KEY_ID" ]; then
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default || true aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile default || true
aws configure set region $AWS_DEFAULT_REGION --profile default || true fi
if [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile default || true
fi
if [ -n "$AWS_DEFAULT_REGION" ]; then
aws configure set region "$AWS_DEFAULT_REGION" --profile default || true
fi
ENDPOINT_ARGS="" ENDPOINT_ARGS=""
if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi
aws $ENDPOINT_ARGS s3 ls ${cloud_runner_1.default.buildParameters.awsStackName}/cloud-runner-cache/ || true aws $ENDPOINT_ARGS s3 ls ${cloud_runner_1.default.buildParameters.awsStackName}/cloud-runner-cache/ || true
@ -6985,9 +7004,15 @@ class ContainerHookService {
hook: after hook: after
commands: | commands: |
if command -v aws > /dev/null 2>&1; then if command -v aws > /dev/null 2>&1; then
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default || true if [ -n "$AWS_ACCESS_KEY_ID" ]; then
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default || true aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile default || true
aws configure set region $AWS_DEFAULT_REGION --profile default || true fi
if [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile default || true
fi
if [ -n "$AWS_DEFAULT_REGION" ]; then
aws configure set region "$AWS_DEFAULT_REGION" --profile default || true
fi
ENDPOINT_ARGS="" ENDPOINT_ARGS=""
if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi
aws $ENDPOINT_ARGS s3 cp --recursive /data/cache/$CACHE_KEY/lfs s3://${cloud_runner_1.default.buildParameters.awsStackName}/cloud-runner-cache/$CACHE_KEY/lfs || true aws $ENDPOINT_ARGS s3 cp --recursive /data/cache/$CACHE_KEY/lfs s3://${cloud_runner_1.default.buildParameters.awsStackName}/cloud-runner-cache/$CACHE_KEY/lfs || true
@ -7013,9 +7038,15 @@ class ContainerHookService {
mkdir -p /data/cache/$CACHE_KEY/Library/ mkdir -p /data/cache/$CACHE_KEY/Library/
mkdir -p /data/cache/$CACHE_KEY/lfs/ mkdir -p /data/cache/$CACHE_KEY/lfs/
if command -v aws > /dev/null 2>&1; then if command -v aws > /dev/null 2>&1; then
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default || true if [ -n "$AWS_ACCESS_KEY_ID" ]; then
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default || true aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile default || true
aws configure set region $AWS_DEFAULT_REGION --profile default || true fi
if [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile default || true
fi
if [ -n "$AWS_DEFAULT_REGION" ]; then
aws configure set region "$AWS_DEFAULT_REGION" --profile default || true
fi
ENDPOINT_ARGS="" ENDPOINT_ARGS=""
if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi
aws $ENDPOINT_ARGS s3 ls ${cloud_runner_1.default.buildParameters.awsStackName}/cloud-runner-cache/ || true aws $ENDPOINT_ARGS s3 ls ${cloud_runner_1.default.buildParameters.awsStackName}/cloud-runner-cache/ || true
@ -7475,7 +7506,10 @@ echo "CACHE_KEY=$CACHE_KEY"`;
tar -cf "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar" --files-from /dev/null || touch "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar" tar -cf "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar" --files-from /dev/null || touch "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar"
fi fi
# Run post-build tasks and pipe output through log stream to capture "Activation successful" # Run post-build tasks and pipe output through log stream to capture "Activation successful"
# Use set +e to allow the command to fail without exiting the script, then restore set -e behavior
set +e
node ${builderPath} -m remote-cli-post-build | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt || echo "Post-build command completed with warnings" node ${builderPath} -m remote-cli-post-build | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt || echo "Post-build command completed with warnings"
set -e
# Write end marker and pipe through log stream # Write end marker and pipe through log stream
echo "end of cloud runner job" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt echo "end of cloud runner job" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt
echo "---${cloud_runner_1.default.buildParameters.logId}" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt echo "---${cloud_runner_1.default.buildParameters.logId}" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -80,6 +80,7 @@ export class RemoteClient {
@CliFunction(`remote-cli-post-build`, `runs a cloud runner build`) @CliFunction(`remote-cli-post-build`, `runs a cloud runner build`)
public static async remoteClientPostBuild(): Promise<string> { public static async remoteClientPostBuild(): Promise<string> {
try {
RemoteClientLogger.log(`Running POST build tasks`); RemoteClientLogger.log(`Running POST build tasks`);
// Ensure cache key is present in logs for assertions // Ensure cache key is present in logs for assertions
@ -153,8 +154,13 @@ export class RemoteClient {
// WIP - need to give the pod permissions to create config map // WIP - need to give the pod permissions to create config map
await RemoteClientLogger.handleLogManagementPostJob(); await RemoteClientLogger.handleLogManagementPostJob();
} catch (error: any) {
// Log error but don't fail - post-build tasks are best-effort
RemoteClientLogger.logWarning(`Post-build task error: ${error.message}`);
CloudRunnerLogger.log(`Post-build task error: ${error.message}`);
}
// Ensure success marker is present in logs for tests // Ensure success marker is always present in logs for tests, even if post-build tasks failed
// For K8s, kubectl logs reads from stdout/stderr, so we must write to stdout // For K8s, kubectl logs reads from stdout/stderr, so we must write to stdout
// For all providers, we write to stdout so it gets piped through the log stream // For all providers, we write to stdout so it gets piped through the log stream
// The log stream will capture it and add it to BuildResults // The log stream will capture it and add it to BuildResults

View File

@ -38,9 +38,15 @@ export class ContainerHookService {
hook: after hook: after
commands: | commands: |
if command -v aws > /dev/null 2>&1; then if command -v aws > /dev/null 2>&1; then
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default || true if [ -n "$AWS_ACCESS_KEY_ID" ]; then
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default || true aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile default || true
aws configure set region $AWS_DEFAULT_REGION --profile default || true fi
if [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile default || true
fi
if [ -n "$AWS_DEFAULT_REGION" ]; then
aws configure set region "$AWS_DEFAULT_REGION" --profile default || true
fi
ENDPOINT_ARGS="" ENDPOINT_ARGS=""
if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi
aws $ENDPOINT_ARGS s3 cp /data/cache/$CACHE_KEY/build/build-${CloudRunner.buildParameters.buildGuid}.tar${ aws $ENDPOINT_ARGS s3 cp /data/cache/$CACHE_KEY/build/build-${CloudRunner.buildParameters.buildGuid}.tar${
@ -68,9 +74,15 @@ export class ContainerHookService {
commands: | commands: |
mkdir -p /data/cache/$CACHE_KEY/build/ mkdir -p /data/cache/$CACHE_KEY/build/
if command -v aws > /dev/null 2>&1; then if command -v aws > /dev/null 2>&1; then
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default || true if [ -n "$AWS_ACCESS_KEY_ID" ]; then
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default || true aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile default || true
aws configure set region $AWS_DEFAULT_REGION --profile default || true fi
if [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile default || true
fi
if [ -n "$AWS_DEFAULT_REGION" ]; then
aws configure set region "$AWS_DEFAULT_REGION" --profile default || true
fi
ENDPOINT_ARGS="" ENDPOINT_ARGS=""
if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi
aws $ENDPOINT_ARGS s3 ls ${CloudRunner.buildParameters.awsStackName}/cloud-runner-cache/ || true aws $ENDPOINT_ARGS s3 ls ${CloudRunner.buildParameters.awsStackName}/cloud-runner-cache/ || true
@ -132,9 +144,15 @@ export class ContainerHookService {
hook: after hook: after
commands: | commands: |
if command -v aws > /dev/null 2>&1; then if command -v aws > /dev/null 2>&1; then
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default || true if [ -n "$AWS_ACCESS_KEY_ID" ]; then
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default || true aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile default || true
aws configure set region $AWS_DEFAULT_REGION --profile default || true fi
if [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile default || true
fi
if [ -n "$AWS_DEFAULT_REGION" ]; then
aws configure set region "$AWS_DEFAULT_REGION" --profile default || true
fi
ENDPOINT_ARGS="" ENDPOINT_ARGS=""
if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi
aws $ENDPOINT_ARGS s3 cp --recursive /data/cache/$CACHE_KEY/lfs s3://${ aws $ENDPOINT_ARGS s3 cp --recursive /data/cache/$CACHE_KEY/lfs s3://${
@ -164,9 +182,15 @@ export class ContainerHookService {
mkdir -p /data/cache/$CACHE_KEY/Library/ mkdir -p /data/cache/$CACHE_KEY/Library/
mkdir -p /data/cache/$CACHE_KEY/lfs/ mkdir -p /data/cache/$CACHE_KEY/lfs/
if command -v aws > /dev/null 2>&1; then if command -v aws > /dev/null 2>&1; then
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile default || true if [ -n "$AWS_ACCESS_KEY_ID" ]; then
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile default || true aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile default || true
aws configure set region $AWS_DEFAULT_REGION --profile default || true fi
if [ -n "$AWS_SECRET_ACCESS_KEY" ]; then
aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile default || true
fi
if [ -n "$AWS_DEFAULT_REGION" ]; then
aws configure set region "$AWS_DEFAULT_REGION" --profile default || true
fi
ENDPOINT_ARGS="" ENDPOINT_ARGS=""
if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi if [ -n "$AWS_S3_ENDPOINT" ]; then ENDPOINT_ARGS="--endpoint-url $AWS_S3_ENDPOINT"; fi
aws $ENDPOINT_ARGS s3 ls ${CloudRunner.buildParameters.awsStackName}/cloud-runner-cache/ || true aws $ENDPOINT_ARGS s3 ls ${CloudRunner.buildParameters.awsStackName}/cloud-runner-cache/ || true

View File

@ -178,7 +178,10 @@ echo "CACHE_KEY=$CACHE_KEY"`;
tar -cf "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar" --files-from /dev/null || touch "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar" tar -cf "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar" --files-from /dev/null || touch "/data/cache/$CACHE_KEY/build/build-$BUILD_GUID.tar"
fi fi
# Run post-build tasks and pipe output through log stream to capture "Activation successful" # Run post-build tasks and pipe output through log stream to capture "Activation successful"
# Use set +e to allow the command to fail without exiting the script, then restore set -e behavior
set +e
node ${builderPath} -m remote-cli-post-build | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt || echo "Post-build command completed with warnings" node ${builderPath} -m remote-cli-post-build | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt || echo "Post-build command completed with warnings"
set -e
# Write end marker and pipe through log stream # Write end marker and pipe through log stream
echo "end of cloud runner job" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt echo "end of cloud runner job" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt
echo "---${CloudRunner.buildParameters.logId}" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt echo "---${CloudRunner.buildParameters.logId}" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt