Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
VERSION: "${{ github.event_name == 'release' && github.event.release.name || github.ref_name }}"

steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
id: login
env:
token_is_present: "${{ secrets.DOCKERHUB_TOKEN && true }}"
Expand All @@ -36,7 +36,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: flyio/litefs
tags: |
Expand All @@ -47,7 +47,7 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- uses: docker/build-push-action@v4
- uses: docker/build-push-action@v6
with:
context: .
push: ${{ steps.login.outcome != 'skipped' }}
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
name: "Build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

Expand All @@ -34,9 +34,9 @@ jobs:
matrix:
journal_mode: [delete, persist, truncate, wal]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

Expand All @@ -53,14 +53,14 @@ jobs:
run: go test -v . ./internal/...

- name: Run FUSE tests
run: go test -v -p 1 -timeout 5m ./fuse -long -journal-mode ${{ matrix.journal_mode }}
run: go test -v -p 1 -timeout 10m ./fuse -long -journal-mode ${{ matrix.journal_mode }}
timeout-minutes: 5

- name: Start consul in dev mode
run: consul agent -dev &

- name: Run cmd tests
run: go test -v -p 1 -timeout 5m ./cmd/litefs -journal-mode ${{ matrix.journal_mode }}
run: go test -v -p 1 -timeout 10m ./cmd/litefs -journal-mode ${{ matrix.journal_mode }}
timeout-minutes: 5

functional:
Expand All @@ -71,9 +71,9 @@ jobs:
matrix:
journal_mode: [delete, persist, truncate, wal]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

Expand All @@ -94,23 +94,23 @@ jobs:
name: "Staticcheck"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- uses: dominikh/staticcheck-action@v1.2.0
- uses: dominikh/staticcheck-action@v1.3.1
with:
install-go: false

errcheck:
name: "Errcheck"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jobs:
MAIN_VERSION: "${{ github.event_name == 'release' && github.event.release.name || '' }}"

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

Expand All @@ -62,7 +62,7 @@ jobs:
tar -czvf litefs-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}.tar.gz litefs

- name: Upload binary artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: litefs-${{ env.VERSION }}-${{ env.GOOS }}-${{ env.GOARCH }}${{ env.GOARM }}
path: dist/litefs
Expand Down
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.5 as builder
FROM golang:1.21.5 AS builder

WORKDIR /src/litefs
COPY . .
Expand All @@ -10,8 +10,11 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
go build -ldflags "-s -w -X 'main.Version=${LITEFS_VERSION}' -X 'main.Commit=${LITEFS_COMMIT}' -extldflags '-static'" -tags osusergo,netgo,sqlite_omit_load_extension -o /usr/local/bin/litefs ./cmd/litefs

FROM alpine

RUN apk add --no-cache fuse3

FROM scratch
COPY --from=builder /usr/local/bin/litefs /usr/local/bin/litefs

ENTRYPOINT ["/usr/local/bin/litefs"]
CMD []
CMD ["mount", "-skip-unmount"]
8 changes: 7 additions & 1 deletion cmd/litefs/mount_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ type MountCommand struct {
cmd *exec.Cmd // subcommand
execCh chan error // subcommand error channel

// Skip unmounting any existing mount
skipUnmount bool

Config Config

OS litefs.OS
Expand Down Expand Up @@ -73,6 +76,7 @@ func (c *MountCommand) ParseFlags(ctx context.Context, args []string) (err error
fs := flag.NewFlagSet("litefs-mount", flag.ContinueOnError)
configPath := fs.String("config", "", "config file path")
noExpandEnv := fs.Bool("no-expand-env", false, "do not expand env vars in config")
skipUnmount := fs.Bool("skip-unmount", false, "skip unmounting any existing mount")
fuseDebug := fs.Bool("fuse.debug", false, "enable FUSE debug logging")
debug := fs.Bool("debug", false, "enable DEBUG level logging")
tracing := fs.Bool("tracing", false, "enable trace logging to stdout")
Expand Down Expand Up @@ -110,6 +114,8 @@ Arguments:
c.Config.Exec = ExecConfigSlice{{Cmd: strings.Join(args1, " ")}}
}

c.skipUnmount = *skipUnmount

// Override "debug" field if specified on the CLI.
if *fuseDebug {
c.Config.FUSE.Debug = true
Expand Down Expand Up @@ -489,7 +495,7 @@ func (c *MountCommand) initFileSystem(ctx context.Context) error {
fsys := fuse.NewFileSystem(c.Config.FUSE.Dir, c.Store)
fsys.AllowOther = c.Config.FUSE.AllowOther
fsys.Debug = c.Config.FUSE.Debug
if err := fsys.Mount(); err != nil {
if err := fsys.Mount(c.skipUnmount); err != nil {
return fmt.Errorf("cannot open file system: %s", err)
}

Expand Down
8 changes: 5 additions & 3 deletions fuse/file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ func (fsys *FileSystem) Path() string { return fsys.path }
func (fsys *FileSystem) Store() *litefs.Store { return fsys.store }

// Mount mounts the file system to the mount point.
func (fsys *FileSystem) Mount() (err error) {
// Attempt to unmount if it did not close cleanly before.
_ = fuse.Unmount(fsys.path)
func (fsys *FileSystem) Mount(skipUnmount bool) (err error) {
if !skipUnmount {
// Attempt to unmount if it did not close cleanly before.
_ = fuse.Unmount(fsys.path)
}

// Ensure mount directory exists before trying to mount to it.
if err := os.MkdirAll(fsys.path, 0777); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion fuse/file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ func newOpenFileSystem(tb testing.TB, path string, leaser *litefs.StaticLeaser)
tb.Helper()

fs := newFileSystem(tb, path, leaser)
if err := fs.Mount(); err != nil {
if err := fs.Mount(false); err != nil {
tb.Fatalf("cannot open file system: %s", err)
}

Expand Down
Loading