Chunked secrets storage leaks a goroutine on every failed release decode

Aperta Adatta ai principianti
#572 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

@RaphaelFakhri ci sta già lavorando.

Dal 5/11/2026.

  • #573 di @RaphaelFakhri — 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
Ambito
backend

Direzione di ricerca

Inizia in pkg/storage/chunked.go, in corrispondenza di chunkedSecrets.decodeRelease, e segui come vengono gestiti il lettore e lo scrittore di io.Pipe quando la decodifica gzip o JSON non riesce. Riproduci il problema con i dati chunk non validi descritti nei passaggi, quindi verifica che le chiamate ripetute a Get che falliscono non aumentino più il numero di goroutine e continuino a restituire l’errore gzip previsto.

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

Descrizione

chunkedSecrets.decodeRelease in pkg/storage/chunked.go starts a goroutine that writes the chunk data into an io.Pipe, and it reads the other end with gzip.NewReader and json.Decoder. The read side of the pipe is never closed. When decoding returns an error before all of the data has been read, the writer goroutine blocks on pw.Write forever and holds a reference to the secret data.

The leak happens whenever decoding fails before the writer finishes, for example because the gzip header is invalid or the JSON payload can't be decoded due to a corrupt or truncated chunk. Each failed Get, List, or Query leaks one goroutine, so an operator that keeps reconciling an affected release leaks a goroutine on every attempt.

Steps to reproduce

  1. Create an index secret with invalid chunk data that is larger than the gzip reader's buffer:

    sec := &corev1.Secret{
        ObjectMeta: metav1.ObjectMeta{Name: "bad.v1"},
        Type:       storage.SecretTypeChunkedIndex,
        Data: map[string][]byte{
            "extraChunks": []byte("[]"),
            "chunk":       make([]byte, 10000),
        },
    }
    
  2. Call Get("bad.v1") on a driver created with storage.NewChunkedSecrets 20 times.

  3. Compare runtime.NumGoroutine() before and after.

Expected behavior

Each call returns failed to create gzip reader: gzip: invalid header, and the goroutine count stays the same.

Actual behavior

Each call returns the error, but the goroutine count goes up by one for every call (13 before, 33 after 20 calls). The leaked goroutines are blocked in (*chunkedSecrets).decodeRelease.func1 on pw.Write.

Successful decodes don't leak.

Lingua principale
Go
Stelle
59
Fork
54
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

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 operator-framework/helm-operator-plugins

Tutte le issue di operator-framework/helm-operator-plugins

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.