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