Skip to content

Commit

Permalink
feat: use alpine:3 as the default Application image
Browse files Browse the repository at this point in the history
- adds `pkg/defaults` and updates `pkg/fe/parser` to overlay Application defaults, which for now include a default image (alpine:3)
- updates the tests so as not to specify a base image, when it would otherwise be our lunchpail-worker image
- removes lunchpail-worker-alpine image, as it was only adding `bash` to alpine
- updates a few places that, for no good reason, depended on `/bin/bash` (switched to `/bin/sh`)
- updates linker/configure to remove values global.image.repo and global.image.registry (only used by the tests)

Signed-off-by: Nick Mitchell <[email protected]>
  • Loading branch information
starpit authored and aavarghese committed Aug 8, 2024
1 parent 8d543ea commit d3e8eb1
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 94 deletions.
4 changes: 2 additions & 2 deletions charts/shell/templates/prestop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ lifecycle:

{{- define "prestop/command" }}
{{- if eq .Values.component "workdispatcher" }}
- /bin/bash
- /bin/sh
- "-c"
- |
touch /tmp/alive && {{ .Values.command }}
/opt/lunchpail/internal/bin/prestop.sh
{{- else }}
- /bin/bash
- /bin/sh
- "-c"
- |
touch /tmp/alive && {{ .Values.command }}
Expand Down
2 changes: 1 addition & 1 deletion charts/workerpool/templates/containers/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: app
image: {{ .Values.image }}
command:
- /bin/bash
- /bin/sh
- "-c"
- |
trap "/workdir/watcher prestop" EXIT
Expand Down
11 changes: 0 additions & 11 deletions images/components/lunchpail-worker-alpine/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion images/components/lunchpail-worker-alpine/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions images/components/lunchpail-worker-alpine/sysctl.conf

This file was deleted.

11 changes: 11 additions & 0 deletions pkg/defaults/application/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package application

import "lunchpail.io/pkg/ir/hlir"

func WithDefaults(app hlir.Application) hlir.Application {
if app.Spec.Image == "" {
app.Spec.Image = "docker.io/alpine:3"
}

return app
}
117 changes: 55 additions & 62 deletions pkg/fe/linker/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,88 +95,81 @@ func Configure(appname, runname, namespace, templatePath string, internalS3Port

yaml := fmt.Sprintf(`
global:
unused: %s # "" (1)
dockerHost: %s # dockerHost (2)
dockerHost: %s # dockerHost (1)
rbac:
serviceaccount: %s # runname (3)
serviceaccount: %s # runname (2)
runAsRoot: false
image:
registry: %s # imageRegistry (4)
repo: %s # imageRepo (5)
jaas:
ips: %s # imagePullSecretName (6)
dockerconfigjson: %s # dockerconfigjson (7)
ips: %s # imagePullSecretName (3)
dockerconfigjson: %s # dockerconfigjson (4)
namespace:
name: %v # systemNamespace (8)
create: %v # opts.CreateNamespace (9)
name: %v # systemNamespace (5)
create: %v # opts.CreateNamespace (6)
context:
name: ""
s3Endpoint: http://%s-lunchpail-s3.%s.svc.cluster.local:%d # runnameMax40 (10) systemNamespace (11) internalS3Port (12)
s3Endpoint: http://%s-lunchpail-s3.%s.svc.cluster.local:%d # runnameMax40 (7) systemNamespace (8) internalS3Port (9)
s3AccessKey: lunchpail
s3SecretKey: lunchpail
lunchpail: lunchpail
username: %s # user.Username (13)
uid: %s # user.Uid (14)
username: %s # user.Username (10)
uid: %s # user.Uid (11)
mcad:
enabled: false
rbac:
serviceaccount: %s # runname (15)
serviceaccount: %s # runname (12)
image:
registry: %s # imageRegistry (16)
repo: %s # imageRepo (17)
version: %v # lunchpail.Version() (18)
partOf: %s # partOf (19)
registry: %s # imageRegistry (13)
repo: %s # imageRepo (14)
version: %v # lunchpail.Version() (15)
partOf: %s # partOf (16)
taskqueue:
auto: %v # queueSpec.Auto (20)
dataset: %s # queueSpec.Name (21)
endpoint: %s # queueSpec.Endpoint (22)
bucket: %s # queueSpec.Bucket (23)
accessKey: %s # queueSpec.AccessKey (24)
secretKey: %s # queueSpec.SecretKey (25)
name: %s # runname (26)
auto: %v # queueSpec.Auto (17)
dataset: %s # queueSpec.Name (18)
endpoint: %s # queueSpec.Endpoint (19)
bucket: %s # queueSpec.Bucket (20)
accessKey: %s # queueSpec.AccessKey (21)
secretKey: %s # queueSpec.SecretKey (22)
name: %s # runname (23)
namespace:
user: %s # namespace (27)
user: %s # namespace (24)
tags:
gpu: %v # hasGpuSupport (28)
gpu: %v # hasGpuSupport (25)
s3:
enabled: %v # queueSpec.Auto (29)
port: %d # internalS3Port (30)
enabled: %v # queueSpec.Auto (26)
port: %d # internalS3Port (27)
lunchpail_internal:
workstealer:
sleep_before_exit: %s # sleepBeforeExit (31)
sleep_before_exit: %s # sleepBeforeExit (28)
`,
"", // (1)
opts.CompilationOptions.DockerHost, // (2)
runname, // (3)
imageRegistry, // (4)
imageRepo, // (5)
imagePullSecretName, // (6)
dockerconfigjson, // (7)
systemNamespace, // (8)
opts.CompilationOptions.CreateNamespace, // (9)

runnameMax40, // (10)
systemNamespace, // (11)
internalS3Port, // (12)
user.Username, // (13)
user.Uid, // (14)
runname, // (15)
imageRegistry, // (16)
imageRepo, // (17)
lunchpail.Version(), // (18)
partOf, // (19)
queueSpec.Auto, // (20)
queueSpec.Name, // (21)
queueSpec.Endpoint, // (22)
queueSpec.Bucket, // (23)
queueSpec.AccessKey, // (24)
queueSpec.SecretKey, // (25)
runname, // (26)
namespace, // (27)
opts.CompilationOptions.HasGpuSupport, // (28)
queueSpec.Auto, // (29)
internalS3Port, // (30)
os.Getenv("LP_SLEEP_BEFORE_EXIT"), // (31)
opts.CompilationOptions.DockerHost, // (1)
runname, // (2)
imagePullSecretName, // (3)
dockerconfigjson, // (4)
systemNamespace, // (5)
opts.CompilationOptions.CreateNamespace, // (6)

runnameMax40, // (7)
systemNamespace, // (8)
internalS3Port, // (9)
user.Username, // (10)
user.Uid, // (11)
runname, // (12)
imageRegistry, // (13)
imageRepo, // (14)
lunchpail.Version(), // (15)
partOf, // (16)
queueSpec.Auto, // (17)
queueSpec.Name, // (18)
queueSpec.Endpoint, // (19)
queueSpec.Bucket, // (20)
queueSpec.AccessKey, // (21)
queueSpec.SecretKey, // (22)
runname, // (23)
namespace, // (24)
opts.CompilationOptions.HasGpuSupport, // (25)
queueSpec.Auto, // (26)
internalS3Port, // (27)
os.Getenv("LP_SLEEP_BEFORE_EXIT"), // (28)
)

backendValues, err := backend.Values()
Expand Down
3 changes: 2 additions & 1 deletion pkg/fe/parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"gopkg.in/yaml.v3"
"io"
"lunchpail.io/pkg/defaults/application"
"lunchpail.io/pkg/ir/hlir"
"os"
"strings"
Expand Down Expand Up @@ -41,7 +42,7 @@ func Parse(yamls string) (hlir.AppModel, error) {
fmt.Fprintf(os.Stderr, "Warning: skipping yaml with invalid Application resource %v", err)
continue
} else {
model.Applications = append(model.Applications, r)
model.Applications = append(model.Applications, application.WithDefaults(r))
}

case "ParameterSweep":
Expand Down
1 change: 0 additions & 1 deletion tests/tests/test7/pail/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: test7
spec:
role: worker
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}
code:
- name: main.sh
source: |
Expand Down
1 change: 0 additions & 1 deletion tests/tests/test7b/pail/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: test7b
spec:
role: worker
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}
code:
- name: main.sh
source: |
Expand Down
1 change: 0 additions & 1 deletion tests/tests/test7c/pail/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ spec:
echo "Done with $in"
command: ./literal.sh
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}
env:
MESSAGE: {{ .Values.message | default "BUG" }}
# TODO: dataset.py in run controller doesn't currently support adding both as mount and configmap
Expand Down
1 change: 0 additions & 1 deletion tests/tests/test7d/pail/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ spec:
echo "Done with $in"
command: ./literal.sh
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}
{{- end }}
1 change: 0 additions & 1 deletion tests/tests/test7e-by-role-autorun/pail/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ spec:
role: worker
command: ./literal.sh
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}

