Skip to content

Commit cfa7477

Browse files
committed
scheduling-webhook: hypershift image builds in memory-based storage
1 parent dc25f3d commit cfa7477

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

cmd/ci-scheduling-webhook/mutation.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ func mutatePod(w http.ResponseWriter, r *http.Request) {
201201
}
202202
}
203203

204+
if podClass == PodClassBuilds &&
205+
strings.HasPrefix(podName, "hypershift") &&
206+
strings.HasSuffix(podName, "amd64-build") {
207+
podClass = PodClassBuildsTmpfs
208+
}
209+
204210
if podClass != PodClassNone {
205211
profile("classified request")
206212

@@ -347,6 +353,23 @@ func mutatePod(w http.ResponseWriter, r *http.Request) {
347353
addPatchEntry("add", "/spec/affinity", unstructuredAffinity)
348354
}
349355

356+
if podClass == PodClassBuildsTmpfs {
357+
// Iterate over pod volumes and set medium to memory for container-storage-root and container-storage-run volumes
358+
for i, volume := range pod.Spec.Volumes {
359+
if volume.Name == "container-storage-root" || volume.Name == "container-storage-run" {
360+
if volume.EmptyDir != nil {
361+
volume.EmptyDir.Medium = corev1.StorageMediumMemory
362+
unstructuredEmptyDir, err := runtime.DefaultUnstructuredConverter.ToUnstructured(volume.EmptyDir)
363+
if err != nil {
364+
writeHttpError(500, fmt.Errorf("error decoding emptydir to unstructured data: %w", err))
365+
return
366+
}
367+
addPatchEntry("replace", fmt.Sprintf("/spec/volumes/%v/emptydir", i), unstructuredEmptyDir)
368+
}
369+
}
370+
}
371+
}
372+
350373
// There is currently an issue with cluster scale up where pods are stacked up, unschedulable.
351374
// A machine is provisioned. As soon as the machine is provisioned, pods are scheduled to the
352375
// node and they begin to run before DNS daemonset pods can successfully configure the pod.

cmd/ci-scheduling-webhook/prioritization.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ import (
3030
type PodClass string
3131

3232
const (
33-
PodClassBuilds PodClass = "builds"
34-
PodClassTests PodClass = "tests"
35-
PodClassLongTests PodClass = "longtests"
36-
PodClassProwJobs PodClass = "prowjobs"
37-
PodClassNone PodClass = ""
33+
PodClassBuilds PodClass = "builds"
34+
PodClassBuildsTmpfs PodClass = "builds-tmpfs"
35+
PodClassTests PodClass = "tests"
36+
PodClassLongTests PodClass = "longtests"
37+
PodClassProwJobs PodClass = "prowjobs"
38+
PodClassNone PodClass = ""
3839

3940
// MachineDeleteAnnotationKey When a machine is annotated with this and the machineset is scaled down,
4041
// it will target machines with this annotation to satisfy the change.

0 commit comments

Comments
 (0)