Skip to content
Draft
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: 3 additions & 1 deletion pkg/cli/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func cmdBuild() *cobra.Command {
cmd.Flags().StringVar(&cfg.k8sNamespace, "k8s-namespace", "default", "namespace to deploy pods into for builds.")
cmd.Flags().StringVar(&cfg.machineFamily, "machine-family", "", "machine family for amd64 builds")
cmd.Flags().StringVar(&cfg.serviceAccount, "service-account", "default", "service-account to run pods as.")
cmd.Flags().BoolVar(&cfg.memTmpfs, "memory-tmpfs", false, "whether to use memory-backed emptydir tmpfs for pods or not when resource are specified.")

return cmd
}
Expand Down Expand Up @@ -602,6 +603,7 @@ type global struct {
k8sNamespace string
serviceAccount string
machineFamily string
memTmpfs bool
}

func (g *global) logdir(arch string) string {
Expand Down Expand Up @@ -831,7 +833,7 @@ func (t *task) buildBundleArch(ctx context.Context, arch string) (*bundleResult,

log := clog.FromContext(ctx)

pod, err := bundle.Podspec(*t.bundle, t.ref, arch, t.cfg.machineFamily, t.cfg.serviceAccount, t.cfg.k8sNamespace)
pod, err := bundle.Podspec(*t.bundle, t.ref, arch, t.cfg.machineFamily, t.cfg.serviceAccount, t.cfg.k8sNamespace, t.cfg.memTmpfs)
if err != nil {
return nil, fmt.Errorf("creating podspec for %s: %w", t.pkg, err)
}
Expand Down
11 changes: 9 additions & 2 deletions pkg/internal/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func escapeRFC1123(s string) string {

// Podspec returns bytes of yaml representing a podspec.
// This is a terrible API that we should change.
func Podspec(task Task, ref name.Reference, arch, mFamily, sa, ns string) (*corev1.Pod, error) {
func Podspec(task Task, ref name.Reference, arch, mFamily, sa, ns string, memTmpfs bool) (*corev1.Pod, error) {
goarch := types.ParseArchitecture(arch).String()

// Set some sane default resource requests if none are specified by flag or config.
Expand All @@ -348,10 +348,15 @@ func Podspec(task Task, ref name.Reference, arch, mFamily, sa, ns string) (*core
Memory: "4Gi",
}

emptyDirMedium := corev1.StorageMediumDefault
// Copy resources out of the task rather than overwriting in place because both archs share the same task.
if in := task.Resources; in != nil {
if in.CPU != "" {
resources.CPU = in.CPU

if memTmpfs {
emptyDirMedium = corev1.StorageMediumMemory
}
}
if in.Memory != "" {
resources.Memory = in.Memory
Expand Down Expand Up @@ -459,7 +464,9 @@ func Podspec(task Task, ref name.Reference, arch, mFamily, sa, ns string) (*core
{
Name: "tmp-dir-bundle-builder",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: emptyDirMedium,
},
},
},
},
Expand Down