Adoption deletes the legacy cluster-state ConfigMap but leaves Pods referencing it, and neither self-heal path detects the result
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- go, kubernetes
- 領域
- devops, infrastructure
調査の方向性
Start in internal/migrate/adopt.go, where the legacy ConfigMap is deleted during in-place adoption, then check where etcdContainerStuck and ensurePod read container state. Done means adopted Pods no longer reference a deleted ConfigMap, or a container waiting with a config error is detected and surfaced. The issue does not settle which fix to take, so confirm the approach with maintainers before writing code.
索引モデルが issue の本文から書いたものです。
説明
What happens
In-place adoption deletes the legacy cluster-state ConfigMap while leaving the running Pods untouched. Those Pods reference that ConfigMap through envFrom, and a Pod spec cannot be edited in place. The cluster therefore keeps running normally until something recreates the container, at which point the Pod fails with CreateContainerConfigError: configmap "etcd-cluster-state" not found and never starts again.
The gap between adoption and the failure can be weeks. On the cluster where I hit this it was 21 days, and it surfaced as two tenant control planes going down at once with no change having been made that day.
internal/migrate/adopt.go:
// ConfigMapName is the legacy cluster-state ConfigMap to delete.
ConfigMapName string
...
plan.Adoption.ConfigMapName = LegacyStateConfigMapName(name)
and the note a few lines further down:
in-place adoption: the etcd pods and their PVCs stay exactly as they are;
only ownership, labels and member annotations change
Both halves are true, and together they leave every adopted Pod holding a reference to an object that adoption itself removed.
Why neither self-heal path catches it
This is the part that turns a restart into a permanent outage.
etcdContainerStuck requires restarts:
if cs.Ready || cs.RestartCount < dataLossRestartThreshold { // threshold = 5
return false
}
CreateContainerConfigError means the container was never created, so RestartCount stays at 0 forever. The counter never reaches the threshold.
The terminal-Pod path added in #370 does not fire either: the Pod phase is Running, only the container is stuck in waiting. So the affected Pods sit in 0/1 CreateContainerConfigError with RESTARTS = 0 indefinitely, and ensurePod treats them as healthy because the Pod object exists:
err := r.Get(ctx, ..., pod)
if err == nil {
// records status, reconciles the role label, returns
return nil
}
Observed state on three tenants:
NAME READY STATUS RESTARTS AGE
etcd-0 0/1 CreateContainerConfigError 0 21d
etcd-1 0/1 CreateContainerConfigError 0 21d
etcd-2 0/1 CreateContainerConfigError 0 21d
Meanwhile the EtcdCluster CR reported Available=True QuorumAvailable: 2/3 members ready, which did not match reality.
Impact
Every cluster that went through adoption carries this. It is invisible while the containers keep running, and it detonates on the next node reboot, eviction, or kubelet restart. On a platform where each tenant control plane has its own etcd, one node reboot can take out several tenants at once, and none of them recover on their own.
Half the tenants on my cluster had already failed this way; the rest were healthy only because their containers had not restarted since adoption.
Workaround
Delete the Pod. ensurePod then takes the IsNotFound branch and rebuilds it from buildPod, which carries no envFrom, resumes the existing data directory via the data-dir-subpath annotation, and passes --initial-cluster-state=existing. Data is preserved: the replacement came back reading raft index 8743018.
On a healthy cluster this has to be done one member at a time, checking quorum between each.
Suggested fix
Either of these closes the hole; the first is the real fix and the second is worth having anyway.
- Do not leave Pods referencing a deleted object. Adoption could drop the
envFromreference as part of the ownership rewrite, or recreate the Pods itself, or keep the ConfigMap until every Pod referencing it has been replaced. - Make self-heal see a container that cannot be created. A container stuck in
waitingwith a config-related reason andRestartCount == 0is currently invisible to both paths, even though it is more clearly unrecoverable than a crash loop.
Related, same area, different trigger: #368, #370, #372.
- 主要言語
- Go
- スター
- 154
- フォーク
- 31
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cozystack/etcd-operator のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
cozystack/etcd-operator#385 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
cozystack/etcd-operator#383 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
cozystack/etcd-operator#381 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
cozystack/etcd-operator#374 · コメント 1 件 ·
-
bugfix controllers
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
cozystack/etcd-operator#372 ·
cozystack/etcd-operator の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Correct local module testing instructions for Go sample contributors対応中かも @slievrly が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
internal/core: cleanAttachmentName splits a rune at the 255-byte cap and stores invalid UTF-8対応中かも @pacwestnobody が今日担当しました。 オープンgo good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Podiom/Podiom#427 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
TestLaunchGolden spends about 98 seconds on fake-agent exit delays under -race対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
factory:subtask
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 1 日以内に返信