diff --git a/.github/workflows/build-windows.yaml b/.github/workflows/build-windows.yaml index 3eaefeb9f99..46275dc74df 100644 --- a/.github/workflows/build-windows.yaml +++ b/.github/workflows/build-windows.yaml @@ -56,6 +56,10 @@ jobs: - go.sum EOF + sh hack/go-list.sh cmd/cni | while read f; do + echo "- $f" | tee -a $filter + done + sh hack/go-list.sh cmd/windows | while read f; do echo "- $f" | tee -a $filter done diff --git a/Makefile b/Makefile index 058eb04b4f0..48de41df51b 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,7 @@ ARCH = amd64 .PHONY: build-go build-go: go mod tidy + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn -ldflags $(GOLDFLAGS) -v ./cmd/cni CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn-cmd -ldflags $(GOLDFLAGS) -v ./cmd CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn-webhook -ldflags $(GOLDFLAGS) -v ./cmd/webhook CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(CURDIR)/dist/images/test-server -ldflags $(GOLDFLAGS) -v ./test/server @@ -81,11 +82,12 @@ build-go: .PHONY: build-go-windows build-go-windows: go mod tidy - CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/windows/kube-ovn.exe -ldflags $(GOLDFLAGS) -v ./cmd/windows/cni + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/windows/kube-ovn.exe -ldflags $(GOLDFLAGS) -v ./cmd/cni CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -buildmode=pie -o $(CURDIR)/dist/windows/kube-ovn-daemon.exe -ldflags $(GOLDFLAGS) -v ./cmd/windows/daemon .PHONY: build-go-arm build-go-arm: + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn -ldflags $(GOLDFLAGS) -v ./cmd/cni CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn-cmd -ldflags $(GOLDFLAGS) -v ./cmd CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -buildmode=pie -o $(CURDIR)/dist/images/kube-ovn-webhook -ldflags $(GOLDFLAGS) -v ./cmd/webhook diff --git a/cmd/cmdmain.go b/cmd/cmdmain.go index 0b6514daffc..90ba28cd155 100644 --- a/cmd/cmdmain.go +++ b/cmd/cmdmain.go @@ -4,7 +4,6 @@ import ( "os" "path/filepath" - "github.com/kubeovn/kube-ovn/cmd/cni" "github.com/kubeovn/kube-ovn/cmd/controller" "github.com/kubeovn/kube-ovn/cmd/controller_health_check" "github.com/kubeovn/kube-ovn/cmd/daemon" @@ -16,7 +15,6 @@ import ( ) const ( - CmdCNI = "kube-ovn" CmdController = "kube-ovn-controller" CmdDaemon = "kube-ovn-daemon" CmdMonitor = "kube-ovn-monitor" @@ -29,8 +27,6 @@ const ( func main() { cmd := filepath.Base(os.Args[0]) switch cmd { - case CmdCNI: - cni.CmdMain() case CmdController: controller.CmdMain() case CmdDaemon: diff --git a/cmd/cni/cni.go b/cmd/cni/cni.go index 312adab8399..bb658474c49 100644 --- a/cmd/cni/cni.go +++ b/cmd/cni/cni.go @@ -1,4 +1,4 @@ -package cni +package main import ( "encoding/json" @@ -18,7 +18,7 @@ import ( "github.com/kubeovn/kube-ovn/versions" ) -func CmdMain() { +func main() { // this ensures that main runs only on main thread (thread group leader). // since namespace ops (unshare, setns) are done for a single thread, we // must ensure that the goroutine does not jump from OS thread to thread diff --git a/cmd/cni/netconf.go b/cmd/cni/netconf.go index 1a2cc52bc8c..91e45701a3a 100644 --- a/cmd/cni/netconf.go +++ b/cmd/cni/netconf.go @@ -1,7 +1,7 @@ //go:build !windows // +build !windows -package cni +package main import ( "github.com/containernetworking/cni/pkg/types" diff --git a/cmd/cni/netconf_windows.go b/cmd/cni/netconf_windows.go index 27d7ba8826f..ddcd2b557e7 100644 --- a/cmd/cni/netconf_windows.go +++ b/cmd/cni/netconf_windows.go @@ -1,4 +1,4 @@ -package cni +package main import ( "github.com/containernetworking/plugins/pkg/hns" diff --git a/cmd/windows/cni/main_windows.go b/cmd/windows/cni/main_windows.go deleted file mode 100644 index 5f9b7ff1232..00000000000 --- a/cmd/windows/cni/main_windows.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "github.com/kubeovn/kube-ovn/cmd/cni" - -func main() { - cni.CmdMain() -} diff --git a/dist/images/Dockerfile b/dist/images/Dockerfile index 9bc83bea9f4..34a323797ee 100644 --- a/dist/images/Dockerfile +++ b/dist/images/Dockerfile @@ -16,10 +16,10 @@ RUN rm -f /usr/bin/nc &&\ rm -f /usr/bin/netcat RUN deluser sync +COPY kube-ovn /kube-ovn/kube-ovn COPY kube-ovn-cmd /kube-ovn/kube-ovn-cmd COPY kube-ovn-webhook /kube-ovn/kube-ovn-webhook -RUN ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn && \ - ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-controller && \ +RUN ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-controller && \ ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-daemon && \ ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-monitor && \ ln -s /kube-ovn/kube-ovn-cmd /kube-ovn/kube-ovn-pinger && \