-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tidb-operator unable to recover an unhealthy cluster even with manual revert #4946
Comments
hi, you can first scale-in tidb to replica:2, let cluster become normal, then operator can proceed the sync logic, after changing the affinity rules, you can scale-out back tidb-2 if you want. |
Thanks @yiduoyunQ for the suggestion! |
hi hoyhbx, this error message is reported from https://github.com/pingcap/tidb-operator/blob/v1.4.4/pkg/manager/member/tidb_upgrader.go#L123-L133, it block Operator continue do Current Operator sync logic is sync each component type one by one in an order, so we need one determinate condition to check if it can continue sync the next component, the component pod's status is used here in For example if we change the pod's status check after What do you think about this? |
if we already in the clear upgrade logic https://github.com/pingcap/tidb-operator/blob/v1.4.4/pkg/manager/member/tidb_member_manager.go#L305 , do we still need check the pod's status? or we can just let it start upgrade. @hanlins |
Yeah I think it is a good practice to wait for the component to get ready and then apply next upgrade. The operator is doing a good job here.
I think the status of the Pod may contain some more useful information to distinguish the two cases. For example, if the Pod has been in |
yes. If we want to apply the next upgrade, we must tell every unhealthy case whether it's safe to process. |
@csuzhangxc Do you think this would be a feature request for the statefulSet controller? Having a field in statefulSet status would greatly help operators to recognize failed upgrade |
Yes, this may be helpful. |
@yiduoyunQ @csuzhangxc Can we have an intermediate fix for this bug before the upstream Kubernetes reacts? We are drafting an issue to send to Kubernetes at the same time. A potential fix for this bug is to recognize the error condition that the cluster is under, and proceed to upgrade the statefulSet if the Pods have been in the error condition for a timeout. The symptom of this bug is that there are some pods in "Pending" state, with error conditions, e.g.: {
"last_probe_time": null,
"last_transition_time": "2023-04-02T12:10:37+00:00",
"message": "0/4 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate, 3 node(s) didn't match Pod's node affinity/selector.",
"reason": "Unschedulable",
"status": "False",
"type": "PodScheduled"
} Note that the condition has the We propose to add a condition branch at tidb-operator/pkg/manager/member/tidb_upgrader.go Lines 123 to 133 in 4b1c55c
last_transition_time field in conditions). If the previous upgrade has failed, the operator can proceed to next upgrade. The timeout can be set with conservatively large number, or be a field in the CRD so users can configure.
|
@hoyhbx this is something like a force upgrade, right? I think adding a new field may be better and wouldn't break the existing behavior. And may need to address which conditions this behavior will take effect. |
@csuzhangxc , yes, a feature like |
Bug Report
What version of Kubernetes are you using?
What version of TiDB Operator are you using?
pingcap/tidb-operator:v1.3.2
What storage classes exist in the Kubernetes cluster and what are used for PD/TiKV pods?
default
What's the status of the TiDB cluster pods?
What did you do?
We first have a healthy tidb cluster.
Then we changed the affinity rule for scheduling the tidb pods. The tidb statefulset is updated with the new affinity rule and performed a rolling upgrade. Then we realized that the new affinity rule cannot be satisfied for the current topology of the cluster, there is always one replica cannot be scheduled.
We then reverted the CR, to remove the new affinity rule.
But then the operator fails to update the tidb statefulset, leaving the cluster under unhealthy state.
What did you expect to see?
tidb-operator should be able to recover the cluster, with manual revert.
What did you see instead?
tidb-operator refuses to update the statefulset, before all replicas in the cluster become ready.
The log indicating this behavior is
tidb_cluster_controller.go:124] TidbCluster: default/test-cluster, still need sync: tidbcluster: [default/test-cluster]'s upgraded tidb pod: [test-cluster-tidb-2] is not ready, requeuing
The text was updated successfully, but these errors were encountered: