Registry Mirror
Skip to content

Conversation

@gauron99

@gauron99 gauron99 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

func logs now prints the logs of functions deployed with the raw and keda deployers, not only Knative ones.
It prints the function's own container by default; --container kafka-runtime prints the Kafka sidecar's logs instead.

Before (main)

func-logs-before

After (this PR)

func-logs-after

Reproduce

On a cluster with func's local registry (e.g. hack/cluster.sh):

# A function deployed with the raw deployer
func create -l go fn-raw
func deploy --path fn-raw --deployer raw --builder host \
  --registry registry.localtest.me/func --registry-insecure
func logs --path fn-raw
# main:    Error: 'func logs' is not yet supported for the "raw" deployer.
# this PR: the function's logs

# A function that consumes from Kafka (any broker the cluster can reach)
func create -l go -t cloudevents fn-kafka
cat >> fn-kafka/func.yaml <<EOF
run:
  kafka:
    brokers: <broker>:9092
    topic: <topic>
EOF
func deploy --path fn-kafka --deployer raw --builder host \
  --registry registry.localtest.me/func --registry-insecure
func logs --path fn-kafka                            # the function's logs, no sidecar lines
func logs --path fn-kafka --container kafka-runtime  # the sidecar's logs (main: unknown flag: --container)

With KEDA installed, --deployer keda gives the same pod: keda deploys through the raw deployer.

Follows #3850, which #3851 closed by adding the error above rather than support.

func logs reads the logs of functions deployed with the raw and keda
deployers. Their pods carry no Knative service label, so each deployer
gets its own pod selector: Knative pods by serving.knative.dev/service,
raw and keda pods by the boson.dev/function and
function.knative.dev/name labels the raw deployer puts on them. Keda
deploys through the raw deployer, so the two share one selector. The
instructions the MCP server sends its clients say so too.

A function which consumes from Kafka runs the kafka-runtime sidecar
beside user-container. func logs prints user-container by default, and
the new --container flag ($FUNC_CONTAINER), named as in kubectl logs,
picks another, as in func logs --container kafka-runtime. The e2e and
integration tests no longer set FUNC_CONTAINER=false: no command has
read it since func run lost its --container flag, and func logs would.

When pods match but none runs a container of the asked name, func logs
names the containers they do run, rather than suggest the function
scaled to zero or, with --follow, wait for logs which never come.
@knative-prow

knative-prow Bot commented Nov 26, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow Bot added the do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. label Nov 26, 2026
@knative-prow

knative-prow Bot commented Nov 26, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved 🤖 PR has been approved by an approver from all required OWNERS files. label Nov 26, 2026
@knative-prow knative-prow Bot added the size/L 🤖 PR changes 100-499 lines, ignoring generated files. label Nov 26, 2026
@gauron99
gauron99 requested a balanced review from Copilot and removed request for dsimansk and jrangelramos November 26, 2026 20:36

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

Active issues allow inherited FUNC_CONTAINER values to redirect or break MCP logs and cause sidecar log following to exit prematurely during rollouts.

2 open issues
What changed in this PR

Extends func logs to raw and KEDA deployments through shared Kubernetes log collection, while retaining Knative support and defaulting to the function’s own container.

Changes:

  • Select pods according to the function’s deployer.
  • Add --container selection and missing-container diagnostics.
  • Expand tests and documentation, and remove shared FUNC_CONTAINER=false test defaults.
File Description
pkg/​mcp/​instructions.md Document supported deployers and container scope.
pkg/​knative/​logs.go Extract a reusable Knative pod selector.
pkg/​k8s/​logs.go Add raw/KEDA pod selection and container validation.
pkg/​k8s/​logs_test.go Cover selectors, sidecar logs, and missing containers.
pkg/​functions/​client_int_test.go Remove the shared container environment default.
e2e/​e2e_test.go Remove the shared container environment default.
docs/​reference/​func_logs.md Document container selection and sidecar examples.
cmd/​logs.go Route requests by deployer and expose container selection.
cmd/​logs_test.go Cover deployer routing, container options, and environment overrides.

Review effort: Balanced

Comment thread cmd/logs.go
Since: viper.GetString("since"),
Tail: viper.GetInt64("tail"),
Follow: viper.GetBool("follow"),
Container: viper.GetString("container"),
Comment thread pkg/k8s/logs.go
Comment on lines +197 to +198
if err = checkContainer(list.Items, opts.Container); err != nil {
return err
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants