Closed jmaness closed 1 month ago
Related:
Yes, golang os.rename not support cross device.
I will fix it next version
@jmaness can you take a look on this commit? it should works fine~
@wencaiwulue It looks like there are a couple of other issues. The file move succeeds but the file is not executable and the file ownership is not correct. Somehow the new file is owned by root
instead of the current user.
$ make kubevpn
make kubevpn-linux-amd64
make[1]: Entering directory '/home/jeremy/projects/kubevpn'
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags noassets --ldflags "-s -w -X github.com/wencaiwulue/kubevpn/v2/pkg/config.Image=docker.io/naison/kubevpn:v2.2.15 -X github.com/wencaiwulue/kubevpn/v2/pkg/config.Version=v2.2.15 -X github.com/wencaiwulue/kubevpn/v2/pkg/config.GitCommit=a37bfc2 -X github.com/wencaiwulue/kubevpn/v2/pkg/config.GitHubOAuthToken= -X github.com/wencaiwulue/kubevpn/v2/cmd/kubevpn/cmds.BuildTime=2024-07-22T12:15:47Z -X github.com/wencaiwulue/kubevpn/v2/cmd/kubevpn/cmds.Branch=master -X github.com/wencaiwulue/kubevpn/v2/cmd/kubevpn/cmds.OsArch=linux/amd64 " -o ./bin/kubevpn github.com/wencaiwulue/kubevpn/v2/cmd/kubevpn
chmod +x ./bin/kubevpn
make[1]: Leaving directory '/home/jeremy/projects/kubevpn'
$ ls -al bin/kubevpn
-rwxr-xr-x 1 jeremy jeremy 100237464 Jul 22 12:15 bin/kubevpn
$ bin/kubevpn upgrade
Current version is: 2.2.15 less than latest version: 2.2.15, needs to upgrade
Current version is: 2.2.15 less than latest version: 2.2.15, needs to upgrade
Length: 31749937 (30.28M)
Writing temp file... 100% [=========================] (81 MB/s)
Upgrade daemon...
Done
Error: fork/exec /home/jeremy/projects/kubevpn/bin/kubevpn: permission denied
$ ls -al bin/kubevpn
-rw-r--r-- 1 root root 100270232 Jul 22 12:16 bin/kubevpn
$ sudo chmod +x bin/kubevpn
$ ./bin/kubevpn
KubeVPN offers a Cloud-Native Dev Environment that seamlessly connects to your Kubernetes cluster network.
Develop commands:
connect Connect to kubernetes cluster network
disconnect Disconnect from kubernetes cluster network
proxy Proxy kubernetes workloads inbound traffic into local PC
leave Leave proxy resource
clone Clone workloads to target-kubeconfig cluster with same volume、env、and network
remove Remove clone resource
dev Startup your kubernetes workloads in local Docker container
Management commands:
status Show connect status and list proxy/clone resource
alias Config file alias to execute command simply
config Proxy kubeconfig which behind of ssh jump server
ssh Ssh to jump server
logs Log kubevpn daemon grpc server
reset Reset all resource create by kubevpn in k8s cluster
quit Quit kubevpn daemon grpc server
Other commands:
upgrade Upgrade kubevpn client to latest version
version Print the client version information
Other Commands:
completion Generate the autocompletion script for the specified shell
Usage:
kubevpn [flags] [options]
Use "kubevpn <command> --help" for more information about a given command.
Use "kubevpn options" for a list of global command-line options (applies to all commands).
@wencaiwulue It looks like there are a couple of other issues. The file move succeeds but the file is not executable and the file ownership is not correct. Somehow the new file is owned by
root
instead of the current user.$ make kubevpn make kubevpn-linux-amd64 make[1]: Entering directory '/home/jeremy/projects/kubevpn' CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags noassets --ldflags "-s -w -X github.com/wencaiwulue/kubevpn/v2/pkg/config.Image=docker.io/naison/kubevpn:v2.2.15 -X github.com/wencaiwulue/kubevpn/v2/pkg/config.Version=v2.2.15 -X github.com/wencaiwulue/kubevpn/v2/pkg/config.GitCommit=a37bfc2 -X github.com/wencaiwulue/kubevpn/v2/pkg/config.GitHubOAuthToken= -X github.com/wencaiwulue/kubevpn/v2/cmd/kubevpn/cmds.BuildTime=2024-07-22T12:15:47Z -X github.com/wencaiwulue/kubevpn/v2/cmd/kubevpn/cmds.Branch=master -X github.com/wencaiwulue/kubevpn/v2/cmd/kubevpn/cmds.OsArch=linux/amd64 " -o ./bin/kubevpn github.com/wencaiwulue/kubevpn/v2/cmd/kubevpn chmod +x ./bin/kubevpn make[1]: Leaving directory '/home/jeremy/projects/kubevpn' $ ls -al bin/kubevpn -rwxr-xr-x 1 jeremy jeremy 100237464 Jul 22 12:15 bin/kubevpn $ bin/kubevpn upgrade Current version is: 2.2.15 less than latest version: 2.2.15, needs to upgrade Current version is: 2.2.15 less than latest version: 2.2.15, needs to upgrade Length: 31749937 (30.28M) Writing temp file... 100% [=========================] (81 MB/s) Upgrade daemon... Done Error: fork/exec /home/jeremy/projects/kubevpn/bin/kubevpn: permission denied $ ls -al bin/kubevpn -rw-r--r-- 1 root root 100270232 Jul 22 12:16 bin/kubevpn $ sudo chmod +x bin/kubevpn $ ./bin/kubevpn KubeVPN offers a Cloud-Native Dev Environment that seamlessly connects to your Kubernetes cluster network. Develop commands: connect Connect to kubernetes cluster network disconnect Disconnect from kubernetes cluster network proxy Proxy kubernetes workloads inbound traffic into local PC leave Leave proxy resource clone Clone workloads to target-kubeconfig cluster with same volume、env、and network remove Remove clone resource dev Startup your kubernetes workloads in local Docker container Management commands: status Show connect status and list proxy/clone resource alias Config file alias to execute command simply config Proxy kubeconfig which behind of ssh jump server ssh Ssh to jump server logs Log kubevpn daemon grpc server reset Reset all resource create by kubevpn in k8s cluster quit Quit kubevpn daemon grpc server Other commands: upgrade Upgrade kubevpn client to latest version version Print the client version information Other Commands: completion Generate the autocompletion script for the specified shell Usage: kubevpn [flags] [options] Use "kubevpn <command> --help" for more information about a given command. Use "kubevpn options" for a list of global command-line options (applies to all commands).
no.... another bug 😂. i will fix it
@jmaness this commit should works fine #305
@wencaiwulue Thanks, I can verify the fix once a new release is available. The new behavior is:
$ kubevpn upgrade
Already up to date, don't needs to upgrade, version: v2.2.15
which is good.
From looking at https://github.com/kubenetworks/kubevpn/pull/305, I see the logic that now preserves the file mode, but I don't see how the file ownership is preserved after the permissions are elevated at https://github.com/kubenetworks/kubevpn/pull/305/files#diff-1c2bd1d24587a4323e59931edaa538b2d6538fbd63dad45ea40ef8d1d9bbd939R27.
I can test it more thoroughly after the next release though.
@wencaiwulue Thanks, I can verify the fix once a new release is available. The new behavior is:
$ kubevpn upgrade Already up to date, don't needs to upgrade, version: v2.2.15
which is good.
From looking at #305, I see the logic that now preserves the file mode, but I don't see how the file ownership is preserved after the permissions are elevated at https://github.com/kubenetworks/kubevpn/pull/305/files#diff-1c2bd1d24587a4323e59931edaa538b2d6538fbd63dad45ea40ef8d1d9bbd939R27.
I can test it more thoroughly after the next release though.
Yes, not preserves the file owner, because we needs to use sudo user to move binary to /usr/local/bin, which needs root permission.
When running
kubevpn upgrade
, after downloading the new kubevpn binary to /tmp, the upgrade fails with the messageThis is likely due to my /tmp directory on a different mount point/file system than /usr. On my system,
/tmp
uses thetmpfs
file system and/usr/bin
is on a different file system.The API call invoked to rename the
kubevpn
binary is likely the wrong one to handle cross-file system file moves.