Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add job_id to container envs #139

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HadesScheduler/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ func (s DockerStep) execute(ctx context.Context) error {
}

job_id := ctx.Value(jobIDContextKey("job_id")).(string)

// Add the job_id to the container envs
envs = append(envs, fmt.Sprintf("UUID=%s", job_id))

container_config := container.Config{
Image: s.Image,
Env: envs,
Expand Down
4 changes: 4 additions & 0 deletions HadesScheduler/k8s/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ func (k K8sJob) volumeSpec(cm corev1.ConfigMap) []corev1.Volume {
func (k K8sJob) containerSpec() []corev1.Container {
containerSpec := []corev1.Container{}

// Add the uuid to the job metadata
k.Metadata["UUID"] = k.ID.String()

for _, step := range k.Steps {

k8sStep := K8sStep{
step: step,
sharedVolumeName: k.sharedVolumeName,
Expand Down
55 changes: 55 additions & 0 deletions docs/api/Create Build Job (long-running-debug).bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
meta {
name: Create Build Job (long-running-debug)
type: http
seq: 3
}

post {
url: http://{{hostname}}/build
body: json
auth: none
}

body:json {
{
"name": "Example Job",
"metadata": {
"GLOBAL": "test"
},
"timestamp": "2021-01-01T00:00:00.000Z",
"priority": 3, // optional, default 3
"steps": [
{
"id": 1, // mandatory to declare the order of execution
"name": "Clone",
"image": "ghcr.io/ls1intum/hades/hades-clone-container:latest", // mandatory
"metadata": {
"REPOSITORY_DIR": "/shared",
"HADES_TEST_USERNAME": "{{user}}",
"HADES_TEST_PASSWORD": "{{password}}",
"HADES_TEST_URL": "{{test_repo}}",
"HADES_TEST_PATH": "./example",
"HADES_TEST_ORDER": "1",
"HADES_ASSIGNMENT_USERNAME": "{{user}}",
"HADES_ASSIGNMENT_PASSWORD": "{{password}}",
"HADES_ASSIGNMENT_URL": "{{assignment_repo}}",
"HADES_ASSIGNMENT_PATH": "./example/assignment",
"HADES_ASSIGNMENT_ORDER": "2"
}
},
{
"id": 2, // mandatory to declare the order of execution
"name": "Execute",
"image": "ls1tum/artemis-maven-template:java17-18", // mandatory
"script": "sleep 3.600"
}
]
}
}

vars:pre-request {
user: ""
password: ""
test_repo: "https://github.com/Mtze/Artemis-Java-Test.git"
assignment_repo: "https://github.com/Mtze/Artemis-Java-Solution.git"
}
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0=
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
Expand Down
Loading