Skip to content

feat: support v2 backing image cloning and encryption #870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ go 1.23.0

toolchain go1.23.5

replace github.com/longhorn/types v0.0.0-20241225162202-00d3a5fd7502 => github.com/chanyilin/types v0.0.0-20250122064930-c1b9017c2968

replace github.com/longhorn/longhorn-spdk-engine v0.0.0-20250116082350-44753b56dd34 => github.com/chanyilin/longhorn-spdk-engine v0.0.0-20250210051857-5201477fb5c0

require (
github.com/google/uuid v1.6.0
github.com/longhorn/backupstore v0.0.0-20250115162037-d046737d09dc
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8 h1:SjZ2GvvOononHOpK
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8/go.mod h1:uEyr4WpAH4hio6LFriaPkL938XnrvLpNPmQHBdrmbIE=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chanyilin/longhorn-spdk-engine v0.0.0-20250210051857-5201477fb5c0 h1:279B6il/OLNUEipBNH7uS06KhdyFE1x9JZKt/zUHVP8=
github.com/chanyilin/longhorn-spdk-engine v0.0.0-20250210051857-5201477fb5c0/go.mod h1:zNbx3gpuMffFml9gcHYfWgbWwt6TzVd6PBAv1df4du4=
github.com/chanyilin/types v0.0.0-20250122064930-c1b9017c2968 h1:RSdTuXuVvvX7AMEUczdNhFYBtu6sHZ3jGd6I/CqAjJI=
github.com/chanyilin/types v0.0.0-20250122064930-c1b9017c2968/go.mod h1:3jHuVDtpkXQzpnp4prguDBskVRric2kmF8aSPkRJ4jw=
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -118,12 +122,8 @@ github.com/longhorn/go-spdk-helper v0.0.0-20250116051812-eabe34a4219e h1:rBySu2+
github.com/longhorn/go-spdk-helper v0.0.0-20250116051812-eabe34a4219e/go.mod h1:2NT1Xz4rBNecYAQmj/UqHz5D3UEDZZkiv2hcmVB7kqM=
github.com/longhorn/longhorn-engine v1.8.0-rc4 h1:gK0pb6etQTXNp1U02G/5pb59AWG4D9o709FG4T1VQZ8=
github.com/longhorn/longhorn-engine v1.8.0-rc4/go.mod h1:Zfkvuuz2ISU1739FDvedhvVmLLpRYYahVici/bUvW3A=
github.com/longhorn/longhorn-spdk-engine v0.0.0-20250116082350-44753b56dd34 h1:0lpPxYX1eyBTD55WJEgdfy8+2M8cXBfCkzMjJT+j/7w=
github.com/longhorn/longhorn-spdk-engine v0.0.0-20250116082350-44753b56dd34/go.mod h1:J+SLXoP08OsyxsyvVjY8WUVUb2zQNh3KmeMy6YNW318=
github.com/longhorn/sparse-tools v0.0.0-20241216160947-2b328f0fa59c h1:OFz3haCSPdgiiJvXLBeId/4dPu0dxIEqkQkfNMufLwc=
github.com/longhorn/sparse-tools v0.0.0-20241216160947-2b328f0fa59c/go.mod h1:dfbJqfI8+T9ZCp5zhTYcBi/64hPBNt5/vFF3gTlfMmc=
github.com/longhorn/types v0.0.0-20241225162202-00d3a5fd7502 h1:jgw7nosooLe1NQEdCGzM/nEOFzPcurNO+0PDsicc5+A=
github.com/longhorn/types v0.0.0-20241225162202-00d3a5fd7502/go.mod h1:3jHuVDtpkXQzpnp4prguDBskVRric2kmF8aSPkRJ4jw=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
Expand Down
28 changes: 16 additions & 12 deletions pkg/client/proxy_backing_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import (
rpc "github.com/longhorn/types/pkg/generated/imrpc"
)

func (c *ProxyClient) SPDKBackingImageCreate(name, backingImageUUID, diskUUID, checksum, fromAddress, srcLvsUUID string, size uint64) (*api.BackingImage, error) {
func (c *ProxyClient) SPDKBackingImageCreate(name, backingImageUUID, diskUUID, checksum, fromAddress, srcLvsUUID, srcBackingImageName, encryption string, size uint64, credential map[string]string) (*api.BackingImage, error) {
input := map[string]string{
"name": name,
"backingImageUUID": backingImageUUID,
"checksum": checksum,
"diskUUID": diskUUID,
"name": name,
"backingImageUUID": backingImageUUID,
"diskUUID": diskUUID,
"srcBackingImageName": srcBackingImageName,
"encryption": encryption,
}

if err := validateProxyMethodParameters(input); err != nil {
Expand All @@ -34,13 +35,16 @@ func (c *ProxyClient) SPDKBackingImageCreate(name, backingImageUUID, diskUUID, c
defer cancel()

resp, err := client.SPDKBackingImageCreate(ctx, &rpc.SPDKBackingImageCreateRequest{
Name: name,
BackingImageUuid: backingImageUUID,
DiskUuid: diskUUID,
Size: size,
Checksum: checksum,
FromAddress: fromAddress,
SrcLvsUuid: srcLvsUUID,
Name: name,
BackingImageUuid: backingImageUUID,
DiskUuid: diskUUID,
Size: size,
Checksum: checksum,
FromAddress: fromAddress,
SrcLvsUuid: srcLvsUUID,
SrcBackingImageName: srcBackingImageName,
Encryption: encryption,
Credential: credential,
})
if err != nil {
return nil, err
Expand Down
5 changes: 4 additions & 1 deletion pkg/proxy/backing_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ func (p *Proxy) SPDKBackingImageCreate(ctx context.Context, req *rpc.SPDKBacking
"Checksum": req.Checksum,
"FromAddress": req.FromAddress,
"SrcLvsUuid": req.SrcLvsUuid,
"SrcBackingImage": req.SrcBackingImageName,
"Encryption": req.Encryption,
})

log.Info("Backing Image Server: Creating SPDk Backing Image")
ret, err := p.spdkLocalClient.BackingImageCreate(req.Name, req.BackingImageUuid, req.DiskUuid, req.Size, req.Checksum, req.FromAddress, req.SrcLvsUuid)
ret, err := p.spdkLocalClient.BackingImageCreate(req.Name, req.BackingImageUuid, req.DiskUuid, req.Size, req.Checksum,
req.FromAddress, req.SrcLvsUuid, req.SrcBackingImageName, req.Encryption, req.Credential)
if err != nil {
return nil, grpcstatus.Error(grpccodes.Internal, err.Error())
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading