{
  "id": "kubernetes/helm-upgrade-failed-dry-run",
  "signature": "Error: UPGRADE FAILED: cannot patch \"my-release\" with kind Deployment: Deployment.apps \"my-release\" is invalid: spec.selector: Invalid value: v1.LabelSelector{...}: field is immutable",
  "signature_zh": "错误：升级失败：无法修补 \"my-release\"（类型 Deployment）：Deployment.apps \"my-release\" 无效：spec.selector：无效值：v1.LabelSelector{...}：字段不可变",
  "regex": "Error: UPGRADE FAILED: cannot patch.*with kind Deployment.*field is immutable",
  "domain": "kubernetes",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A Helm upgrade attempts to modify an immutable field (e.g., spec.selector) on an existing Deployment, which is not allowed by the Kubernetes API.",
  "root_cause_type": "generic",
  "root_cause_zh": "Helm 升级尝试修改现有 Deployment 上的不可变字段（例如 spec.selector），这是 Kubernetes API 不允许的。",
  "versions": [
    {
      "version": "helm 3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "kubernetes 1.27",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "helm 3.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The --force flag in Helm only recreates resources if the release name changes, but does not bypass immutable field validation on existing resources.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Editing the selector after creation is also rejected by the API; the field is immutable for all operations.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The old Deployment persists and still has the immutable field; Helm will try to patch it again.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Run `kubectl delete deployment my-release` to remove the Deployment, then perform `helm upgrade --install my-release ./chart` to recreate it with the new selector.",
      "success_rate": 0.95,
      "how": "Run `kubectl delete deployment my-release` to remove the Deployment, then perform `helm upgrade --install my-release ./chart` to recreate it with the new selector.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the selector change is unintended, rollback: `helm rollback my-release <revision>` to a version before the change, then modify the chart to avoid immutable field changes.",
      "success_rate": 0.85,
      "how": "If the selector change is unintended, rollback: `helm rollback my-release <revision>` to a version before the change, then modify the chart to avoid immutable field changes.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "运行 `kubectl delete deployment my-release` 删除 Deployment，然后执行 `helm upgrade --install my-release ./chart` 使用新选择器重新创建。",
    "如果选择器更改是意外的，回滚：`helm rollback my-release <revision>` 到更改前的版本，然后修改 chart 以避免不可变字段更改。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://helm.sh/docs/helm/helm_upgrade/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}