mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-05-31 13:56:13 -07:00
* fixes * fixes * fixes * fixes * fixes * check for startup message in workflows * check for startup message in workflows * check for startup message in workflows * check for startup message in workflows * check for startup message in workflows * check for startup message in workflows * Update cloud-runner-ci-pipeline.yml * Update cloud-runner-ci-pipeline.yml * no storage class specified * log file path * log file path * log file path * log file path * log file path * log file path * log file path * log file path * updates * log file path * latest develop * log file path * log file path * Update package.json * log file path * log file path * log file path * log file path * log file path * log file path * log file path * log file path * log file path * log file path * log file path * log file path * log file path * log file path * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * stream logs through standard input and new remote client cli command * update pipeline to use k3s * version: 'latest' * fixes * disable aws pipe for now * disable aws pipe for now * disable aws pipe for now * disable aws pipe for now * disable aws pipe for now * disable aws pipe for now * disable aws pipe for now * disable aws pipe for now * disable aws pipe for now * disable aws pipe for now * push k8s logs to LOG SERVICE IP * push k8s logs to LOG SERVICE IP * push k8s logs to LOG SERVICE IP * push k8s logs to LOG SERVICE IP * push k8s logs to LOG SERVICE IP * push k8s logs to LOG SERVICE IP * push k8s logs to LOG SERVICE IP * push k8s logs to LOG SERVICE IP * tests * tests * tests * tests * tests * tests * tests * tests * tests * tests * tests * tests * tests * tests * tests * tests * tests * podname logs for log service * podname logs for log service * podname logs for log service * podname logs for log service * podname logs for log service * podname logs for log service * podname logs for log service * podname logs for log service * podname logs for log service * hashed logs * hashed logs * hashed logs * hashed logs * hashed logs * hashed logs * no wait, just repeat logs * no wait, just repeat logs * remove typo - double await * test fix - kubernetes - name typo in github yaml * test fix - kubernetes - name typo in github yaml * check missing log file * check missing log file * Push to steam test * Push to steam test * Fix path * k8s reliable log hashing * k8s reliable log hashing * k8s reliable log hashing * hashed logging k8s * hashed logging k8s * hashed logging k8s * hashed logging k8s * hashed logging k8s * hashed logging k8s * Include log chunk when task runner sees log update, clarify if we can pull logs from same line or next line * Include log chunk when task runner sees log update, clarify if we can pull logs from same line or next line * Include log chunk when task runner sees log update, clarify if we can pull logs from same line or next line * Include log chunk when task runner sees log update, clarify if we can pull logs from same line or next line * Include log chunk when task runner sees log update, clarify if we can pull logs from same line or next line * Fix exit flow for k8s job * hash comparison logging for log complete in k8s flow * Interrupt k8s logs when logs found * cleanup async parameter * cleanup async parameter * cleanup async parameter * fixes * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix
128 lines
3.9 KiB
TypeScript
128 lines
3.9 KiB
TypeScript
import { V1EnvVar, V1EnvVarSource, V1SecretKeySelector } from '@kubernetes/client-node';
|
|
import BuildParameters from '../../../build-parameters';
|
|
import { CommandHookService } from '../../services/hooks/command-hook-service';
|
|
import CloudRunnerEnvironmentVariable from '../../options/cloud-runner-environment-variable';
|
|
import CloudRunnerSecret from '../../options/cloud-runner-secret';
|
|
import CloudRunner from '../../cloud-runner';
|
|
|
|
class KubernetesJobSpecFactory {
|
|
static getJobSpec(
|
|
command: string,
|
|
image: string,
|
|
mountdir: string,
|
|
workingDirectory: string,
|
|
environment: CloudRunnerEnvironmentVariable[],
|
|
secrets: CloudRunnerSecret[],
|
|
buildGuid: string,
|
|
buildParameters: BuildParameters,
|
|
secretName: string,
|
|
pvcName: string,
|
|
jobName: string,
|
|
k8s: any,
|
|
containerName: string,
|
|
ip: string = '',
|
|
) {
|
|
const job = new k8s.V1Job();
|
|
job.apiVersion = 'batch/v1';
|
|
job.kind = 'Job';
|
|
job.metadata = {
|
|
name: jobName,
|
|
labels: {
|
|
app: 'unity-builder',
|
|
buildGuid,
|
|
},
|
|
};
|
|
job.spec = {
|
|
ttlSecondsAfterFinished: 9999,
|
|
backoffLimit: 0,
|
|
template: {
|
|
spec: {
|
|
volumes: [
|
|
{
|
|
name: 'build-mount',
|
|
persistentVolumeClaim: {
|
|
claimName: pvcName,
|
|
},
|
|
},
|
|
],
|
|
containers: [
|
|
{
|
|
ttlSecondsAfterFinished: 9999,
|
|
name: containerName,
|
|
image,
|
|
command: ['/bin/sh'],
|
|
args: [
|
|
'-c',
|
|
`${CommandHookService.ApplyHooksToCommands(`${command}\nsleep 2m`, CloudRunner.buildParameters)}`,
|
|
],
|
|
|
|
workingDir: `${workingDirectory}`,
|
|
resources: {
|
|
requests: {
|
|
memory: `${Number.parseInt(buildParameters.containerMemory) / 1024}G` || '750M',
|
|
cpu: Number.parseInt(buildParameters.containerCpu) / 1024 || '1',
|
|
},
|
|
},
|
|
env: [
|
|
...environment.map((x) => {
|
|
const environmentVariable = new V1EnvVar();
|
|
environmentVariable.name = x.name;
|
|
environmentVariable.value = x.value;
|
|
|
|
return environmentVariable;
|
|
}),
|
|
...secrets.map((x) => {
|
|
const secret = new V1EnvVarSource();
|
|
secret.secretKeyRef = new V1SecretKeySelector();
|
|
secret.secretKeyRef.key = x.ParameterKey;
|
|
secret.secretKeyRef.name = secretName;
|
|
const environmentVariable = new V1EnvVar();
|
|
environmentVariable.name = x.EnvironmentVariable;
|
|
environmentVariable.valueFrom = secret;
|
|
|
|
return environmentVariable;
|
|
}),
|
|
{ name: 'LOG_SERVICE_IP', value: ip },
|
|
],
|
|
volumeMounts: [
|
|
{
|
|
name: 'build-mount',
|
|
mountPath: `${mountdir}`,
|
|
},
|
|
],
|
|
lifecycle: {
|
|
preStop: {
|
|
exec: {
|
|
command: [
|
|
`wait 60s;
|
|
cd /data/builder/action/steps;
|
|
chmod +x /return_license.sh;
|
|
/return_license.sh;`,
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
restartPolicy: 'Never',
|
|
},
|
|
},
|
|
};
|
|
|
|
if (process.env['CLOUD_RUNNER_MINIKUBE']) {
|
|
job.spec.template.spec.volumes[0] = {
|
|
name: 'build-mount',
|
|
hostPath: {
|
|
path: `/data`,
|
|
type: `Directory`,
|
|
},
|
|
};
|
|
}
|
|
|
|
job.spec.template.spec.containers[0].resources.requests[`ephemeral-storage`] = '10Gi';
|
|
|
|
return job;
|
|
}
|
|
}
|
|
export default KubernetesJobSpecFactory;
|