-
Notifications
You must be signed in to change notification settings - Fork 40.2k
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: add mutation for Linux paths in KubeletConfiguration on Windows #105992
Conversation
/assign @neolit123 We can communicate here. |
} | ||
|
||
// Mutate the fields we care about. | ||
mutateStringField("resolvConf", cfg.ResolverConfig, true) // make sure this is disabled on Windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neolit123
Compared with your code, I changed this because this field becomes a pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess this was causing the panic you saw when testing?
OK, i just saw your comment below.
And the mutatePathsOnWindows is panicing because |
thanks, i will have a look tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ok-to-test
/triage accepted
/priority backlog
/sig windows
/release-note-edit
|
@@ -212,6 +216,63 @@ func (kc *kubeletConfig) Default(cfg *kubeadmapi.ClusterConfiguration, _ *kubead | |||
} | |||
} | |||
|
|||
// Mutate modifies absolute path fields in the KubeletConfiguration to be Windows compatible absolute paths. | |||
func (kc *kubeletConfig) Mutate() error { | |||
if runtime.GOOS != "windows" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems ok to add the Mutate() error
function as a post hook before writing config to the disk.
Not sure we should check the os by runtime.GOOS != "windows"
or // +build !windows
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems ok to add the Mutate() error function as a post hook before writing config to the disk.
Mutate operates on the KubeletConfiguration object and Marshal finalizes the object converting it to yaml string, thus it has to be before Marshal.
Not sure we should check the os by runtime.GOOS != "windows" or // +build !windows
+build !windows is better, but one problem is that if we move the *windows logic to _windows.go files, the unit test will not be run...currently the k8s CI only runs the Linux unit tests.
@hwdef i think we can have a TODO above the `if runtime.GOOS != "windows" line
TODO: use build tags and move the Windows related logic to _windows.go files once the kubeadm code base is unit tested for Windows as part of CI - "GOOS=windows go test ...".
(please keep the commits squashed)
/retest |
41b214b
to
23065e2
Compare
added a couple of new comments above: note that code freeze for 1.23 is early next week...otherwise the PR will have to wait for 1.24 (starts in mid december) |
b7e7d63
to
7aff6e3
Compare
/test pull-kubernetes-unit |
2ab266d
to
85e3dfc
Compare
@neolit123 And I add the blank line in |
the errors in CI are because there are multiple pkg/errors imports.
|
/retitle kubeadm: add mutation for Linux paths in KubeletConfiguration on Windows |
85e3dfc
to
897e609
Compare
@neolit123 I updated the code and test code. |
897e609
to
b985e09
Compare
i tested your patch locally and i saw 2 pkg error imports:
this is not visible in the github diff for some reason. |
the pkg/error import is already out of place in the current master branch: so let's leave it like that... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the PR!
/lgtm
/hold cancel |
fix absolute paths do not work properly in config files in windows
What type of PR is this?
/kind bug
What this PR does / why we need it:
Because linux and windows express the absolute path differently, some errors may be caused.
This pr fixes this bug, the fix method comes from https://gist.github.com/neolit123/1b7375c8a956155a2ca1cdd901336bce
Which issue(s) this PR fixes:
Fixes # kubernetes/kubeadm#2419
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: