Kafka sidecar: a volume mounted at a parent of a run.kafka.tls cert path is wrongly removed from the function container
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
調査の方向性
Start with kafkaSidecarVolumeMounts in pkg/k8s/deployer.go and compare its path matching with findSecretForPath in pkg/keda/kafka_scaling.go. Trace how the selected mounts are passed to excludeVolumeMounts, then run the relevant deployer tests or add a case for a PVC at /data and a Kafka Secret at /data/certs. Done when the PVC remains mounted in the function and only the Secret backing the certificate is moved to the sidecar.
索引モデルが issue の本文から書いたものです。
説明
What happens
When a function consumes from Kafka with TLS (run.kafka.tls.*), the Kafka
runtime sidecar is given the volume mount(s) that back the configured certificate
paths, and those volumes are then excluded from the function (user) container so
the private key never lands in application code's filesystem.
The mount-selection logic over-matches: it keeps every volume mount whose path
is an ancestor directory of a cert path, not just the volume that actually backs
the certificate. If an unrelated volume (a PVC, ConfigMap, emptyDir, or another
Secret) is mounted at a parent directory of a Kafka cert path, that volume is:
- mounted into the sidecar (unnecessary), and
- removed from the function container (by
excludeVolumeMounts, which drops
by volume name).
The function therefore silently loses a volume mount it depends on.
Reproduce
run:
volumes:
- persistentVolumeClaim:
claimName: data-pvc
path: /data
- secret: kafka-cert
path: /data/certs
kafka:
brokers: kafka:9092
topic: orders
consumerGroup: my-func
securityProtocol: SSL
tls:
caCert: /data/certs/ca.crt
Deploy with the raw or keda deployer. The kafka-cert secret at /data/certs
legitimately backs the CA cert, so it is moved to the sidecar. But because
/data (the PVC) is also a parent directory of /data/certs/ca.crt, the PVC mount
is swept into the same set and then excluded from the function container. The
function comes up without /data.
Root cause
kafkaSidecarVolumeMounts in pkg/k8s/deployer.go matches a mount when the cert
path equals the mount path or is nested under it:
for _, vm := range volumeMounts {
mountPath := path.Clean(vm.MountPath)
for _, cp := range certPaths {
if cp == mountPath || strings.HasPrefix(cp, mountPath+"/") {
mounts = append(mounts, vm)
break
}
}
}
This has two problems:
- It considers all volume types, not only Secrets. A Kafka TLS certificate can
only come from a Secret, so a PVC/ConfigMap/emptyDir at an ancestor path should
never be treated as backing the cert. - It keeps every ancestor mount rather than the single most-specific (longest
mount path) one that actually provides the file.
The sibling resolver on the keda path, findSecretForPath
(pkg/keda/kafka_scaling.go), already skips non-Secret volumes
(if v.Secret == nil || v.Path == nil { continue }), so the KEDA
TriggerAuthentication wiring resolves the correct secret in this scenario. The
two code paths are not actually at parity even though the comment on
kafkaSidecarVolumeMounts says they use "the same path-to-volume matching."
Impact
- Silent: no error; the function just comes up missing a volume, which typically
surfaces later as a confusing runtime failure. - Scope: only functions that both (a) configure
run.kafka.tls.*and (b) mount an
unrelated volume at a parent directory of a cert path. Mounting the cert Secret
at a path that is not nested under another volume avoids it.
Workaround
Mount the Kafka TLS Secret at a path that is not nested under another volume's
mount path (e.g. /etc/kafka/certs instead of /data/certs when /data is a
PVC).
Suggested fix
Make kafkaSidecarVolumeMounts mirror findSecretForPath: only consider Secret
volumes as cert backers, and select the single most-specific matching mount (or
resolve the exact backing Secret via findSecretForPath and mount only that
volume into the sidecar). That keeps the sidecar/user-container split correct and
brings the two code paths genuinely into parity.
Follow-up to #4060 (language-agnostic Kafka runtime sidecar).
/kind bug
- 主要言語
- Go
- スター
- 366
- フォーク
- 226
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 24
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
knative/func のほかの issue
-
KEDA deployer: default minReplicaCount prevents scale-to-zero対応中かも @Tushar-Khandelwal-2004 が 114 日前に担当しました。 オープンlifecycle/stale
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
knative/func#3924 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
git/gitlab: default project webhooks to SSL verification when creating hooks対応中かも @Vi-shub が 161 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
mcp: config add/remove handlers bypass readonly guard対応中かも @Elvand-Lie が 163 日前に担当しました。 オープンkind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
knative/func#3704 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
kind/documentation
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
kind/cleanup
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
praetorianer777/Dynamo#53 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
kind/engineering pulumi/pulumi-terraform Task Workflow Failure
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
pulumi/pulumi-terraform#1261 ·
メンテナーはふだん 1 日以内に返信
-
Controllers integration tests fail when port 8080 is in use対応中かも @noahnut が今日担当しました。 オープンarea/cluster-autoscaler kind/bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
kubernetes-sigs/cluster-autoscaler#236 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信