Skip to content
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

Fix panic in kubeadm master node setup #44143

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmd/kubeadm/app/phases/apiconfig/setupmaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ func attemptToUpdateMasterRoleLabelsAndTaints(client *clientset.Clientset) error
wait.PollInfinite(kubeadmconstants.APICallRetryInterval, func() (bool, error) {
var err error
if n, err = client.Nodes().Get(node.GetHostname(""), metav1.GetOptions{}); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my fault - err != nil is there incorrect. We are ending this loop on err.

Also test for Labels == nil should be there, because it can nil because it's declared as omitempty, so can be unmarshaled possibly to nil.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't the error being logged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point an error is expected to happen several times (IIUC both apiserver can be available and node not registered yet)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could still log it of course using higher verbosity level, it may aid debugging in case if the request never succeeds...

return true, nil
return false, nil
}
return false, nil
// The node may appear to have no labels at first,
// so we wait for it to get hostname label.
_, found := n.ObjectMeta.Labels[metav1.LabelHostname]
return found, nil
})

oldData, err := json.Marshal(n)
Expand Down