Skip to content

FunctionConfig controller improvements 1#1019

Draft
mozesl-nokia wants to merge 15 commits into
kptdev:mainfrom
nokia:fnconf-improv-1
Draft

FunctionConfig controller improvements 1#1019
mozesl-nokia wants to merge 15 commits into
kptdev:mainfrom
nokia:fnconf-improv-1

Conversation

@mozesl-nokia

Copy link
Copy Markdown
Contributor

Title

FunctionConfig controller improvements 1


Description

  • What changed: A lot of the logic around the functionconfig reconciler/controller/store has been rewritten. New image parsing logic added. Prepared some additional changes by moving files around in func/.
  • Why it’s needed: Simplify how the reconciler works and prepare it for further improvements.
  • How it works: The store cache has been unified into a single, multi-layer map, the Store method has been made "smarter", improved the Get methods.

Related Issue(s)

None


Type of Change

  • Bug fix
  • Enhancement
  • Refactor

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

Additional Notes (Optional)

  • Known issues: make destroy does not seem to work 100% of the time because porch-server gets deleted before the finalizers can be removed from the functionconfigs
  • Further improvements: making warmup event based, using the new image parsing elsewhere

AI Disclosure

I have not used AI in the creation of this PR.

…or now

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Copilot AI review requested due to automatic review settings June 2, 2026 13:26
@mozesl-nokia mozesl-nokia added go Pull requests that update go code refactoring #b33d8f cleanup labels Jun 2, 2026
@netlify

netlify Bot commented Jun 2, 2026

Copy link
Copy Markdown

Deploy Preview for kpt-porch ready!

Name Link
🔨 Latest commit a769f10
🔍 Latest deploy log https://app.netlify.com/projects/kpt-porch/deploys/6a1fdf2fca4e5000096876fd
😎 Deploy Preview https://deploy-preview-1019--kpt-porch.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the FunctionConfig controller, store, and surrounding infrastructure. The previous multi-cache FunctionConfigStore is replaced with a single multi-layer (image → prefix → tag) cache; image parsing is moved into a new pkg/util/image package; the func/internal package is renamed func/evaluator, the generated proto code moves to func/proto, and shared evaluator types move to func/types. Imports across the repository are updated accordingly.

Changes:

  • Unify the function-config cache and rewrite Store/Get paths around a parsed-image lookup, replacing the prior UpdateExecCache/UpdateBinaryCache/GetBinaryFromCache* API.
  • Introduce pkg/util/image with a new ParsedImage, Parse, Join, and FindBestSemverMatch; remove the older helpers from pkg/util/util.go.
  • Reorganise func/: rename package internalevaluator, move generated proto to func/proto, extract shared types to func/types, and add a startup wait for FunctionConfig warmup.

Reviewed changes

