Chunked secrets storage leaks a goroutine on every failed release decode

未關閉 適合新手
#572 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

@RaphaelFakhri 已經在處理了。

開始於 2026年11月5日。

  • #573 來自 @RaphaelFakhri —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
go
領域
backend

研究方向

從pkg/storage/chunked.go中的chunkedSecrets.decodeRelease開始,追蹤 gzip 或 JSON 解碼失敗時如何處理io.Pipe的 reader 和 writer。使用步驟中描述的無效 chunk 資料重現問題,接著確認重複失敗的Get呼叫不再增加 goroutine 數量,且仍會傳回預期的 gzip 錯誤。

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Go
星號
59
分支
54
PR 合併指標
30 天內沒有已合併 PR

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 沒有貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

operator-framework/helm-operator-plugins 的其他 Issue

查看 operator-framework/helm-operator-plugins 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。