Skip to content

Commit

Permalink
#461: generate the filesystemID on the fly and register over create
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlotte committed Jun 27, 2018
1 parent d8bb7ad commit 61fc20b
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions cmd/dotmesh-server/pkg/main/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/coreos/etcd/client"
uuid "github.com/nu7hatch/gouuid"
"golang.org/x/net/context"
)

Expand Down Expand Up @@ -1051,6 +1052,7 @@ func (d *DotmeshRPC) S3Transfer(
args *S3TransferRequest,
result *string,
) error {
localVolumeName := VolumeName{args.LocalNamespace, args.LocalName}
switch args.Direction {
case "push":
// TODO do we need this check, should it be different? Suspect s3 just requires there's no `.` etc but that's something the user will need to do on AWS anyway, unless we're allowing create-if-not-exists for pushes
Expand All @@ -1059,7 +1061,7 @@ func (d *DotmeshRPC) S3Transfer(
return err
}
case "pull":
err := requireValidVolumeName(VolumeName{args.LocalNamespace, args.LocalName})
err := requireValidVolumeName(localVolumeName)
if err != nil {
return err
}
Expand Down Expand Up @@ -1088,19 +1090,34 @@ func (d *DotmeshRPC) S3Transfer(
log.Printf("[S3Transfer] starting with %+v", safeS3(*args))

localFilesystemId := d.state.registry.Exists(
VolumeName{args.LocalNamespace, args.LocalName}, args.LocalBranchName,
localVolumeName, args.LocalBranchName,
)
localExists := localFilesystemId != ""

// note; was a bunch of logic checks for whether remote/local ends exist here - I don't think we need them because we'd have returned an error already if remote didn't exist

var filesystemId string
if args.Direction == "pull" && !localExists {
localFilesystem, _, err := d.state.CreateFilesystem(r.Context(), &VolumeName{args.LocalNamespace, args.LocalName})
id, err := uuid.NewV4()
if err != nil {
return err
}
filesystemId = id.String()
err = d.registerFilesystemBecomeMaster(
r.Context(),
args.LocalNamespace,
args.LocalName,
args.LocalBranchName,
filesystemId,
PathToTopLevelFilesystem{
TopLevelFilesystemId: filesystemId,
TopLevelFilesystemName: localVolumeName,
Clones: ClonesList{},
},
)
if err != nil {
return err
}
filesystemId = localFilesystem.filesystemId
}
// TODO: look at the logic for filesystem combinations, there was a bunch of logic for pulling/pushing fsystems that were in sync or had dirty changes. Not sure we need or can use those

Expand All @@ -1111,7 +1128,7 @@ func (d *DotmeshRPC) S3Transfer(

responseChan, requestId, err := d.state.globalFsRequestId(
filesystemId,
&Event{Name: "transfer",
&Event{Name: "s3-transfer",
Args: &EventArgs{
"Transfer": args,
},
Expand Down

0 comments on commit 61fc20b

Please sign in to comment.