Copilot reviewed 43 out of 48 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/util/util.go, util_test.go Removes image helpers and semver match (moved to pkg/util/image).
pkg/util/image/{image,types,regex}.go, image_test.go New image parsing/joining/semver helpers and tests.
controllers/functionconfigs/store.go, store_test.go New unified FunctionConfigStore implementation and tests.
controllers/functionconfigs/reconciler.go, reconciler_test.go New reconciler using Store, replaces deleted reconciler/functionconfigreconciler.go.
controllers/functionconfigs/reconciler/functionconfigreconciler.go Deleted (logic split into store.go/reconciler.go).
controllers/main.go, main_test.go Pre-population uses the new Store API; minor test updates.
controllers/packagerevisions/.../packagerevision_controller.go, config_test.go Import path/type updates for the new package.
api/porchconfig/v1alpha1/function_config_types.go Adds TagIterable interface and IterTags methods on executor configs.
pkg/apiserver/apiserver.go Updated imports/types for the renamed package.
pkg/engine/{builtinruntime,grpcruntime,options}.go (+tests) Use the new store API and imageutil.
func/server/server.go, func/client/main.go, func/wrapper-server/* Import-path updates after the package renames.
func/proto/evaluator.{proto,pb.go,_grpc.pb.go} Generated proto files relocated.
func/types/common_types.go Newly-shared evaluator types (PodData, ConnectionRequest, etc.).
func/evaluator/*.go (+ tests) Package renamed internalevaluator; uses new shared types and store API; adds startup warmup wait.
func/evaluator/testdata/config*.yaml Test fixtures added.
func/Makefile Proto source path partially updated.
.golangci.json Allow dot-import (ST1001) under func/evaluator/.
Comments suppressed due to low confidence (2)

func/Makefile:31

  • The Makefile recipe was only partially updated. The prerequisite was changed to proto/evaluator.proto, but COMPILED_PROTO (line 19) still targets files under evaluator/, and the recipe (lines 28–31) still uses -I ./evaluator, writes outputs to ./evaluator, and compiles ./evaluator/evaluator.proto. With the proto file moved to proto/, running make will fail to find the source. The COMPILED_PROTO variable, the -I include path, the --go_out/--go-grpc_out paths, and the final protoc argument all need to point to proto/.
$(COMPILED_PROTO): proto/evaluator.proto
	protoc \
	  -I /usr/local/include/google/protobuf \
	  -I ./evaluator \
	  --go_out=./evaluator --go_opt=paths=source_relative \
	  --go-grpc_out=./evaluator --go-grpc_opt=paths=source_relative \
	  ./evaluator/evaluator.proto 

func/evaluator/podcachemanager.go:296

  • spec.PodExecutor.Tags[0] will panic if Tags is empty. The previous code (removed) gated this with len(entry.Spec.PodExecutor.Tags) > 0. Furthermore, IterPodConfigSpecs iterates over every prefix×tag entry in the cache, so the same spec will be yielded multiple times here, causing redundant warm-up goroutines for the same image. A length check on Tags is required, and the iteration semantics likely need to be reconsidered (e.g. yield each unique image once).

Comment thread controllers/functionconfigs/store.go
Comment thread controllers/main.go Outdated
Comment thread pkg/util/image/types.go Outdated
Comment thread func/types/common_types.go Outdated
Comment thread controllers/functionconfigs/store.go
Comment thread controllers/functionconfigs/store.go Outdated
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Copilot AI review requested due to automatic review settings June 2, 2026 15:02
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 48 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

func/evaluator/podcachemanager.go:291

  • spec.PodExecutor.Tags[0] is indexed without checking len(spec.PodExecutor.Tags), which will panic when a FunctionConfig has a PodExecutor but no tags (allowed by the API comment). Treat an empty tag list as latest (or skip warmup for that entry).
    pkg/engine/builtinruntime.go:54
  • Leftover debug log klog.Infof("????") should be removed (or replaced with a meaningful message). As-is it adds noisy, unhelpful output on parse failures.

Comment thread controllers/functionconfigs/store.go Outdated
Comment on lines +87 to +92
if entry, ok := s.internalCache[spec.Image]; ok && entry.objName != objKey {
return apierrors.NewConflict(
configapi.TypeFunctionConfig.GroupResource(),
client.ObjectKeyFromObject(obj).String(),
pkgerrors.Errorf("Image %q is already configured from object %q", spec.Image, objKey),
)
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Copilot AI review requested due to automatic review settings June 3, 2026 08:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 48 changed files in this pull request and generated 4 comments.

Comment thread pkg/util/image/image.go
Comment on lines +26 to +28
// FindBestSemverMatch selects the cache key whose semver tag best satisfies
// the constraint for the given imageName. It returns the full cache key
// (e.g. "ghcr.io/foo/bar:v1.2.3") of the highest matching version.
Comment thread controllers/functionconfigs/store.go
Comment thread controllers/functionconfigs/store.go
Comment thread controllers/functionconfigs/store.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup go Pull requests that update go code refactoring #b33d8f

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants