Skip to content

Have function-runner output include image version tags in output#4421

Open
JamesMcDermott wants to merge 12 commits intokptdev:mainfrom
Nordix:cli-print-function-versions
Open

Have function-runner output include image version tags in output#4421
JamesMcDermott wants to merge 12 commits intokptdev:mainfrom
Nordix:cli-print-function-versions

Conversation

@JamesMcDermott
Copy link

@JamesMcDermott JamesMcDermott commented Mar 3, 2026

Changes:

  • Update function-runner so that printed output lines, containing the function image names executed, also include image version tags:
    • before running ("[RUNNING]" lines)
      • update runner.go so the display name in the printed output appends the function image's tag attribute (replacing any tag in the existing image attribute), OR leaves an existing tag in the image attribute if no tag attribute, OR defaults to "latest", in that order of preference
      • as per comment chain Have function-runner output include image version tags in output #4421 (comment), we're instead refactoring to resolve the image before running (at the point of function creation in runner.go). This allows the exact image version tag to be included in "[RUNNING]" lines as well
    • after success/failure ("[PASS]" or "[FAIL]" lines)
      • update container.go to replace the display name in the printed output with the resolved image that was run, whether successfully or not
        • we replace the display name entirely because, with the introduction of semantic versioning constraint functionality the image that was actually resolved may differ significantly from the text provided in the tag attribute

Motivation:

When using the tag attribute (with or without a semantic version constraint) or when no version tag is included in either tag or image (defaulting to "latest"), function pipeline output does not usually include the version tag of the executed image.

Fixes: #4410

Copilot AI review requested due to automatic review settings March 3, 2026 13:24
@netlify
Copy link

netlify bot commented Mar 3, 2026

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit cc79c89
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/69aeddc4590bef0008e80e91
😎 Deploy Preview https://deploy-preview-4421--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. area/fn-runtime KRM function runtime labels Mar 3, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the function-runner’s CLI output so that function image names shown in [RUNNING], [PASS], and [FAIL] lines include version tag information (including semver constraints and latest defaults), improving observability when tag is used or when tags are implicit.

Changes:

  • Add Tag metadata to function results and use it to construct [RUNNING] display names with the right tag/constraint (defaulting to latest when needed).
  • Update container execution to overwrite the displayed image on completion with the resolved image actually executed (important for semver constraints).
  • Add unit test coverage for display-name construction and new e2e golden tests validating printed output.

Reviewed changes

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

Show a summary per file
File Description
pkg/api/fnresult/v1/types.go Adds Tag field to structured function result metadata.
internal/fnruntime/runner.go Builds [RUNNING] display names including tag/constraint and updates name post-run to use resolved image.
internal/fnruntime/container.go Updates FnResult.Image to the resolved image (or :latest when implicit) to drive [PASS]/[FAIL] output.
internal/fnruntime/runner_test.go Adds table-driven tests for function image display-name construction.
e2e/testdata/fn-render/fn-failure-print-fn-version/starlark-failure-fn.yaml Adds failing starlark config to validate [FAIL] output includes resolved tag.
e2e/testdata/fn-render/fn-failure-print-fn-version/resources.yaml Adds resources for the failure scenario test package.
e2e/testdata/fn-render/fn-failure-print-fn-version/deployment_httpbin.yaml Adds additional resource input for the failure scenario.
e2e/testdata/fn-render/fn-failure-print-fn-version/Kptfile Defines a pipeline using tag so output must show constraint and resolved version.
e2e/testdata/fn-render/fn-failure-print-fn-version/.krmignore Excludes .expected from function input processing.
e2e/testdata/fn-render/fn-failure-print-fn-version/.expected/config.yaml Golden output asserting [RUNNING] shows constraint and [FAIL] shows resolved tag.
e2e/testdata/fn-render/basicpipeline-print-fn-versions/resources.yaml Adds resources for the “basicpipeline” tag-printing scenario.
e2e/testdata/fn-render/basicpipeline-print-fn-versions/Kptfile Exercises multiple tag cases: implicit latest, explicit tag, and semver constraints.
e2e/testdata/fn-render/basicpipeline-print-fn-versions/.krmignore Excludes .expected from function input processing.
e2e/testdata/fn-render/basicpipeline-print-fn-versions/.expected/diff.patch Golden diff output for resource mutations in the basic pipeline.
e2e/testdata/fn-render/basicpipeline-print-fn-versions/.expected/config.yaml Golden stderr output asserting tag/constraint printing behavior across cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JamesMcDermott JamesMcDermott force-pushed the cli-print-function-versions branch from fee7097 to bfcda2c Compare March 3, 2026 13:33
Copilot AI review requested due to automatic review settings March 4, 2026 10:16
Copy link
Contributor

Copilot AI left a comment

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 15 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 4, 2026 14:02
Copy link
Contributor

Copilot AI left a comment

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 19 out of 19 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 4, 2026 17:14
Copy link
Contributor

Copilot AI left a comment

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 20 out of 20 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JamesMcDermott JamesMcDermott force-pushed the cli-print-function-versions branch from 3651d10 to bffca20 Compare March 5, 2026 09:31
}
f.Image, err = tagResolver.ResolveFunctionImage(f.Ctx, f.Image, f.Tag)
if err != nil {
f.FnResult.Image = buildFunctionDisplayName(f.FnResult)
Copy link
Contributor

Choose a reason for hiding this comment

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

For me, I think it would be better if we could get the ACTUAL image being RUN.
We could prob get this from the StdErr in the runCli fn below, the the f.FnResult.Image would display the exact tag/digest.

Copy link
Author

Choose a reason for hiding this comment

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

Not sure that's possible at this point - a few points:

  • Do you mean in this particular block? If we're at this line, we've had an error trying to resolve the Image and Tag (which we didn't know without trying if it had an exact version or SemVer constraint) to an actual image - there's no way to know what the actual image would have been that would have been run if we hadn't errored out. I think giving back the same tag as configured is the best we can do in this situation.
  • Do you mean in the [PASS]/[FAIL] lines after the run? That's already done by line 169 as is - a successful ResolveFunctionImage() call will have updated f.Image to include the exact resolved tag
  • Do you mean in [RUNNING] output lines in general? That's not currently possible because at the point of resolving the actual image, the [RUNNING] line has already been printed, back in FunctionRunner.Filter() in internal/fnruntime/runner.go. The printing there serves double duty for both Image and Exec runs - it'd be a lot of extra work (and repetition in wasm.go and exec.go) to split it out to a point where we can wait to print until we've resolved the actual image.
  • Perhaps a redesign where we pull the use of ResolveFunctionImage() back up to the creation of the ContainerFn f at runner.go line 108? That would probably work, but it seems like it would break the separation of "part where we're setting up and configuring" from "part where we start going on the network and actually running things". Let me know anyway. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

No, doesn't matter where the functionality lives, but just looking at the sample [RUNNING] output in some of the tests, I don't think it's that useful. ie [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:0.4.1 - 0.4.3"
If we can get the exact tag/digest, I think it would be more useful for the user.

Copy link
Author

Choose a reason for hiding this comment

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

Ah - fair enough. Reworked to bring it up to runner.go and added a new line type, [RESOLUTION FAIL].

example:
    Package: "nginx"
    [RUNNING] "ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest"
    [PASS] "ghcr.io/kptdev/krm-functions-catalog/kubeconform:latest" in 2.4s
    Successfully executed 1 function(s) in 1 package(s)

Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
- also linting changes
- also minor AI-suggested refactors for better readbility

Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
- when `tag` present and image resolution errors out, add `tag`
  to printed image name
  - also new e2e test for this specific failure
- reuse pre-run display name building logic

Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
- minor Copilot review comments

Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
- also addresses Copilot comment

Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
- allows us to have exact resolved image version tags
  in [RUNNING] output lines as well as [PASS]/[FAIL]
- add new [RESOLUTION FAIL] line type to account for
  image resolution failure

Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
Copilot AI review requested due to automatic review settings March 9, 2026 10:18
@JamesMcDermott JamesMcDermott force-pushed the cli-print-function-versions branch from bffca20 to 0c54533 Compare March 9, 2026 10:18
Copy link
Contributor

Copilot AI left a comment

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 20 out of 20 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: JamesMcDermott <james.j.mcdermott@ericsson.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/fn-runtime KRM function runtime size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function pipeline output does not show image version tags

3 participants