Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#2,278 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@NopeCharon ci sta già lavorando.

Dal 28/10/2026.

  • #2280 di @NopeCharon — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, kubernetes
Ambito
cli

Direzione di ricerca

Inizia da UpdateNodeAffinity in pkg/flags/podspec_helper.go e segui come analizza Type e aggiorna spec.Affinity. Controlla i test vicini per i tipi mancanti e le clausole di affinity esistenti. Il lavoro è completato quando un tipo mancante restituisce un errore che elenca Required | Preferred e l’aggiunta di un termine conserva le altre impostazioni di affinity.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Go
Stelle
387
Fork
278
Merge medio
3g 21h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di knative/client

Tutte le issue di knative/client

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.