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

Refactor kubelet config generation #5246

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

twz123
Copy link
Member

@twz123 twz123 commented Nov 13, 2024

Description

Rename prepareLocalKubeletConfig to writeKubeletConfig and have this method not only generate the configuration data, but also write it to the designated file. Makes the Start method a bit shorter, and keeps related code snippets closer together. In this particular case, this eliminates an unnecessary string conversion back and forth. Move all kubelet config logic into that method, as well. This allows for dissolving the kubeletConfig struct and make the assignments directly to the generated KubeletConfiguration struct. Removes unnecessary indirection and concentrates more of the decision making into the appropriate method. Defer OS-specific decisions about the path to resolv.conf to the specific function, so that its return value is meaningful even if it's not called on Linux. Set the cgroups settings and do systemd detection only on Linux, as these are Linux-specific and don't exist on other operating systems.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist:

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Rename prepareLocalKubeletConfig to writeKubeletConfig and have this
method not only generate the configuration data, but also write it to
the designated file. Makes the Start method a bit shorter, and keeps
related code snippets closer together. In this particular case, this
eliminates an unnecessary string conversion back and forth.

Signed-off-by: Tom Wieczorek <[email protected]>
This allows for dissolving the config struct and make the assignments
directly to the generated kubelet configuration struct. Removes
unnecessary indirection and concentrates more of the decision making
into the appropriate method.

Defer OS-specific decisions about the path to resolv.conf to the
specific function, so that its return values are meaningful even if it's
not called on Linux.

Set the cgroups settings and do systemd detection only on Linux, as
these are Linux-specific and don't exist on other operating systems.

Signed-off-by: Tom Wieczorek <[email protected]>
@twz123 twz123 merged commit e86e0ce into k0sproject:main Nov 14, 2024
92 checks passed
@twz123 twz123 deleted the kubelet-config-refactor branch November 14, 2024 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants