Skip to content

Commit

Permalink
feat: support Milvus 2.5 function feature by bypassing SDK
Browse files Browse the repository at this point in the history
Milvus 2.5 introduced the function feature, which is not well-supported by the older SDK versions. The new SDK hides many internal IDs used by the backup tool. To address this, the backup tool now interacts with Milvus directly via gRPC, bypassing the SDK.

Signed-off-by: huanghaoyuanhhy <haoyuan.huang@zilliz.com>
  • Loading branch information
huanghaoyuanhhy committed Jan 7, 2025
1 parent 6d40f12 commit 406695b
Show file tree
Hide file tree
Showing 41 changed files with 5,187 additions and 4,019 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.18.0'
go-version: '1.23'
cache: true

- name: Build
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.18.0'
go-version: '1.23'
cache: true

- name: Build
Expand Down Expand Up @@ -270,7 +270,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.18.0'
go-version: '1.23'
cache: true

- name: Build
Expand Down Expand Up @@ -402,7 +402,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.18.0'
go-version: '1.23'
cache: "true"

- name: Creating kind cluster
Expand Down Expand Up @@ -550,7 +550,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.18.0'
go-version: '1.23'
cache: true

- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.18.0'
go-version: '1.23'
cache: true

- name: Creating kind cluster
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.18.0'
go-version: '1.23'
cache: true

- name: Creating kind cluster
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/perf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.18.0'
go-version: '1.23'
cache: true

- name: Creating kind cluster
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- run: git fetch --force --tags
- uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: 1.23
cache: true
- uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
- run: git fetch --force --tags
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.23
cache: true

- name: Set up QEMU
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

FROM golang:1.18 AS builder
FROM golang:1.23 AS builder

ENV CGO_ENABLED=0

Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
# Variables
BINARY_NAME=milvus-backup
PKG := github.com/zilliztech/milvus-backup
VERSION=$(shell git describe --tags --always)
COMMIT=$(shell git rev-parse --short HEAD)
DATE=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')

LDFLAGS += -X "$(PKG)/version.Version=$(VERSION)"
LDFLAGS += -X "$(PKG)/version.Commit=$(COMMIT)"
LDFLAGS += -X "$(PKG)/version.Date=$(DATE)"

# Default target
all: gen build

# Build the binary
build:
@echo "Building binary..."
GO111MODULE=on CGO_ENABLED=0 go build -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)" -o $(BINARY_NAME)
GO111MODULE=on CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o $(BINARY_NAME)

gen:
./scripts/gen_swag.sh
./scripts/gen_proto.sh

fmt:
@echo Formatting code...
@goimports -w --local $(PKG) ./
@echo Format code done

.PHONY: all build gen
4 changes: 3 additions & 1 deletion cmd/backup_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package cmd
import (
"fmt"
"strings"

"github.com/spf13/cobra"
"github.com/zilliztech/milvus-backup/core/paramtable"
"gopkg.in/yaml.v3"

"github.com/zilliztech/milvus-backup/core/paramtable"
)

var configCmd = &cobra.Command{
Expand Down
3 changes: 2 additions & 1 deletion cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/spf13/cobra"

"github.com/zilliztech/milvus-backup/core"
"github.com/zilliztech/milvus-backup/core/paramtable"
)
Expand All @@ -20,7 +21,7 @@ var checkCmd = &cobra.Command{
params.Init()

context := context.Background()
backupContext := core.CreateBackupContext(context, params)
backupContext := core.CreateBackupContext(context, &params)

resp := backupContext.Check(context)
fmt.Println(resp)
Expand Down
3 changes: 2 additions & 1 deletion cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

jsoniter "github.com/json-iterator/go"
"github.com/spf13/cobra"

"github.com/zilliztech/milvus-backup/core"
"github.com/zilliztech/milvus-backup/core/paramtable"
"github.com/zilliztech/milvus-backup/core/proto/backuppb"
Expand Down Expand Up @@ -35,7 +36,7 @@ var createBackupCmd = &cobra.Command{
params.Init()

context := context.Background()
backupContext := core.CreateBackupContext(context, params)
backupContext := core.CreateBackupContext(context, &params)

start := time.Now().Unix()
var collectionNameArr []string
Expand Down
3 changes: 2 additions & 1 deletion cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/spf13/cobra"

"github.com/zilliztech/milvus-backup/core"
"github.com/zilliztech/milvus-backup/core/paramtable"
"github.com/zilliztech/milvus-backup/core/proto/backuppb"
Expand All @@ -24,7 +25,7 @@ var deleteBackupCmd = &cobra.Command{
params.Init()

context := context.Background()
backupContext := core.CreateBackupContext(context, params)
backupContext := core.CreateBackupContext(context, &params)

resp := backupContext.DeleteBackup(context, &backuppb.DeleteBackupRequest{
BackupName: deleteBackName,
Expand Down
3 changes: 2 additions & 1 deletion cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"

"github.com/spf13/cobra"

"github.com/zilliztech/milvus-backup/core"
"github.com/zilliztech/milvus-backup/core/paramtable"
"github.com/zilliztech/milvus-backup/core/proto/backuppb"
Expand All @@ -27,7 +28,7 @@ var getBackupCmd = &cobra.Command{
params.Init()

context := context.Background()
backupContext := core.CreateBackupContext(context, params)
backupContext := core.CreateBackupContext(context, &params)

resp := backupContext.GetBackup(context, &backuppb.GetBackupRequest{
BackupName: getBackName,
Expand Down
3 changes: 2 additions & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/spf13/cobra"

"github.com/zilliztech/milvus-backup/core"
"github.com/zilliztech/milvus-backup/core/paramtable"
"github.com/zilliztech/milvus-backup/core/proto/backuppb"
Expand All @@ -25,7 +26,7 @@ var listBackupCmd = &cobra.Command{
params.Init()

context := context.Background()
backupContext := core.CreateBackupContext(context, params)
backupContext := core.CreateBackupContext(context, &params)

backups := backupContext.ListBackups(context, &backuppb.ListBackupsRequest{
CollectionName: collectionName,
Expand Down
3 changes: 2 additions & 1 deletion cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

jsoniter "github.com/json-iterator/go"
"github.com/spf13/cobra"

"github.com/zilliztech/milvus-backup/core"
"github.com/zilliztech/milvus-backup/core/paramtable"
"github.com/zilliztech/milvus-backup/core/proto/backuppb"
Expand Down Expand Up @@ -43,7 +44,7 @@ var restoreBackupCmd = &cobra.Command{
params.Init()

context := context.Background()
backupContext := core.CreateBackupContext(context, params)
backupContext := core.CreateBackupContext(context, &params)
log.Info("restore cmd input args", zap.Strings("args", args))
start := time.Now().Unix()
var collectionNameArr []string
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var rootCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
Error(cmd, args, errors.New("unrecognized command"))
},
PersistentPreRun: func(cmd *cobra.Command, args []string){
PersistentPreRun: func(cmd *cobra.Command, args []string) {
setEnvs(yamlOverrides)
},
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"

"github.com/spf13/cobra"

"github.com/zilliztech/milvus-backup/core"
"github.com/zilliztech/milvus-backup/core/paramtable"
)
Expand All @@ -31,7 +32,7 @@ var serverCmd = &cobra.Command{
params.Init()

context := context.Background()
server, err := core.NewServer(context, params, core.Port(port))
server, err := core.NewServer(context, &params, core.Port(port))
if err != nil {
fmt.Errorf("fail to create backup server, %s", err.Error())
}
Expand Down
Loading

0 comments on commit 406695b

Please sign in to comment.