Skip to content

Commit 80db790

Browse files
committed
pr feedback
1 parent b4fb0c0 commit 80db790

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

dist/index.js

Lines changed: 19 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/model/cloud-runner/remote-client/index.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,28 @@ export class RemoteClient {
169169
// The log stream will capture it and add it to BuildResults
170170
const successMessage = `Activation successful`;
171171

172+
// Write directly to log file first to ensure it's captured even if pipe fails
173+
// This is critical for all providers, especially K8s where timing matters
174+
try {
175+
const logFilePath = CloudRunner.isCloudRunnerEnvironment
176+
? `/home/job-log.txt`
177+
: path.join(process.cwd(), 'temp', 'job-log.txt');
178+
if (fs.existsSync(path.dirname(logFilePath))) {
179+
fs.appendFileSync(logFilePath, `${successMessage}\n`);
180+
}
181+
} catch (error) {
182+
// If direct file write fails, continue with other methods
183+
}
184+
172185
// Write to stdout so it gets piped through remote-cli-log-stream when invoked via pipe
173186
// This ensures the message is captured in BuildResults for all providers
174187
// Use synchronous write and ensure newline is included for proper flushing
175188
process.stdout.write(`${successMessage}\n`, 'utf8');
176189

177-
// For K8s, also write directly to stdout (not through pipe) to ensure kubectl logs captures it
178-
// This is critical because kubectl logs reads from stdout, and the pipe might not process
179-
// the message in time before the container exits
190+
// For K8s, also write to stderr as a backup since kubectl logs reads from both stdout and stderr
191+
// This ensures the message is captured even if stdout pipe has issues
180192
if (CloudRunnerOptions.providerStrategy === 'k8s') {
181-
// Write directly to stdout so kubectl logs can capture it immediately
182-
// This bypasses the pipe to ensure the message is captured even if the pipe fails
183-
process.stdout.write(`${successMessage}\n`, 'utf8');
193+
process.stderr.write(`${successMessage}\n`, 'utf8');
184194
}
185195

186196
// Ensure stdout is flushed before process exits (critical for K8s where process might exit quickly)

src/model/cloud-runner/workflows/build-automation-workflow.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ echo "CACHE_KEY=$CACHE_KEY"`;
184184
set -e
185185
# Write end marker and pipe through log stream
186186
# Use set +e to prevent failure if builder path doesn't exist (builder might have been cleaned up)
187+
# Keep set +e for the rest of the script to prevent exit on error
187188
set +e
188189
if [ -f "${builderPath}" ]; then
189190
echo "end of cloud runner job" | node ${builderPath} -m remote-cli-log-stream --logFile /home/job-log.txt || echo "end of cloud runner job" >> /home/job-log.txt
@@ -193,7 +194,8 @@ echo "CACHE_KEY=$CACHE_KEY"`;
193194
echo "end of cloud runner job" >> /home/job-log.txt
194195
echo "---${CloudRunner.buildParameters.logId}" >> /home/job-log.txt
195196
fi
196-
set -e
197+
# Don't restore set -e - keep set +e to prevent script from exiting on error
198+
# This ensures the script completes successfully even if some operations fail
197199
# Mirror cache back into workspace for test assertions
198200
mkdir -p "$GITHUB_WORKSPACE/cloud-runner-cache/cache/$CACHE_KEY/Library"
199201
mkdir -p "$GITHUB_WORKSPACE/cloud-runner-cache/cache/$CACHE_KEY/build"

0 commit comments

Comments
 (0)