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

Fix rendering big (>4MB) packages with function-runner #142

Merged
merged 6 commits into from
Nov 25, 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
16 changes: 9 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"--repo-sync-frequency=60s"
],
"cwd": "${workspaceFolder}",
"env": {
"CERT_STORAGE_DIR": "${workspaceFolder}/.build/pki/tmp",
"env": {
"CERT_STORAGE_DIR": "${workspaceFolder}/.build/pki/tmp",
"WEBHOOK_HOST": "localhost",
"GOOGLE_API_GO_EXPERIMENTAL_DISABLE_NEW_AUTH_LIB": "true"
}
Expand All @@ -31,9 +31,9 @@
"mode": "auto",
"program": "${workspaceFolder}/controllers",
"cwd": "${workspaceFolder}",
"env": {
"ENABLE_PACKAGEVARIANTS": "true",
"ENABLE_PACKAGEVARIANTSETS": "true"
"env": {
"ENABLE_PACKAGEVARIANTS": "true",
"ENABLE_PACKAGEVARIANTSETS": "true"
}
},
{
Expand All @@ -45,9 +45,11 @@
"args": [
"-test.v",
"-test.run",
"TestE2E/PorchSuite/TestGitRepositoryWithReleaseTagsAndDirectory"
"TestE2E/PorchSuite/TestPodEvaluatorWithLargeObjects"
],
"env": { "E2E": "1"}
"env": {
"E2E": "1"
}
},
{
"name": "Launch Func Client",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,5 @@ test-e2e: ## Run end-to-end tests
E2E=1 go test -v -failfast ./test/e2e/cli

.PHONY: test-e2e-clean
test-e2e-clean: porchctl ## Run end-to-end tests aginst a newly deployed porch in a newly created kind cluster
test-e2e-clean: porchctl ## Run end-to-end tests against a newly deployed porch in a newly created kind cluster
./scripts/clean-e2e-test.sh
1 change: 1 addition & 0 deletions deployments/porch/2-function-runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ spec:
- --config=/config.yaml
- --functions=/functions
- --pod-namespace=porch-fn-system
- --max-request-body-size=6291456 # Keep this in sync with porch-server's corresponding argument
env:
- name: WRAPPER_SERVER_IMAGE
value: docker.io/nephio/porch-wrapper-server:latest
Expand Down
19 changes: 10 additions & 9 deletions deployments/porch/3-porch-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,23 @@ spec:
- name: api-server-certs
mountPath: /tmp/certs
env:
# Uncomment to enable trace-reporting to jaeger
#- name: OTEL
# value: otel://jaeger-oltp:4317
- name: OTEL_SERVICE_NAME
value: porch-server
- name: CERT_STORAGE_DIR
value: "/etc/webhook/certs"
- name: GOOGLE_API_GO_EXPERIMENTAL_DISABLE_NEW_AUTH_LIB
value: "true"
# Uncomment to enable trace-reporting to jaeger
#- name: OTEL
# value: otel://jaeger-oltp:4317
- name: OTEL_SERVICE_NAME
value: porch-server
- name: CERT_STORAGE_DIR
value: "/etc/webhook/certs"
- name: GOOGLE_API_GO_EXPERIMENTAL_DISABLE_NEW_AUTH_LIB
value: "true"
args:
- --function-runner=function-runner:9445
- --cache-directory=/cache
- --cert-dir=/tmp/certs
- --secure-port=4443
- --repo-sync-frequency=10m
- --disable-validating-admissions-policy=true
- --max-request-body-size=6291456 # Keep this in sync with function-runner's corresponding argument

---
apiVersion: v1
Expand Down
17 changes: 11 additions & 6 deletions func/internal/executableevaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import (
"k8s.io/klog/v2"
)

type ExecutableEvaluatorOptions struct {
ConfigFileName string // Path to the config file
FunctionCacheDir string // Path to cached functions
}

type executableEvaluator struct {
// Fast-path function cache
cache map[string]string
Expand All @@ -47,25 +52,25 @@ type function struct {

var _ Evaluator = &executableEvaluator{}

func NewExecutableEvaluator(functions string, config string) (Evaluator, error) {
func NewExecutableEvaluator(o ExecutableEvaluatorOptions) (Evaluator, error) {
cache := map[string]string{}

if config != "" {
bytes, err := os.ReadFile(config)
if o.ConfigFileName != "" {
bytes, err := os.ReadFile(o.ConfigFileName)
if err != nil {
return nil, fmt.Errorf("failed to read configuration file %q: %w", config, err)
return nil, fmt.Errorf("failed to read configuration file %q: %w", o.ConfigFileName, err)
}
var cfg configuration
if err := yaml.Unmarshal(bytes, &cfg); err != nil {
return nil, fmt.Errorf("failed to parse configuration file %q: %w", config, err)
return nil, fmt.Errorf("failed to parse configuration file %q: %w", o.ConfigFileName, err)
}

for _, fn := range cfg.Functions {
for _, img := range fn.Images {
if _, exists := cache[img]; exists {
klog.Warningf("Ignoring duplicate image %q (%s)", img, fn.Function)
} else {
abs, err := filepath.Abs(filepath.Join(functions, fn.Function))
abs, err := filepath.Abs(filepath.Join(o.FunctionCacheDir, fn.Function))
if err != nil {
return nil, fmt.Errorf("failed to determine path to the cached function %q: %w", img, err)
}
Expand Down
Loading
Loading