# TODO: dataset.py in run controller doesn't currently support adding both as mount and configmap
# inputs:
Expand Down
1 change: 0 additions & 1 deletion tests/tests/test7e-by-role/pail/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ spec:
role: worker
command: ./literal.sh
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}

# TODO: dataset.py in run controller doesn't currently support adding both as mount and configmap
# inputs:
Expand Down
1 change: 0 additions & 1 deletion tests/tests/test7e/pail/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ spec:
echo "Done with $in"
command: ./literal.sh
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}

# TODO: dataset.py in run controller doesn't currently support adding both as mount and configmap
# inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ spec:
echo "Done with $in"
command: ./literal.sh
image: {{ print .Values.image.registry "/" .Values.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}
2 changes: 1 addition & 1 deletion tests/tests/test7f-external/settings.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
api=workqueue
app=https://github.com/IBM/lunchpail-demo.git
branch=v0.2.0
branch=v0.3.0
deployname=lunchpail-demo

# /queue/0,1 <-- 2 workers
Expand Down
1 change: 0 additions & 1 deletion tests/tests/test7f/pail/worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ spec:
echo "Done with $in"
command: ./literal.sh
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}
env:
WORK_TIME: {{ .Values.duration | default 5 | quote }}
1 change: 0 additions & 1 deletion tests/tests/test7g/pail/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ spec:
echo "Done with $in"
command: ./literal.sh
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}
{{- end }}
1 change: 0 additions & 1 deletion tests/tests/test7g/pail/workdispatcher-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ spec:
sleep 10000
command: ./literal.sh
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}
env:
# main.sh from workdispatcher1 uses $taskprefix and $taskprefix2; this overrides an env var from ./workdispatcher-app.yaml
taskprefix: tasky
Expand Down
1 change: 0 additions & 1 deletion tests/tests/test7h/pail/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ spec:
echo "Done with $in"
command: ./literal.sh
image: {{ print .Values.global.image.registry "/" .Values.global.image.repo "/lunchpail-worker-alpine:" .Chart.AppVersion }}

# TODO: dataset.py in run controller doesn't currently support adding both as mount and configmap
# inputs:
Expand Down

0 comments on commit d3e8eb1

Please sign in to comment.