File upload does not work with directories with ":" in their names
Let's say I have a directory structure like this, which I wish to copy to a target host..
$ tree gpu-workstation/
gpu-workstation/
├── etc
│ └── k0s
│ ├── certs.d
│ │ └── gpu-workstation:30101
│ │ ├── hosts.toml
│ │ └── ca.pem
│ └── containerd.d
│ └── registry.toml
└── var
└── lib
└── tailscale
└── tailscaled.state
Which I then put into k0sctl.yaml like this..
spec:
hosts:
...
- ssh:
address: 100.92.34.7
user: martin_kou
port: 22
keyPath: null
role: worker
files:
- name: test
src: gpu-workstation
dstDir: /
The directory gpu-workstation:30101 would cause the file upload to always fail with an "invalid path" log entry. e.g.
time="24 Mar 24 17:41 PDT" level=info msg="\x1b[32m==> Running phase: Upload files to hosts\x1b[0m"
time="24 Mar 24 17:41 PDT" level=info msg="[ssh] 100.92.34.7:22: uploading registry-config"
time="24 Mar 24 17:41 PDT" level=info msg="[ssh] 100.92.34.7:22: uploading file gpu-workstation/etc/k0s/certs.d/gpu-workstation:30101/hosts.toml => /etc/k0s/certs.d/gpu-workstation:30101/hosts.toml (1 of 4)"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: ensuring directory /etc/k0s/certs.d/gpu-workstation:30101"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: executing `sudo -s -- test -e /etc/k0s/certs.d/gpu-workstation:30101 2> /dev/null`"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: executing `sudo -s -- env -i LC_ALL=C stat -c '%s|%y|%a|%F' -- /etc/k0s/certs.d/gpu-workstation:30101/hosts.toml`"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: remote stat failed: failed to stat /etc/k0s/certs.d/gpu-workstation:30101/hosts.toml: command failed: client exec: ssh session wait: Process exited with status 1"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: executing `stat --help 2>&1`"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: executing `stat -c '%#f %s %.9Y //%n//' -- /etc/k0s/certs.d/gpu-workstation:30101/hosts.toml 2> /dev/null`"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: executing `stat -c '%#f %s %.9Y //%n//' -- /etc/k0s/certs.d/gpu-workstation:30101 2> /dev/null`"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: 0x41ed 4096 1711326694.424793474 ///etc/k0s/certs.d/gpu-workstation:30101//"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: executing `install -m 0644 /dev/null /etc/k0s/certs.d/gpu-workstation:30101/hosts.toml`"
time="24 Mar 24 17:41 PDT" level=info msg="\x1b[31m* Running clean-up for phase: Acquire exclusive host lock\x1b[0m"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.114.163.115:22: stopped lock cycle, removing file"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: stopped lock cycle, removing file"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.92.34.7:22: executing `sudo -s -- rm -f -- /run/lock/k0sctl 2> /dev/null`"
time="24 Mar 24 17:41 PDT" level=debug msg="[ssh] 100.114.163.115:22: executing `sudo -s -- rm -f -- /run/lock/k0sctl 2> /dev/null`"
time="24 Mar 24 17:41 PDT" level=info msg="\x1b[31m==> Apply failed\x1b[0m"
time="24 Mar 24 17:41 PDT" level=fatal msg="apply failed - log file saved to /home/martin_kou/.cache/k0sctl/k0sctl.log: failed on 1 hosts:\n - [ssh] 100.92.34.7:22: invalid path: open remote file
/etc/k0s/certs.d/gpu-workstation:30101/hosts.toml for writing:
open /etc/k0s/certs.d/gpu-workstation:30101/hosts.toml:
command failed: client exec: ssh session wait: Process exited with status 1"
If I remove any directory with ":" from the source files, then the upload would succeed. Unfortunately, in this particular case I actually need the "gpu-workstation:30101" to be named in that particular way.
That's strange.
It looks like the command install -m 0644 /dev/null /etc/k0s/certs.d/gpu-workstation:30101/hosts.toml fails which creates an empty file with 0644 permissions.
It looks like it didn't use sudo but I can't understand how that could happen.
I need to try this out myself.
I think the colon is a red herring, this is probably the same issue I had in https://github.com/k0sproject/k0sctl/issues/638