Skip to content

Commit

Permalink
add local jfs gateway, fix edge cases, dynamic chunk size
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpetrovic committed Jan 9, 2025
1 parent 063dc31 commit 425caf1
Show file tree
Hide file tree
Showing 14 changed files with 641 additions and 292 deletions.
3 changes: 3 additions & 0 deletions hack/k3d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ ports:
- port: 8008:8008
nodeFilters:
- loadbalancer
- port: 9900:9900
nodeFilters:
- loadbalancer

volumes:
- volume: $PWD/manifests/k3d:k3s-manifests-custom
Expand Down
36 changes: 36 additions & 0 deletions manifests/kustomize/components/juicefs/helm-chart-generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,39 @@ valuesInline:
master:
persistence:
size: 1Gi
---
apiVersion: builtin
kind: HelmChartInflationGenerator
metadata:
name: &name juicefs-s3-gateway
releaseName: *name
name: &name juicefs-s3-gateway
repo: https://juicedata.github.io/charts/
version: 0.11.2
namespace: beta9
includeCRDs: true
skipTests: true
valuesInline:
nameOverride: *name
fullnameOverride: *name
port: 9900
service:
type: LoadBalancer
secret:
name: beta9-fs
metaurl: redis://juicefs-redis-master:6379/0
storage: s3
accessKey: test
secretKey: test-test-test
bucket: http://localstack:4566/juicefs

# -- JuiceFS format options. Separated by spaces
# Example: "--inodes=1000000 --block-size=4M"
# Ref: https://juicefs.com/docs/community/command_reference#format
formatOptions: "--block-size=4096 --no-update"

# -- Gateway Options. Separated by spaces
# Example: "--get-timeout=60 --put-timeout=60"
# CE Ref: https://juicefs.com/docs/community/command_reference#gateway
# EE Ref: https://juicefs.com/docs/cloud/reference/command_reference/#gateway
options: "--buffer-size=300 --cache-size=0 --prefetch=-1 --no-usage-report"
11 changes: 11 additions & 0 deletions manifests/kustomize/components/juicefs/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ kind: Component

generators:
- helm-chart-generator.yaml

patches:
- target:
kind: Deployment
name: juicefs-s3-gateway
patch: |-
- op: remove
path: /spec/template/spec/containers/0/env/0/valueFrom
- op: add
path: /spec/template/spec/containers/0/env/0/value
value: 0.0.0.0
8 changes: 8 additions & 0 deletions manifests/kustomize/overlays/cluster-dev/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ patches:
- op: replace
path: /spec/replicas
value: 0
# Replace RollingUpdate with Recreate for all Deployments in this overlay
- target:
kind: Deployment
patch: |
- op: add
path: /spec/strategy
value:
type: Recreate
30 changes: 30 additions & 0 deletions pkg/abstractions/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,36 @@ func (vs *GlobalVolumeService) MovePath(ctx context.Context, in *pb.MovePathRequ
}, nil
}

func (vs *GlobalVolumeService) StatPath(ctx context.Context, in *pb.StatPathRequest) (*pb.StatPathResponse, error) {
authInfo, _ := auth.AuthInfoFromContext(ctx)

path, err := vs.getFilePath(ctx, in.Path, authInfo.Workspace)
if err != nil {
return &pb.StatPathResponse{
Ok: false,
ErrMsg: err.Error(),
}, nil
}

info, err := os.Stat(path)
if err != nil {
return &pb.StatPathResponse{
Ok: true,
ErrMsg: "Path does not exist",
}, nil
}

return &pb.StatPathResponse{
Ok: true,
PathInfo: &pb.PathInfo{
Path: in.Path,
Size: uint64(info.Size()),
ModTime: timestamppb.New(info.ModTime()),
IsDir: info.IsDir(),
},
}, nil
}

// Volume business logic
func (vs *GlobalVolumeService) getOrCreateVolume(ctx context.Context, workspace *types.Workspace, volumeName string) (*types.Volume, error) {
volume, err := vs.backendRepo.GetOrCreateVolume(ctx, workspace.Id, volumeName)
Expand Down
10 changes: 10 additions & 0 deletions pkg/abstractions/volume/volume.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ service VolumeService {
rpc DeletePath(DeletePathRequest) returns (DeletePathResponse) {}
rpc CopyPathStream(stream CopyPathRequest) returns (CopyPathResponse) {}
rpc MovePath(MovePathRequest) returns (MovePathResponse) {}
rpc StatPath(StatPathRequest) returns (StatPathResponse) {}

// Multipart Upload
rpc CreatePresignedURL(CreatePresignedURLRequest) returns (CreatePresignedURLResponse) {}
Expand Down Expand Up @@ -107,6 +108,15 @@ message MovePathResponse {
string new_path = 3;
}

message StatPathRequest {
string path = 1;
}

message StatPathResponse {
bool ok = 1;
string err_msg = 2;
PathInfo path_info = 3;
}

message PresignedURLParams {
string upload_id = 1;
Expand Down
6 changes: 3 additions & 3 deletions pkg/common/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ gateway:
maxReplicas: 10
maxGpuCount: 2
fileService:
endpointUrl: https://data-stage-beam-cloud.fly.dev
endpointUrl: http://juicefs-s3-gateway.beta9.svc.cluster.local:9900
bucketName: beta9-fs
accessKey:
secretKey:
accessKey: test
secretKey: test-test-test
region:
imageService:
localCacheEnabled: true
Expand Down
Loading

0 comments on commit 425caf1

Please sign in to comment.