Fix: watch pod until running
parent
d403415bbe
commit
ca6d7c750e
|
|
@ -50,7 +50,7 @@ function run() {
|
|||
switch (buildParameters.remoteBuildCluster) {
|
||||
case 'k8s':
|
||||
core.info('Building with Kubernetes');
|
||||
yield new model_1.Kubernetes(buildParameters, baseImage).run();
|
||||
yield new model_1.Kubernetes(buildParameters, baseImage).runFullBuildFlow();
|
||||
break;
|
||||
case 'aws':
|
||||
core.info('Building with AWS');
|
||||
|
|
@ -854,10 +854,10 @@ const core = __importStar(__webpack_require__(42186));
|
|||
const remote_builder_constants_1 = __importDefault(__webpack_require__(92560));
|
||||
const aws_build_runner_1 = __importDefault(__webpack_require__(11201));
|
||||
class AWSBuildEnvironment {
|
||||
run() {
|
||||
runFullBuildFlow() {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
runBuild(buildId, stackName, image, commands, mountdir, workingdir, environment, secrets) {
|
||||
runBuildTask(buildId, stackName, image, commands, mountdir, workingdir, environment, secrets) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const ECS = new SDK.ECS();
|
||||
const CF = new SDK.CloudFormation();
|
||||
|
|
@ -1282,7 +1282,7 @@ class Kubernetes {
|
|||
this.buildParameters = buildParameters;
|
||||
this.baseImage = baseImage;
|
||||
}
|
||||
runBuild(buildId, stackName, image, commands, mountdir, workingdir, environment, secrets) {
|
||||
runBuildTask(buildId, stackName, image, commands, mountdir, workingdir, environment, secrets) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
this.setUniqueBuildId();
|
||||
|
|
@ -1348,7 +1348,7 @@ class Kubernetes {
|
|||
this.secretName = secretName;
|
||||
this.jobName = jobName;
|
||||
}
|
||||
run() {
|
||||
runFullBuildFlow() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Running Remote Builder on Kubernetes');
|
||||
try {
|
||||
|
|
@ -1576,7 +1576,7 @@ class Kubernetes {
|
|||
}
|
||||
runCloneJob() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield this.runBuild(this.buildCorrelationId, '', 'alpine/git', [
|
||||
yield this.runBuildTask(this.buildCorrelationId, '', 'alpine/git', [
|
||||
'/bin/ash',
|
||||
'-c',
|
||||
`apk update;
|
||||
|
|
@ -1597,7 +1597,7 @@ class Kubernetes {
|
|||
}
|
||||
runBuildJob() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield this.runBuild(this.buildCorrelationId, '', this.baseImage.toString(), [
|
||||
yield this.runBuildTask(this.buildCorrelationId, '', this.baseImage.toString(), [
|
||||
'bin/bash',
|
||||
'-c',
|
||||
`ls
|
||||
|
|
@ -1615,27 +1615,22 @@ class Kubernetes {
|
|||
], '', '', [], []);
|
||||
});
|
||||
}
|
||||
getPodStatusPhase() {
|
||||
var _a, _b;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return (_b = (_a = (yield this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace))) === null || _a === void 0 ? void 0 : _a.body.status) === null || _b === void 0 ? void 0 : _b.phase;
|
||||
});
|
||||
}
|
||||
watchUntilPodRunning() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let success = false;
|
||||
core.info(`Watching ${this.podName} ${this.namespace}`);
|
||||
yield async_wait_until_1.waitUntil(() => __awaiter(this, void 0, void 0, function* () {
|
||||
(yield this.getPodStatusPhase()) !== 'Pending';
|
||||
var _a, _b;
|
||||
const phase = (_b = (_a = (yield this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace))) === null || _a === void 0 ? void 0 : _a.body.status) === null || _b === void 0 ? void 0 : _b.phase;
|
||||
success = phase === 'Running';
|
||||
if (success || phase !== 'Pending')
|
||||
return true;
|
||||
return false;
|
||||
}), {
|
||||
timeout: 500000,
|
||||
intervalBetweenAttempts: 15000,
|
||||
});
|
||||
const phase = yield this.getPodStatusPhase();
|
||||
if (phase === 'Running') {
|
||||
core.info('Pod no longer pending');
|
||||
}
|
||||
else {
|
||||
core.error('Pod failed to reach running phase');
|
||||
}
|
||||
return success;
|
||||
});
|
||||
}
|
||||
setPodNameAndContainerName(pod) {
|
||||
|
|
@ -1908,7 +1903,7 @@ class RemoteBuilder {
|
|||
static SetupStep(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 1/4 clone and restore cache)');
|
||||
yield this.RemoteBuilderProviderPlatform.runBuild(buildUid, buildParameters.awsStackName, 'alpine/git', [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, buildParameters.awsStackName, 'alpine/git', [
|
||||
'-c',
|
||||
`apk update;
|
||||
apk add unzip;
|
||||
|
|
@ -2020,7 +2015,7 @@ class RemoteBuilder {
|
|||
ParameterValue: buildParameters.androidKeyaliasPass,
|
||||
});
|
||||
core.info('Starting part 2/4 (build unity project)');
|
||||
yield this.RemoteBuilderProviderPlatform.runBuild(buildUid, buildParameters.awsStackName, baseImage.toString(), [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, buildParameters.awsStackName, baseImage.toString(), [
|
||||
'-c',
|
||||
`
|
||||
cp -r /${buildVolumeFolder}/${buildUid}/builder/dist/default-build-script/ /UnityBuilderAction;
|
||||
|
|
@ -2090,7 +2085,7 @@ class RemoteBuilder {
|
|||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 3/4 build compression');
|
||||
// Cleanup
|
||||
yield this.RemoteBuilderProviderPlatform.runBuild(buildUid, buildParameters.awsStackName, 'alpine', [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, buildParameters.awsStackName, 'alpine', [
|
||||
'-c',
|
||||
`
|
||||
apk update
|
||||
|
|
@ -2117,7 +2112,7 @@ class RemoteBuilder {
|
|||
static UploadArtifacts(buildUid, buildParameters, branchName, defaultSecretsArray) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 4/4 upload build to s3');
|
||||
yield this.RemoteBuilderProviderPlatform.runBuild(buildUid, buildParameters.awsStackName, 'amazon/aws-cli', [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, buildParameters.awsStackName, 'amazon/aws-cli', [
|
||||
'-c',
|
||||
`
|
||||
aws s3 cp ${buildUid}/build-${buildUid}.zip s3://game-ci-storage/
|
||||
|
|
@ -2152,7 +2147,7 @@ class RemoteBuilder {
|
|||
static DeployToSteam(buildUid, buildParameters, defaultSecretsArray) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting steam deployment');
|
||||
yield this.RemoteBuilderProviderPlatform.runBuild(buildUid, buildParameters.awsStackName, 'cm2network/steamcmd:root', [
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(buildUid, buildParameters.awsStackName, 'cm2network/steamcmd:root', [
|
||||
'-c',
|
||||
`
|
||||
ls
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -15,7 +15,7 @@ async function run() {
|
|||
switch (buildParameters.remoteBuildCluster) {
|
||||
case 'k8s':
|
||||
core.info('Building with Kubernetes');
|
||||
await new Kubernetes(buildParameters, baseImage).run();
|
||||
await new Kubernetes(buildParameters, baseImage).runFullBuildFlow();
|
||||
break;
|
||||
|
||||
case 'aws':
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ import AWSBuildRunner from './aws-build-runner';
|
|||
import { RemoteBuilderProviderInterface } from './remote-builder-provider-interface';
|
||||
|
||||
class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
|
||||
run(): Promise<void> {
|
||||
runFullBuildFlow(): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
async runBuild(
|
||||
async runBuildTask(
|
||||
buildId: string,
|
||||
stackName: string,
|
||||
image: string,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
|||
this.buildParameters = buildParameters;
|
||||
this.baseImage = baseImage;
|
||||
}
|
||||
async runBuild(
|
||||
async runBuildTask(
|
||||
buildId: string,
|
||||
stackName: string,
|
||||
image: string,
|
||||
|
|
@ -124,7 +124,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
|||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
async run() {
|
||||
async runFullBuildFlow() {
|
||||
core.info('Running Remote Builder on Kubernetes');
|
||||
try {
|
||||
await this.runCloneJob();
|
||||
|
|
@ -355,7 +355,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
|||
}
|
||||
|
||||
async runCloneJob() {
|
||||
await this.runBuild(
|
||||
await this.runBuildTask(
|
||||
this.buildCorrelationId,
|
||||
'',
|
||||
'alpine/git',
|
||||
|
|
@ -384,7 +384,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
|||
}
|
||||
|
||||
async runBuildJob() {
|
||||
await this.runBuild(
|
||||
await this.runBuildTask(
|
||||
this.buildCorrelationId,
|
||||
'',
|
||||
this.baseImage.toString(),
|
||||
|
|
@ -411,26 +411,22 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
|||
);
|
||||
}
|
||||
|
||||
async getPodStatusPhase() {
|
||||
return (await this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace))?.body.status?.phase;
|
||||
}
|
||||
|
||||
async watchUntilPodRunning() {
|
||||
let success: boolean = false;
|
||||
core.info(`Watching ${this.podName} ${this.namespace}`);
|
||||
await waitUntil(
|
||||
async () => {
|
||||
(await this.getPodStatusPhase()) !== 'Pending';
|
||||
const phase = (await this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace))?.body.status?.phase;
|
||||
success = phase === 'Running';
|
||||
if (success || phase !== 'Pending') return true;
|
||||
return false;
|
||||
},
|
||||
{
|
||||
timeout: 500000,
|
||||
intervalBetweenAttempts: 15000,
|
||||
},
|
||||
);
|
||||
const phase = await this.getPodStatusPhase();
|
||||
if (phase === 'Running') {
|
||||
core.info('Pod no longer pending');
|
||||
} else {
|
||||
core.error('Pod failed to reach running phase');
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
setPodNameAndContainerName(pod: k8s.V1Pod) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import RemoteBuilderEnvironmentVariable from './remote-builder-environment-varia
|
|||
import RemoteBuilderSecret from './remote-builder-secret';
|
||||
|
||||
export interface RemoteBuilderProviderInterface {
|
||||
run(): Promise<void>;
|
||||
runBuild(
|
||||
runFullBuildFlow(): Promise<void>;
|
||||
runBuildTask(
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
buildId: string,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class RemoteBuilder {
|
|||
defaultSecretsArray: RemoteBuilderSecret[],
|
||||
) {
|
||||
core.info('Starting step 1/4 clone and restore cache)');
|
||||
await this.RemoteBuilderProviderPlatform.runBuild(
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
buildParameters.awsStackName,
|
||||
'alpine/git',
|
||||
|
|
@ -200,7 +200,7 @@ class RemoteBuilder {
|
|||
ParameterValue: buildParameters.androidKeyaliasPass,
|
||||
});
|
||||
core.info('Starting part 2/4 (build unity project)');
|
||||
await this.RemoteBuilderProviderPlatform.runBuild(
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
buildParameters.awsStackName,
|
||||
baseImage.toString(),
|
||||
|
|
@ -283,7 +283,7 @@ class RemoteBuilder {
|
|||
) {
|
||||
core.info('Starting step 3/4 build compression');
|
||||
// Cleanup
|
||||
await this.RemoteBuilderProviderPlatform.runBuild(
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
buildParameters.awsStackName,
|
||||
'alpine',
|
||||
|
|
@ -323,7 +323,7 @@ class RemoteBuilder {
|
|||
defaultSecretsArray: RemoteBuilderSecret[],
|
||||
) {
|
||||
core.info('Starting step 4/4 upload build to s3');
|
||||
await this.RemoteBuilderProviderPlatform.runBuild(
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
buildParameters.awsStackName,
|
||||
'amazon/aws-cli',
|
||||
|
|
@ -370,7 +370,7 @@ class RemoteBuilder {
|
|||
defaultSecretsArray: RemoteBuilderSecret[],
|
||||
) {
|
||||
core.info('Starting steam deployment');
|
||||
await this.RemoteBuilderProviderPlatform.runBuild(
|
||||
await this.RemoteBuilderProviderPlatform.runBuildTask(
|
||||
buildUid,
|
||||
buildParameters.awsStackName,
|
||||
'cm2network/steamcmd:root',
|
||||
|
|
|
|||
Loading…
Reference in New Issue