Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

--node-affinity panics without Type and wipes existing affinity settings

オープン 初心者向け
#2,278 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@NopeCharon がすでに取り組んでいます。

2026年10月28日 から。

  • #2280 @NopeCharon による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go, kubernetes
領域
cli

調査の方向性

pkg/flags/podspec_helper.go の UpdateNodeAffinity から始め、Type をどのように解析し、spec.Affinity を更新するかを追ってください。近くにあるテストで、型がない場合と既存の affinity 条件を確認してください。型がない場合に Required | Preferred を列挙するエラーが返され、項を追加しても他の affinity 設定が保持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Bug report

--node-affinity (UpdateNodeAffinity in pkg/flags/podspec_helper.go) has two problems:

  1. When no Type= is given, kn panics with a nil pointer dereference instead of reporting an error, because spec.Affinity is only initialized inside the Type branches:

    $ kn service create foo --image gcr.io/knative-samples/helloworld-go --node-affinity Key=topology.kubernetes.io/zone,Operator=In,Values=antarctica-east1
    panic: runtime error: invalid memory address or nil pointer dereference
    
  2. When the requested clause (Required or Preferred) doesn't exist on the service yet, the whole spec.Affinity is replaced by a new empty object. This silently deletes everything else in it: the other node affinity clause and any podAffinity / podAntiAffinity. For example, adding a Preferred term to a service with a Required term removes the Required term.

Expected behavior
  1. A missing type is reported as an error listing the valid values (Required | Preferred).
  2. The new term is added to the requested clause and all other affinity settings of the service are kept.
Steps to reproduce the problem

With the node affinity feature flag enabled in Knative Serving:

kn service create foo --image gcr.io/knative-samples/helloworld-go \
  --node-affinity Type=Required,Key=topology.kubernetes.io/zone,Operator=In,Values=antarctica-east1
kn service update foo \
  --node-affinity Type=Preferred,Key=disktype,Operator=In,Values=ssd,Weight=1
kn service describe foo -o yaml   # requiredDuringSchedulingIgnoredDuringExecution is gone
kn version
main (f2bfc7f3)
Knative (serving/eventing) version

Nightly

主要言語
Go
スター
387
フォーク
278
平均マージ
3日 21時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

knative/client のほかの issue

knative/client の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。