Skip to content

Allow tag constraints in FunctionConfig CRs - #1186

Open
mozesl-nokia wants to merge 6 commits into
kptdev:mainfrom
nokia:fnconf-tag-constraints
Open

mozesl-nokia wants to merge 6 commits into
kptdev:mainfrom
nokia:fnconf-tag-constraints

Conversation

@mozesl-nokia

Copy link
Copy Markdown
Contributor

Allow tag constrains in FunctionConfig CRs


Description

  • What changed: The tag lists in FunctionConfigs are now treated as constraints
  • Why it’s needed: To more easily specify version ranges to apply configs for
  • How it works: The entries in the lists are treated as semver constraints and requested images are appropriately matched against them.

Related Issue(s)


Type of Change

  • New feature
  • Enhancement
  • Refactor
  • Documentation

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: Cache warmup is skipped for semver constraint tags
  • Further improvements: ^^^ Cache warmup should use an image matching the constraint

AI Disclosure

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

If so, please describe how:

  • Cursor's Grok 4.6 was used to make the changes compatible with main

mozesl-nokia and others added 3 commits September 17, 2026 13:08
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Co-authored-by: Daniel Gyorgy <daniel.gyorgy@nokia.com>
Assisted-by: Cursor:grok-4.6
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Assisted-by: Cursor:grok-4.6
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@mozesl-nokia
mozesl-nokia requested review from a team September 17, 2026 12:45
@netlify

netlify Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kpt-porch ready!

Name Link
🔨 Latest commit 862f917
🔍 Latest deploy log https://app.netlify.com/projects/kpt-porch/deploys/6aacfb32c7133e000828434a
😎 Deploy Preview https://deploy-preview-1186--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.

🟡 Changes recommended

Unresolved semver matching, cache preloading, pod constraint, warmup, and ordering issues remain.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR adds semver constraint support for FunctionConfig tags, updating executor matching, defaults, documentation, and tests.

Changes:

  • Adds semver validation, normalization, and matching.
  • Applies constraints to Go, binary, and pod execution.
  • Updates manifests, API/CRD documentation, and test coverage.
File summaries
File Summary
test/e2e/crd/function_config_test.go Adds semver constraint e2e coverage.
pkg/util/image/image.go Adds constraint matching; critical unresolved range-overlap matching issue remains.
pkg/util/image/image_test.go Adds image constraint matching tests.
pkg/engine/builtinruntime.go Uses constraint-aware Go executor matching.
func/internal/podcachemanager.go Applies constraints to pod settings and warmup; unresolved out-of-range overrides and latest warmup issues remain.
func/internal/podcachemanager_unit_test.go Tests constrained pod settings.
func/internal/executableevaluator_test.go Updates binary cache test setup.
docs/content/en/docs/6_configuration_and_deployments/configurations/components/function-runner-config/function-configuration.md Expands constraint configuration guidance.
docs/content/en/docs/5_architecture_and_components/function-runner/interactions.md Documents constraint lookup behavior.
docs/content/en/docs/5_architecture_and_components/function-runner/functionality/function-evaluation.md Documents executor constraints.
docs/content/en/docs/2_concepts/functions.md Updates FunctionConfig examples.
deployments/porch/23-function-configurations.yaml Converts default tags to semver ranges.
controllers/main.go Updates cache prepopulation; invalid tags are not validated on startup.
controllers/functionconfigs/functionconfigreconciler.go Validates and normalizes constraints; deduplication does not preserve first-item order.
controllers/functionconfigs/functionconfigreconciler_test.go Tests validation, normalization, and cache matching.
api/porchconfig/v1alpha1/function_config_types.go Updates FunctionConfig tag documentation.
api/generated/crds/config.porch.kpt.dev_functionconfigs.yaml Updates generated CRD descriptions.
Review details

Suppressed comments (2)

controllers/main.go:354

  • FunctionConfigs are preloaded into the live caches before informer reconciliation, but this path never runs the new semver validation. An invalid tags value can therefore be served after every restart even though Reconcile would reject it, and the invalid cache entry is not removed by that error path. Validate/normalize before prepopulation or skip invalid objects.
			store.UpdateBinaryCache(&obj.Spec)

func/internal/podcachemanager.go:263

  • This condition only makes TTL/queue/max-pod lookups fall back when the image is outside the PodExecutor constraints; the request path still fetches and passes this same PodExecutor to getFuncEvalPodClient, so CreatePod applies its templateOverrides (including service account, security context, and resources) to out-of-range images. Select the PodExecutor only when parsed.Tag satisfies its tags, otherwise pass nil/default configuration so all PodExecutor settings obey the constraint.
	entry, ok := pcm.functionConfigMap.GetFunctionConfig(parsed.BaseName)
	if !ok || entry.Spec.PodExecutor == nil || !imageutil.MatchesAnyConstraint(parsed.Tag, entry.Spec.PodExecutor.Tags) {
		return pcm.podTTL, pcm.maxWaitlistLength, pcm.maxParallelPodsPerFunction
  • Files reviewed: 16/17 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/util/image/image.go
Comment on lines +58 to +63
func MatchesConfigTags(request string, tags []string) bool {
if MatchesAnyConstraint(request, tags) {
return true
}
_, err := FindBestSemverMatch(request, tags)
return err == nil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This looks quite hard to solve without support from the semver lib. They have several PRs for this, some of which have been waiting for years for review...

Comment thread controllers/functionconfigs/functionconfigreconciler.go Outdated
Comment on lines +376 to +382
tag := entry.Spec.PodExecutor.Tags[0]
if tag != "" && tag != "*" {
if _, err := semver.NewVersion(tag); err != nil {
klog.V(3).Infof("Skipping warmup for %q: Tags[0]=%q is a semver constraint, not a concrete version", entry.Spec.Image, tag)
continue
}
image = fmt.Sprintf("%s:%s", entry.Spec.Image, tag)
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>
@mozesl-nokia

Copy link
Copy Markdown
Contributor Author

It may be a good idea to get kptdev/kpt#4636 merged first, and the we could use the regclient lister here for the pod cache warmup

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@sonarqubecloud

Copy link
Copy Markdown

@mozesl-nokia mozesl-nokia changed the title Allow tag constrains in FunctionConfig CRs Allow tag constraints in FunctionConfig CRs Sep 23, 2026
@mozesl-nokia

Copy link
Copy Markdown
Contributor Author

Considering the scope of what I will need to do to make cache warmup work here, I think I will wait until #1119 is merged.

@mozesl-nokia mozesl-nokia added documentation Improvements or additions to documentation enhancement New feature or request go Pull requests that update go code refactoring #b33d8f size:XL This PR changes 500-999 lines, ignoring generated files. do-not-merge/hold #ededed labels Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold #ededed documentation Improvements or additions to documentation enhancement New feature or request go Pull requests that update go code refactoring #b33d8f size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants