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: config hostname as string type in kubeadmConfig rendering #10997

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

ErikJiang
Copy link
Member

@ErikJiang ErikJiang commented Mar 11, 2024

What type of PR is this?
/kind bug

What this PR does / why we need it:
When rendering the kubeadm configuration file, the hostname may sometimes be a numeric name.
If double quotes are not added, kubeadm init may detect it as a numeric type and throw an error.

Examples of such error messages are as follows:

{
   "attempts":3,
   "changed":true,
   "cmd":[
      "timeout",
      "-k",
      "300s",
      "300s",
      "/usr/local/bin/kubeadm",
      "init",
      "--config=/etc/kubernetes/kubeadm-config.yaml",
      "--ignore-preflight-errors=all",
      "--v=8",
      "--skip-phases=addon/coredns",
      "--upload-certs"
   ],
   "delta":"0:00:01.092516",
   "end":"2024-01-30 21:48:15.252523",
   "failed_when_result":true,
   "msg":"non-zero return code",
   "rc":1,
   "start":"2024-01-30 21:48:14.160007",
   "stderr":"I0130 21:48:14.241241   25813 initconfiguration.go:255] loading configuration from \"/etc/kubernetes/kubeadm-config.yaml\"\nW0130 21:48:14.247196   25813 initconfiguration.go:307] error unmarshaling configuration schema.GroupVersionKind{Group:\"kubeadm.k8s.io\", Version:\"v1beta3\", Kind:\"ClusterConfiguration\"}: json: cannot unmarshal number into Go struct field APIServer.apiServer.certSANs of type string\njson: cannot unmarshal number into Go struct field APIServer.apiServer.certSANs of type string",
   "stderr_lines":[
      "I0130 21:48:14.241241   25813 initconfiguration.go:255] loading configuration from \"/etc/kubernetes/kubeadm-config.yaml\"",
      "W0130 21:48:14.247196   25813 initconfiguration.go:307] error unmarshaling configuration schema.GroupVersionKind{Group:\"kubeadm.k8s.io\", Version:\"v1beta3\", Kind:\"ClusterConfiguration\"}: json: cannot unmarshal number into Go struct field APIServer.apiServer.certSANs of type string",
      "json: cannot unmarshal number into Go struct field APIServer.apiServer.certSANs of type string"
   ],
   "stdout":"",
   "stdout_lines":[
      
   ]
}
{
   "attempts":3,
   "changed":true,
   "cmd":[
      "timeout",
      "-k",
      "300s",
      "300s",
      "/usr/local/bin/kubeadm",
      "init",
      "--config=/etc/kubernetes/kubeadm-config.yaml",
      "--ignore-preflight-errors=all",
      "--skip-phases=addon/coredns",
      "--upload-certs"
   ],
   "delta":"0:00:00.043053",
   "end":"2024-03-06 04:53:59.038113",
   "failed_when_result":true,
   "invocation":{
      "module_args":{
         "_raw_params":"timeout -k 300s 300s /usr/local/bin/kubeadm init --config=/etc/kubernetes/kubeadm-config.yaml --ignore-preflight-errors=all --skip-phases=addon/coredns --upload-certs",
         "_uses_shell":false,
         "argv":null,
         "chdir":null,
         "creates":null,
         "executable":null,
         "removes":null,
         "stdin":null,
         "stdin_add_newline":true,
         "strip_empty_ends":true
      }
   },
   "msg":"non-zero return code",
   "rc":1,
   "start":"2024-03-06 04:53:58.995060",
   "stderr":"W0306 04:53:59.036571   24390 initconfiguration.go:306] error unmarshaling configuration schema.GroupVersionKind{Group:\"kubeadm.k8s.io\", Version:\"v1beta3\", Kind:\"InitConfiguration\"}: json: cannot unmarshal number into Go struct field NodeRegistrationOptions.nodeRegistration.name of type string\njson: cannot unmarshal number into Go struct field NodeRegistrationOptions.nodeRegistration.name of type string\nTo see the stack trace of this error execute with --v=5 or higher",
   "stderr_lines":[
      "W0306 04:53:59.036571   24390 initconfiguration.go:306] error unmarshaling configuration schema.GroupVersionKind{Group:\"kubeadm.k8s.io\", Version:\"v1beta3\", Kind:\"InitConfiguration\"}: json: cannot unmarshal number into Go struct field NodeRegistrationOptions.nodeRegistration.name of type string",
      "json: cannot unmarshal number into Go struct field NodeRegistrationOptions.nodeRegistration.name of type string",
      "To see the stack trace of this error execute with --v=5 or higher"
   ],
   "stdout":"",
   "stdout_lines":[
      
   ]
}

Which issue(s) this PR fixes:

Fixes #10864

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix: config hostname as string type in kubeadmConfig rendering

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 11, 2024
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 11, 2024
Copy link
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

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

Thanks :D
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 11, 2024
@cyclinder
Copy link
Contributor

/lgtm

@ErikJiang
Copy link
Member Author

@mzaian @VannTen @yankay PTAL🙏

@VannTen
Copy link
Contributor

VannTen commented Mar 21, 2024 via email

@yankay
Copy link
Member

yankay commented Mar 22, 2024

Thanks for all @ErikJiang @VannTen
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cyclinder, ErikJiang, MrFreezeex, yankay

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 22, 2024
@k8s-ci-robot k8s-ci-robot merged commit 30da721 into kubernetes-sigs:master Mar 22, 2024
60 checks passed
pedro-peter pushed a commit to pedro-peter/kubespray that referenced this pull request Mar 23, 2024
@mzaian mzaian mentioned this pull request Apr 26, 2024
dibi-codes pushed a commit to fino-digital/kubespray that referenced this pull request May 7, 2024
pedro-peter pushed a commit to pedro-peter/kubespray that referenced this pull request May 8, 2024
Rickkwa pushed a commit to Rickkwa/kubespray that referenced this pull request Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Installation error if hostname of a control plane node is all numeric
6 participants