Skip to content

Commit

Permalink
Fix Makefile, Dockerfile and makefile (fluid-cloudnative#1528)
Browse files Browse the repository at this point in the history
* Move pprof into a  function, To #37688693

Signed-off-by: cheyang <cheyang@163.com>

* Move pprof into a  function, To #37688693

Signed-off-by: cheyang <cheyang@163.com>

* Add dlv, To #37688693

Signed-off-by: cheyang <cheyang@163.com>

* Add dlv, To #37688693

Signed-off-by: cheyang <cheyang@163.com>

* Build docker image for disabling timezone hostpath for jindoruntime, To #37688693

Signed-off-by: cheyang <cheyang@163.com>

* Build docker image for disabling timezone hostpath for jindoruntime, To #37688693

Signed-off-by: cheyang <cheyang@163.com>

* Build docker image for debuging, To #37688693

Signed-off-by: cheyang <cheyang@163.com>
  • Loading branch information
cheyang authored Mar 16, 2022
1 parent 768a656 commit 772cf40
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 54 deletions.
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LOADER_IMG ?= ${IMG_REPO}/fluid-dataloader
INIT_USERS_IMG ?= ${IMG_REPO}/init-users
WEBHOOK_IMG ?= ${IMG_REPO}/fluid-webhook
GO_MODULE ?= off
GC_FLAGS ?= -gcflags="all=-N -l"

LOCAL_FLAGS ?= -gcflags=-l
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand Down Expand Up @@ -88,28 +89,28 @@ unit-test: generate fmt vet
build: ${BINARY_BUILD}

csi-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build -o bin/fluid-csi -ldflags '${LDFLAGS}' cmd/csi/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/fluid-csi -ldflags '${LDFLAGS}' cmd/csi/main.go

dataset-controller-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build -gcflags="-N -l" -a -o bin/dataset-controller -ldflags '${LDFLAGS}' cmd/dataset/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/dataset-controller -ldflags '${LDFLAGS}' cmd/dataset/main.go

alluxioruntime-controller-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build -gcflags="-N -l" -a -o bin/alluxioruntime-controller -ldflags '${LDFLAGS}' cmd/alluxio/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/alluxioruntime-controller -ldflags '${LDFLAGS}' cmd/alluxio/main.go

jindoruntime-controller-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build -gcflags="-N -l" -a -o bin/jindoruntime-controller -ldflags '${LDFLAGS}' cmd/jindo/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/jindoruntime-controller -ldflags '${LDFLAGS}' cmd/jindo/main.go

goosefsruntime-controller-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build -gcflags="-N -l" -a -o bin/goosefsruntime-controller -ldflags '${LDFLAGS}' cmd/goosefs/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/goosefsruntime-controller -ldflags '${LDFLAGS}' cmd/goosefs/main.go

juicefsruntime-controller-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build -gcflags="-N -l" -a -o bin/juicefsruntime-controller -ldflags '-s -w ${LDFLAGS}' cmd/juicefs/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/juicefsruntime-controller -ldflags '-s -w ${LDFLAGS}' cmd/juicefs/main.go

webhook-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build -gcflags="-N -l" -a -o bin/fluid-webhook -ldflags '${LDFLAGS}' cmd/webhook/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/fluid-webhook -ldflags '${LDFLAGS}' cmd/webhook/main.go

application-controller-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build -gcflags="-N -l" -a -o bin/fluidapp-controller -ldflags '${LDFLAGS}' cmd/fluidapp/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=${GO_MODULE} go build ${GC_FLAGS} -a -o bin/fluidapp-controller -ldflags '${LDFLAGS}' cmd/fluidapp/main.go

# Debug against the configured Kubernetes cluster in ~/.kube/config, add debug
debug: generate fmt vet manifests
Expand Down
77 changes: 41 additions & 36 deletions cmd/csi/app/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import (
"errors"
"flag"
"fmt"
"net/http"
"net/http/pprof"
"os"
"time"

"github.com/fluid-cloudnative/fluid"
datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
"github.com/fluid-cloudnative/fluid/pkg/csi"
Expand All @@ -30,11 +35,7 @@ import (
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"net/http"
"net/http/pprof"
"os"
ctrl "sigs.k8s.io/controller-runtime"
"time"
)

var (
Expand Down Expand Up @@ -90,38 +91,7 @@ func handle() {
fluid.LogVersion()

if pprofAddr != "" {
glog.Infof("Enabling pprof with address %s", pprofAddr)
mux := http.NewServeMux()
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)

pprofServer := http.Server{
Addr: pprofAddr,
Handler: mux,
}
glog.Infof("Starting pprof HTTP server at %s", pprofServer.Addr)

go func() {
go func() {
ctx := context.Background()
<-ctx.Done()

ctx, cancelFunc := context.WithTimeout(context.Background(), 60*time.Minute)
defer cancelFunc()

if err := pprofServer.Shutdown(ctx); err != nil {
glog.Error(err, "Failed to shutdown debug HTTP server")
}
}()

if err := pprofServer.ListenAndServe(); !errors.Is(http.ErrServerClosed, err) {
glog.Error(err, "Failed to start debug HTTP server")
panic(err)
}
}()
newPprofServer(pprofAddr)
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Expand All @@ -148,3 +118,38 @@ func handle() {
panic(fmt.Sprintf("unable to start controller recover due to error %v", err))
}
}

func newPprofServer(pprofAddr string) {
glog.Infof("Enabling pprof with address %s", pprofAddr)
mux := http.NewServeMux()
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)

pprofServer := http.Server{
Addr: pprofAddr,
Handler: mux,
}
glog.Infof("Starting pprof HTTP server at %s", pprofServer.Addr)

go func() {
go func() {
ctx := context.Background()
<-ctx.Done()

ctx, cancelFunc := context.WithTimeout(context.Background(), 60*time.Minute)
defer cancelFunc()

if err := pprofServer.Shutdown(ctx); err != nil {
glog.Error(err, "Failed to shutdown debug HTTP server")
}
}()

if err := pprofServer.ListenAndServe(); !errors.Is(http.ErrServerClosed, err) {
glog.Error(err, "Failed to start debug HTTP server")
panic(err)
}
}()
}
2 changes: 1 addition & 1 deletion docker/Dockerfile.alluxioruntime
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN curl -o helm-v3.0.3-linux-amd64.tar.gz http://aliacs-k8s-cn-hongkong.oss-cn-
ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl

add charts/ /charts
ADD charts/ /charts

COPY --from=builder /go/bin/alluxioruntime-controller /usr/local/bin/alluxioruntime-controller
RUN chmod -R u+x /usr/local/bin/
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.application
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN curl -o helm-v3.0.3-linux-amd64.tar.gz http://aliacs-k8s-cn-hongkong.oss-cn-
ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl

add charts/ /charts
ADD charts/ /charts

COPY --from=builder /go/bin/fluidapp-controller /usr/local/bin/fluidapp-controller
COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.csi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY . .
RUN make csi-build && \
cp bin/fluid-csi /go/bin/fluid-csi

# RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -gcflags="-N -l" -a -o /go/bin/fluid-csi cmd/csi/*.go
# RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -gcflags="all=-N -l" -a -o /go/bin/fluid-csi cmd/csi/*.go

# Debug
RUN go get github.com/go-delve/delve/cmd/dlv
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.dataset
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN curl -o helm-v3.0.3-linux-amd64.tar.gz http://aliacs-k8s-cn-hongkong.oss-cn-
ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl

add charts/ /charts
ADD charts/ /charts

COPY --from=builder /go/bin/dataset-controller /usr/local/bin/dataset-controller
COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.goosefsruntime
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN curl -o helm-v3.0.3-linux-amd64.tar.gz http://aliacs-k8s-cn-hongkong.oss-cn-
ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl

add charts/ /charts
ADD charts/ /charts

COPY --from=builder /go/bin/goosefsruntime-controller /usr/local/bin/goosefsruntime-controller
COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.jindoruntime
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN curl -o helm-v3.0.3-linux-amd64.tar.gz http://aliacs-k8s-cn-hongkong.oss-cn-
ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl

add charts/jindofs /charts/jindofs
ADD charts/jindofs /charts/jindofs

COPY --from=builder /go/bin/jindoruntime-controller /usr/local/bin/jindoruntime-controller
COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.juicefsruntime
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN curl -o helm-v3.0.3-linux-amd64.tar.gz http://aliacs-k8s-cn-hongkong.oss-cn-
ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl

add charts/ /charts
ADD charts/ /charts

COPY --from=builder /go/bin/juicefsruntime-controller /usr/local/bin/juicefsruntime-controller
COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
Expand Down
8 changes: 7 additions & 1 deletion docs/en/userguide/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,14 @@ $ kubectl delete ns fluid-system

### Advanced Configuration

In some cloud vendors, the default mount root directory `/runtime-mnt` is not writable, so you have to modify the directory location
1. In some cloud vendors, the default mount root directory `/runtime-mnt` is not writable, so you have to modify the directory location

```
helm install fluid --set runtime.mountRoot=/var/lib/docker/runtime-mnt fluid
```

2. The feature `Fuse Recovery` is not enable by default, to enable this:

```
helm install fluid --set csi.featureGates='FuseRecovery=true' fluid
```
2 changes: 1 addition & 1 deletion docs/zh/dev/runtime_dev_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func init() {
JINDORUNTIME_CONTROLLER_IMG ?= xxx/xxx
jindoruntime-controller-build: generate fmt vet
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -gcflags="-N -l" -a -o bin/jindoruntime-controller -ldflags '${LDFLAGS}' cmd/jindo/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -gcflags="all=-N -l" -a -o bin/jindoruntime-controller -ldflags '${LDFLAGS}' cmd/jindo/main.go
docker-build-jindoruntime-controller: generate fmt vet
docker build --no-cache . -f Dockerfile.jindoruntime -t ${JINDORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
Expand Down
7 changes: 6 additions & 1 deletion docs/zh/userguide/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,14 @@ $ kubectl delete ns fluid-system

### 高级配置

在一些特定的云厂商实现下, 默认mount根目录`/runtime-mnt`是不可写的,因此需要修改目录位置
1. 在一些特定的云厂商实现下, 默认mount根目录`/runtime-mnt`是不可写的,因此需要修改目录位置

```
helm install fluid --set runtime.mountRoot=/var/lib/docker/runtime-mnt fluid
```

2. 默认Fuse Recovery的功能并没有打开,如果需要开放该功能,需要按照以下配置

```
helm install fluid --set csi.featureGates='FuseRecovery=true' fluid
```

0 comments on commit 772cf40

Please sign in to comment.