Skip to content

Conversation

@Mykhailo-Roit
Copy link

Please add a summary of your change

When running velero install from Windows CLI, filepath.Join() was generating Windows-style paths with backslashes (e.g., \var\lib\kubelet\pods) in the generated DaemonSet manifest. However, these manifests are applied to Linux Kubernetes clusters which require forward slashes.

This fix ensures hostPath.path always uses forward slashes by replacing filepath.Join() with string concatenation, so the generated manifests work correctly regardless of the CLI host OS.

Does your change fix a particular issue?

Fixes #(9415)

When running velero install from Windows CLI, filepath.Join() was
generating Windows-style paths with backslashes (e.g., \var\lib\kubelet\pods)
in the generated DaemonSet manifest. However, these manifests are applied
to Linux Kubernetes clusters which require forward slashes.

This fix ensures hostPath.path always uses forward slashes by replacing
filepath.Join() with string concatenation, so the generated manifests
work correctly regardless of the CLI host OS.

Fixes vmware-tanzu#9415
hostPluginsVolumePath := filepath.Join(c.kubeletRootDir, "plugins")
// Use forward slashes for hostPath paths to ensure POSIX-style paths in generated manifests
// even when velero CLI runs on Windows. Kubernetes hostPath.path must use '/' separator.
kubeletRoot := strings.TrimRight(c.kubeletRootDir, "/\\")
Copy link
Contributor

Choose a reason for hiding this comment

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

kubeletRootDir could be specified by users, so in a Windows cluster, users may specify a Windows styled path, e.g., C:\\var\\lib\\kubelet.
As a result, it ends with a path mixed with / and \\, e.g., C:\\var\\lib\\kubelet/pods.

Even though Windows supports this mix, but since you are making this change for the purpose of Use forward slashes for hostPath paths to ensure POSIX-style path in generated manifests and it looks the right way, could you consider the above case and make the entire path in POSIX style?

Copy link
Author

Choose a reason for hiding this comment

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

The --use-node-agent flag indicates that an agent must be deployed on the Linux cluster.

Copy link
Contributor

@Lyndon-Li Lyndon-Li Nov 18, 2025

Choose a reason for hiding this comment

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

Yes, but the code here is shared by both linux cluster installation and Windows cluster installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants