Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions func/internal/executableevaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
defaultKRMImagePrefix = "ghcr.io/kptdev/krm-functions-catalog/"
setImageFunction = "set-image"
starlarkFunction = "starlark"
testImageName = "test-image"
)

func getFunctionConfigStore(binaryDir string) *reconciler.FunctionConfigStore {
Expand Down
77 changes: 36 additions & 41 deletions func/internal/podevaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"sync/atomic"
"time"

"github.com/kptdev/kpt/pkg/fn/runtime"
"github.com/kptdev/kpt/pkg/lib/runneroptions"
fnconf "github.com/kptdev/porch/controllers/functionconfigs/reconciler"
"github.com/kptdev/porch/func/evaluator"
Expand Down Expand Up @@ -136,40 +135,44 @@ func NewPodEvaluator(ctx context.Context, o PodEvaluatorOptions, cl client.Clien
readyCh := make(chan *podReadyResponse, channelBufferSize)
evictCh := make(chan *podEvictionRequest, channelBufferSize)

podMgr := &podManager{
kubeClient: cl,
namespace: o.PodNamespace,
wrapperServerImage: o.WrapperServerImage,
podReadyCh: readyCh,
podReadyTimeout: 60 * time.Second,
managerNamespace: managerNs,
maxGrpcMessageSize: o.MaxGrpcMessageSize,

enablePrivateRegistries: o.EnablePrivateRegistries,
registryAuthSecretPath: o.RegistryAuthSecretPath,
registryAuthSecretName: o.RegistryAuthSecretName,
enablePrivateRegistriesTls: o.EnablePrivateRegistriesTls,
tlsSecretPath: o.TlsSecretPath,
imageResolver: runneroptions.ResolveToImageForCLIFunc(o.DefaultImagePrefix),
}

pcm := &podCacheManager{
gcScanInterval: o.GcScanInterval,
podTTL: o.PodTTL,
connectionRequestCh: reqCh,
podReadyCh: readyCh,
evictionCh: evictCh,
functions: map[string]*functionInfo{},
maxWaitlistLength: maxWaitlist,
maxParallelPodsPerFunction: maxPods,
functionConfigMap: functionConfigStore,

podManager: podMgr,
}

pe := &podEvaluator{
requestCh: reqCh,
evictionCh: evictCh,
maxGrpcRetries: maxRetries,
podCacheManager: &podCacheManager{
gcScanInterval: o.GcScanInterval,
podTTL: o.PodTTL,
connectionRequestCh: reqCh,
podReadyCh: readyCh,
evictionCh: evictCh,
functions: map[string]*functionInfo{},
maxWaitlistLength: maxWaitlist,
maxParallelPodsPerFunction: maxPods,
functionConfigMap: functionConfigStore,

podManager: &podManager{
kubeClient: cl,
namespace: o.PodNamespace,
wrapperServerImage: o.WrapperServerImage,
podReadyCh: readyCh,
podReadyTimeout: 60 * time.Second,
managerNamespace: managerNs,
maxGrpcMessageSize: o.MaxGrpcMessageSize,

enablePrivateRegistries: o.EnablePrivateRegistries,
registryAuthSecretPath: o.RegistryAuthSecretPath,
registryAuthSecretName: o.RegistryAuthSecretName,
enablePrivateRegistriesTls: o.EnablePrivateRegistriesTls,
tlsSecretPath: o.TlsSecretPath,
imageResolver: runneroptions.ResolveToImageForCLIFunc(o.DefaultImagePrefix),
tagResolver: runtime.TagResolver{},
},
},
requestCh: reqCh,
evictionCh: evictCh,
maxGrpcRetries: maxRetries,
podCacheManager: pcm,
}

go pe.podCacheManager.podCacheManager(ctx)

err = pe.podCacheManager.retrieveFunctionPods(context.Background())
Expand All @@ -191,17 +194,9 @@ func NewPodEvaluator(ctx context.Context, o PodEvaluatorOptions, cl client.Clien

func (pe *podEvaluator) EvaluateFunction(ctx context.Context, req *evaluator.EvaluateFunctionRequest) (*evaluator.EvaluateFunctionResponse, error) {
starttime := time.Now()
var image string
defer func() {
klog.Infof("evaluating %v in pod took %v", req.Image, time.Since(starttime))
}()
Comment thread
mozesl-nokia marked this conversation as resolved.
tagResolver := pe.podCacheManager.podManager.tagResolver
var err error
image, err = tagResolver.ResolveFunctionImage(ctx, req.Image, req.Tag)
if err != nil {
return nil, fmt.Errorf("failed to resolve tag for image %q with constraint %q: %w", req.Image, req.Tag, err)
}
req.Image = image

maxRetries := pe.maxGrpcRetries
var lastErr error
Expand Down
175 changes: 0 additions & 175 deletions func/internal/podevaluator_tag_resolution_test.go

This file was deleted.

Loading
Loading