Skip to content

Commit

Permalink
Merge pull request nephio-project#142 from nokia/grpc-msg-size
Browse files Browse the repository at this point in the history
Fix rendering big (>4MB) packages with function-runner
  • Loading branch information
nephio-prow[bot] authored Nov 25, 2024
2 parents c06b695 + 4b77ee0 commit f732f02
Show file tree
Hide file tree
Showing 15 changed files with 298 additions and 172 deletions.
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

0 comments on commit f732f02

Please sign in to comment.