-
Notifications
You must be signed in to change notification settings - Fork 716
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
Kubeadm upgrade stuck in "Static pod: etcd-xxxx hash: xxxx" occasionally #2877
Comments
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/sig Cluster-Lifecycle |
/area kubeadm At my first glance, to patch etcd manifest, you may try the #2046 --patch feature. I need to dig into this later. |
so when comparing yaml, we should also use DeepHashObject? this seems like a bug.
i don't understand why it would happen occasionally and not always thought? |
Totally agree with this, seems to be the most reasonable solution.
In our case, if the new yaml file has the same order with the old one, this process would be skipped since ManifestFilesAreEqual returns true. And the annotation fileds order is random since its a map. |
ok, PRs welcome with a fix. we can backport this bugfix as blocking for upgrades in older versions too. |
What happened?
We encountered this error when running kubeadm upgrade apply, the logs of kubeadm printed "Static pod: etcd-xxxx hash: xxxx" repeatedly till timeout.
What did you expect to happen?
We were trying to keep some of the modifications in static pods' yaml while upgrading k8s. Our strategy is:
We suppose that these operations should work.
How can we reproduce it (as minimally and precisely as possible)?
If the order of a map's fields are different between current static pods' yaml and the diff patch files, the problem will occur. e.g. if current etcd yaml has some annotations like:
metadata:
annotations:
field1: foo1
field2: foo2
and the patch file we created is:
metadata:
annotations:
field2: foo2
field1: foo1
the upgrade will stuck and failed.
Anything else we need to know?
Since map is unordered in golang, we didn't expected this behavior of kubeadm.
By looking into the source code of kubeadm, we found the possible cause of this behavior, the current procedures of kubeadm upgrading static pods are as below(using etcd as an example):
The problem of this process is, kubeadm uses DeepHashObject in pkg/util/hash to generate hash code, this hash method will sort the fileds, which means the two yaml files like above will leads to a same hash code. Meanwhile, when compare yaml files, kubeadm simply comprares the files' bytes instead, see in: https://github.com/kubernetes/kubernetes/blob/bc41f37e85dd67ddb69eaa9e4da530c3c72101d7/cmd/kubeadm/app/util/staticpod/utils.go#L352
In this case, kubeadm will replace the new yaml file to /etc/kubernetes/manifests, but the hash code of the pod won't make any difference.
Kubernetes version
Cloud provider
OS version
Install tools
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, ...) and versions (if applicable)
The text was updated successfully, but these errors were encountered: