From 39aaf68b8e7e2c8b7469a6740d59cc4e2320e259 Mon Sep 17 00:00:00 2001 From: YLShiJustFly Date: Tue, 29 Aug 2023 16:27:18 +0800 Subject: [PATCH] support spdk tgt Signed-off-by: YLShiJustFly --- Makefile | 1 - cli/command/cmd.go | 2 + cli/command/spdk_target/add.go | 151 ++++++++++++++++++ cli/command/spdk_target/cmd.go | 47 ++++++ cli/command/spdk_target/delete.go | 109 +++++++++++++ cli/command/spdk_target/list.go | 118 ++++++++++++++ cli/command/spdk_target/start.go | 123 ++++++++++++++ cli/command/spdk_target/stop.go | 99 ++++++++++++ go.mod | 35 ++-- go.sum | 61 +++++++ internal/common/common.go | 4 + internal/errno/errno.go | 20 +-- internal/playbook/factory.go | 21 +++ internal/task/scripts/add_spdk_target.go | 79 +++++++++ internal/task/scripts/spdk_target.go | 76 +++++++++ internal/task/step/daemon.go | 3 + internal/task/task/bs/add_spdk_target.go | 125 +++++++++++++++ internal/task/task/bs/delete_spdk_target.go | 106 ++++++++++++ internal/task/task/bs/list_targets.go | 41 +++++ internal/task/task/bs/start_spdk_tgt.go | 168 ++++++++++++++++++++ internal/task/task/bs/stop_spdk_tgt.go | 78 +++++++++ 21 files changed, 1442 insertions(+), 25 deletions(-) create mode 100644 cli/command/spdk_target/add.go create mode 100644 cli/command/spdk_target/cmd.go create mode 100644 cli/command/spdk_target/delete.go create mode 100644 cli/command/spdk_target/list.go create mode 100644 cli/command/spdk_target/start.go create mode 100644 cli/command/spdk_target/stop.go create mode 100644 internal/task/scripts/add_spdk_target.go create mode 100644 internal/task/scripts/spdk_target.go create mode 100644 internal/task/task/bs/add_spdk_target.go create mode 100644 internal/task/task/bs/delete_spdk_target.go create mode 100644 internal/task/task/bs/start_spdk_tgt.go create mode 100644 internal/task/task/bs/stop_spdk_tgt.go diff --git a/Makefile b/Makefile index 4e92ad68c..175ba24d9 100644 --- a/Makefile +++ b/Makefile @@ -73,4 +73,3 @@ upload: lint: go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCILINT_VERSION) $(GOBIN_GOLANGCILINT) run -v - diff --git a/cli/command/cmd.go b/cli/command/cmd.go index a1f6c19f5..577ba9e15 100644 --- a/cli/command/cmd.go +++ b/cli/command/cmd.go @@ -38,6 +38,7 @@ import ( "github.com/opencurve/curveadm/cli/command/pfs" "github.com/opencurve/curveadm/cli/command/playground" "github.com/opencurve/curveadm/cli/command/target" + "github.com/opencurve/curveadm/cli/command/spdk_target" "github.com/opencurve/curveadm/cli/command/website" "github.com/opencurve/curveadm/internal/errno" tools "github.com/opencurve/curveadm/internal/tools/upgrade" @@ -68,6 +69,7 @@ func addSubCommands(cmd *cobra.Command, curveadm *cli.CurveAdm) { disks.NewDisksCommand(curveadm), // curveadm disks ... playground.NewPlaygroundCommand(curveadm), // curveadm playground ... target.NewTargetCommand(curveadm), // curveadm target ... + spdk_target.NewSpdkTargetCommand(curveadm), // curveadm target ... pfs.NewPFSCommand(curveadm), // curveadm pfs ... monitor.NewMonitorCommand(curveadm), // curveadm monitor ... http.NewHttpCommand(curveadm), // curveadm http diff --git a/cli/command/spdk_target/add.go b/cli/command/spdk_target/add.go new file mode 100644 index 000000000..713ac3460 --- /dev/null +++ b/cli/command/spdk_target/add.go @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2021 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-08 + * Author: Jingli Chen (Wine93) + */ + +package spdk_target + +import ( + "github.com/fatih/color" + "github.com/opencurve/curveadm/cli/cli" + "github.com/opencurve/curveadm/cli/command/client" + comm "github.com/opencurve/curveadm/internal/common" + "github.com/opencurve/curveadm/internal/configure" + "github.com/opencurve/curveadm/internal/configure/topology" + "github.com/opencurve/curveadm/internal/errno" + "github.com/opencurve/curveadm/internal/playbook" + "github.com/opencurve/curveadm/internal/task/task/bs" + cliutil "github.com/opencurve/curveadm/internal/utils" + utils "github.com/opencurve/curveadm/internal/utils" + "github.com/spf13/cobra" +) + +var ( + ADD_PLAYBOOK_STEPS = []int{ + //playbook.CREATE_VOLUME, + playbook.ADD_TARGET, + } +) + +type addOptions struct { + image string + host string + size string + create bool + filename string + blocksize string +} + +func checkAddOptions(curveadm *cli.CurveAdm, options addOptions) error { + if _, _, err := client.ParseImage(options.image); err != nil { + return err + } else if _, err = client.ParseSize(options.size); err != nil { + return err + } else if _, err = client.ParseBlockSize(options.blocksize); err != nil { + return err + } else if !utils.PathExist(options.filename) { + return errno.ERR_CLIENT_CONFIGURE_FILE_NOT_EXIST. + F("file path: %s", utils.AbsPath(options.filename)) + } + return nil +} + +func NewAddCommand(curveadm *cli.CurveAdm) *cobra.Command { + var options addOptions + + cmd := &cobra.Command{ + Use: "add USER:VOLUME [OPTIONS]", + Short: "Add a spdk target of CurveBS", + Args: cliutil.ExactArgs(1), + PreRunE: func(cmd *cobra.Command, args []string) error { + options.image = args[0] + return checkAddOptions(curveadm, options) + }, + RunE: func(cmd *cobra.Command, args []string) error { + options.image = args[0] + return runAdd(curveadm, options) + }, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVar(&options.host, "host", "localhost", "Specify spdk target host") + flags.BoolVar(&options.create, "create", false, "Create volume if not exist") + flags.StringVar(&options.size, "size", "10GiB", "Specify volume size") + flags.StringVarP(&options.filename, "conf", "c", "client.yaml", "Specify client configuration file") + flags.StringVar(&options.blocksize, "blocksize", "4096B", "Specify volume blocksize") + return cmd +} + +func genAddPlaybook(curveadm *cli.CurveAdm, + ccs []*configure.ClientConfig, + options addOptions) (*playbook.Playbook, error) { + user, name, _ := client.ParseImage(options.image) + size, _ := client.ParseSize(options.size) + blocksize, _ := client.ParseBlockSize(options.blocksize) + steps := ADD_PLAYBOOK_STEPS + pb := playbook.NewPlaybook(curveadm) + for _, step := range steps { + pb.AddStep(&playbook.PlaybookStep{ + Type: step, + Configs: ccs, + Options: map[string]interface{}{ + comm.KEY_SPDK_TARGET_OPTIONS: bs.SpdkTargetOption{ + Host: options.host, + User: user, + Volume: name, + Size: uint64(size), + Blocksize: blocksize, + Create: options.create, + }, + }, + }) + } + return pb, nil +} + +func runAdd(curveadm *cli.CurveAdm, options addOptions) error { + // 1) parse client configure + cc, err := configure.ParseClientConfig(options.filename) + if err != nil { + return err + } else if cc.GetKind() != topology.KIND_CURVEBS { + return errno.ERR_REQUIRE_CURVEBS_KIND_CLIENT_CONFIGURE_FILE. + F("kind: %s", cc.GetKind()) + } + + // 2) generate map playbook + pb, err := genAddPlaybook(curveadm, []*configure.ClientConfig{cc}, options) + if err != nil { + return err + } + + // 3) run playground + err = pb.Run() + if err != nil { + return err + } + + // 4) print success prompt + curveadm.WriteOutln("") + curveadm.WriteOutln(color.GreenString("Add target (%s) to %s success ^_^"), + options.image, options.host) + return nil +} diff --git a/cli/command/spdk_target/cmd.go b/cli/command/spdk_target/cmd.go new file mode 100644 index 000000000..57253f2d9 --- /dev/null +++ b/cli/command/spdk_target/cmd.go @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-08 + * Author: Jingli Chen (Wine93) + */ + +package spdk_target + +import ( + "github.com/opencurve/curveadm/cli/cli" + cliutil "github.com/opencurve/curveadm/internal/utils" + "github.com/spf13/cobra" +) + +func NewSpdkTargetCommand(curveadm *cli.CurveAdm) *cobra.Command { + cmd := &cobra.Command{ + Use: "spdktarget", + Short: "Manage spdk target of CurveBS", + Args: cliutil.NoArgs, + RunE: cliutil.ShowHelp(curveadm.Err()), + } + + cmd.AddCommand( + NewStartCommand(curveadm), + NewStopCommand(curveadm), + NewAddCommand(curveadm), + NewDeleteCommand(curveadm), + NewListCommand(curveadm), + ) + return cmd +} diff --git a/cli/command/spdk_target/delete.go b/cli/command/spdk_target/delete.go new file mode 100644 index 000000000..33aca680a --- /dev/null +++ b/cli/command/spdk_target/delete.go @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2021 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-09 + * Author: Jingli Chen (Wine93) + */ + +package spdk_target + +import ( + "github.com/fatih/color" + "github.com/opencurve/curveadm/cli/cli" + comm "github.com/opencurve/curveadm/internal/common" + "github.com/opencurve/curveadm/internal/playbook" + "github.com/opencurve/curveadm/internal/task/task/bs" + cliutil "github.com/opencurve/curveadm/internal/utils" + "github.com/spf13/cobra" +) + +var ( + DELETE_PLAYBOOK_STEPS = []int{ + playbook.DELETE_TARGET, + } +) + +type deleteOptions struct { + host string + sockname string + rpcpath string + tid string +} + +func NewDeleteCommand(curveadm *cli.CurveAdm) *cobra.Command { + var options deleteOptions + + cmd := &cobra.Command{ + Use: "rm TID [OPTIONS]", + Aliases: []string{"delete"}, + Short: "Delete a spdk target of CurveBS", + Args: cliutil.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + options.sockname = args[0] + options.rpcpath = args[1] + options.tid = args[2] + return runDelete(curveadm, options) + }, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVar(&options.host, "host", "localhost", "Specify spdk target host") + + return cmd +} + +func genDeletePlaybook(curveadm *cli.CurveAdm, options deleteOptions) (*playbook.Playbook, error) { + steps := DELETE_PLAYBOOK_STEPS + pb := playbook.NewPlaybook(curveadm) + for _, step := range steps { + pb.AddStep(&playbook.PlaybookStep{ + Type: step, + Configs: nil, + Options: map[string]interface{}{ + comm.KEY_SPDK_TARGET_OPTIONS: bs.SpdkTargetOption{ + Host: options.host, + Sockname: options.sockname, + RpcPath: options.rpcpath, + Tid: options.tid, + }, + }, + }) + } + return pb, nil +} + +func runDelete(curveadm *cli.CurveAdm, options deleteOptions) error { + // 1) generate list playbook + pb, err := genDeletePlaybook(curveadm, options) + if err != nil { + return err + } + + // 2) run playground + err = pb.Run() + if err != nil { + return err + } + + // 3) print targets + curveadm.WriteOutln("") + curveadm.WriteOutln(color.GreenString("Delete target (tid=%s) on %s success ^_^"), + options.tid, options.host) + return nil +} diff --git a/cli/command/spdk_target/list.go b/cli/command/spdk_target/list.go new file mode 100644 index 000000000..d5845e2ee --- /dev/null +++ b/cli/command/spdk_target/list.go @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2021 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-09 + * Author: Jingli Chen (Wine93) + */ + +package spdk_target + +import ( + "github.com/opencurve/curveadm/cli/cli" + comm "github.com/opencurve/curveadm/internal/common" + "github.com/opencurve/curveadm/internal/playbook" + "github.com/opencurve/curveadm/internal/task/step" + "github.com/opencurve/curveadm/internal/task/task/bs" + "github.com/opencurve/curveadm/internal/tui" + cliutil "github.com/opencurve/curveadm/internal/utils" + "github.com/spf13/cobra" +) + +var ( + LIST_PLAYBOOK_STEPS = []int{ + playbook.LIST_TARGETS, + } +) + +type listOptions struct { + host string + rpcpath string + sockname string +} + +func NewListCommand(curveadm *cli.CurveAdm) *cobra.Command { + var options listOptions + + cmd := &cobra.Command{ + Use: "ls [OPTIONS]", + Aliases: []string{"list"}, + Short: "List Spdk targets", + Args: cliutil.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return runList(curveadm, options) + }, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVar(&options.host, "host", "localhost", "Specify spdk target host") + + return cmd +} + +func genListPlaybook(curveadm *cli.CurveAdm, options listOptions) (*playbook.Playbook, error) { + steps := LIST_PLAYBOOK_STEPS + pb := playbook.NewPlaybook(curveadm) + for _, step := range steps { + pb.AddStep(&playbook.PlaybookStep{ + Type: step, + Configs: nil, + Options: map[string]interface{}{ + comm.KEY_SPDK_TARGET_OPTIONS: bs.SpdkTargetOption{ + Host: options.host, + RpcPath: options.rpcpath, + Sockname: options.sockname, + }, + }, + }) + } + return pb, nil +} + +func displayTargets(curveadm *cli.CurveAdm) { + targets := []step.Target{} + value := curveadm.MemStorage().Get(comm.KEY_ALL_TARGETS) + if value != nil { + m := value.(map[string]*step.Target) + for _, target := range m { + targets = append(targets, *target) + } + } + + output := tui.FormatTargets(targets) + curveadm.WriteOutln("") + curveadm.WriteOut(output) +} + +func runList(curveadm *cli.CurveAdm, options listOptions) error { + // 1) generate list playbook + pb, err := genListPlaybook(curveadm, options) + if err != nil { + return err + } + + // 2) run playground + err = pb.Run() + if err != nil { + return err + } + + // 3) print targets + displayTargets(curveadm) + return nil +} diff --git a/cli/command/spdk_target/start.go b/cli/command/spdk_target/start.go new file mode 100644 index 000000000..24d969655 --- /dev/null +++ b/cli/command/spdk_target/start.go @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2022 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-08 + * Author: Jingli Chen (Wine93) + */ + +package spdk_target + +import ( + "github.com/fatih/color" + "github.com/opencurve/curveadm/cli/cli" + comm "github.com/opencurve/curveadm/internal/common" + "github.com/opencurve/curveadm/internal/configure" + "github.com/opencurve/curveadm/internal/configure/topology" + "github.com/opencurve/curveadm/internal/errno" + "github.com/opencurve/curveadm/internal/playbook" + "github.com/opencurve/curveadm/internal/task/task/bs" + cliutil "github.com/opencurve/curveadm/internal/utils" + "github.com/spf13/cobra" +) + +var ( + START_PLAYBOOK_STEPS = []int{ + playbook.START_TARGET_DAEMON, + } +) + +type startOptions struct { + host string + filename string + binarypath string + cpumask string + sockname string + iscsilogpath string +} + +func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command { + var options startOptions + + cmd := &cobra.Command{ + Use: "start [OPTIONS]", + Short: "Start target deamon", + Args: cliutil.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return runStart(curveadm, options) + }, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVar(&options.host, "host", "localhost", "Specify spdk target host") + flags.StringVarP(&options.filename, "conf", "c", "client.yaml", "Specify client configuration file") + + return cmd +} + +func genStartPlaybook(curveadm *cli.CurveAdm, + ccs []*configure.ClientConfig, + options startOptions) (*playbook.Playbook, error) { + steps := START_PLAYBOOK_STEPS + pb := playbook.NewPlaybook(curveadm) + for _, step := range steps { + pb.AddStep(&playbook.PlaybookStep{ + Type: step, + Configs: ccs, + Options: map[string]interface{}{ + comm.KEY_SPDK_TARGET_OPTIONS: bs.SpdkTargetOption{ + Host: options.host, + BinaryPath: options.binarypath, + Cpumask: options.cpumask, + Sockname: options.sockname, + ISCSIlogpath: options.iscsilogpath, + }, + }, + }) + } + return pb, nil +} + +func runStart(curveadm *cli.CurveAdm, options startOptions) error { + // 1) parse client configure + cc, err := configure.ParseClientConfig(options.filename) + if err != nil { + return err + } else if cc.GetKind() != topology.KIND_CURVEBS { + return errno.ERR_REQUIRE_CURVEBS_KIND_CLIENT_CONFIGURE_FILE. + F("kind: %s", cc.GetKind()) + } + + // 2) generate map playbook + pb, err := genStartPlaybook(curveadm, []*configure.ClientConfig{cc}, options) + if err != nil { + return err + } + + // 3) run playground + err = pb.Run() + if err != nil { + return err + } + + // 4) print success prompt + curveadm.WriteOutln("") + curveadm.WriteOutln(color.GreenString("Start spdk target daemon on %s success ^_^"), + options.host) + return nil +} diff --git a/cli/command/spdk_target/stop.go b/cli/command/spdk_target/stop.go new file mode 100644 index 000000000..1b18b5a15 --- /dev/null +++ b/cli/command/spdk_target/stop.go @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2022 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-08 + * Author: Jingli Chen (Wine93) + */ + +package spdk_target + +import ( + "github.com/fatih/color" + "github.com/opencurve/curveadm/cli/cli" + comm "github.com/opencurve/curveadm/internal/common" + "github.com/opencurve/curveadm/internal/playbook" + "github.com/opencurve/curveadm/internal/task/task/bs" + cliutil "github.com/opencurve/curveadm/internal/utils" + "github.com/spf13/cobra" +) + +var ( + STOP_PLAYBOOK_STEPS = []int{ + playbook.STOP_TARGET_DAEMON, + } +) + +type stopOptions struct { + host string +} + +func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command { + var options stopOptions + + cmd := &cobra.Command{ + Use: "stop [OPTIONS]", + Short: "Stop spdk target deamon", + Args: cliutil.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return runStop(curveadm, options) + }, + DisableFlagsInUseLine: true, + } + + flags := cmd.Flags() + flags.StringVar(&options.host, "host", "localhost", "Specify spdk target host") + + return cmd +} + +func genStopPlaybook(curveadm *cli.CurveAdm, options stopOptions) (*playbook.Playbook, error) { + steps := STOP_PLAYBOOK_STEPS + pb := playbook.NewPlaybook(curveadm) + for _, step := range steps { + pb.AddStep(&playbook.PlaybookStep{ + Type: step, + Configs: nil, + Options: map[string]interface{}{ + comm.KEY_SPDK_TARGET_OPTIONS: bs.SpdkTargetOption{ + Host: options.host, + }, + }, + }) + } + return pb, nil +} + +func runStop(curveadm *cli.CurveAdm, options stopOptions) error { + // 1) generate stop playbook + pb, err := genStopPlaybook(curveadm, options) + if err != nil { + return err + } + + // 2) run playground + err = pb.Run() + if err != nil { + return err + } + + // 3) print success prompt + curveadm.WriteOutln("") + curveadm.WriteOutln(color.GreenString("Stop spdk target daemon on %s success ^_^"), + options.host) + return nil +} diff --git a/go.mod b/go.mod index a5f78bf36..26a5d0d66 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/google/uuid v1.3.0 github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629 github.com/kpango/glg v1.6.14 - github.com/mattn/go-sqlite3 v1.14.16 + github.com/mattn/go-sqlite3 v1.14.17 github.com/mcuadros/go-defaults v1.2.0 github.com/melbahja/goph v1.3.0 github.com/mitchellh/hashstructure/v2 v2.0.2 @@ -24,7 +24,7 @@ require ( github.com/stretchr/testify v1.8.2 github.com/vbauerster/mpb/v7 v7.5.3 go.uber.org/zap v1.24.0 - golang.org/x/crypto v0.8.0 + golang.org/x/crypto v0.13.0 ) require ( @@ -33,11 +33,13 @@ require ( github.com/VividCortex/ewma v1.2.0 // indirect github.com/Wine93/grace v0.0.0-20221021033009-7d0348013a3c // indirect github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect + github.com/andybalholm/brotli v1.0.5 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bytedance/sonic v1.8.7 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/cloudflare/circl v1.3.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/docker v24.0.1+incompatible // indirect @@ -52,6 +54,7 @@ require ( github.com/facebookgo/stats v0.0.0-20151006221625-1b76add642e4 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fvbommel/sortorder v1.1.0 // indirect + github.com/gaukas/godicttls v0.0.4 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-gonic/gin v1.9.0 // indirect github.com/go-playground/locales v0.14.1 // indirect @@ -62,15 +65,16 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect + github.com/google/pprof v0.0.0-20230912144702-c363fe2c2ed8 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/imroc/req/v3 v3.33.2 // indirect + github.com/imroc/req/v3 v3.42.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect + github.com/klauspost/compress v1.16.7 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kpango/fastime v1.1.6 // indirect github.com/kr/fs v0.1.0 // indirect @@ -86,7 +90,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/morikuni/aec v1.0.0 // indirect - github.com/onsi/ginkgo/v2 v2.9.2 // indirect + github.com/onsi/ginkgo/v2 v2.12.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/pelletier/go-toml/v2 v2.0.7 // indirect @@ -99,8 +103,9 @@ require ( github.com/prometheus/procfs v0.9.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/qtls-go1-19 v0.3.2 // indirect - github.com/quic-go/qtls-go1-20 v0.2.2 // indirect - github.com/quic-go/quic-go v0.33.0 // indirect + github.com/quic-go/qtls-go1-20 v0.3.4 // indirect + github.com/quic-go/quic-go v0.38.1 // indirect + github.com/refraction-networking/utls v1.5.3 // indirect github.com/rivo/uniseg v0.4.3 // indirect github.com/sevlyar/go-daemon v0.1.6 // indirect github.com/sirupsen/logrus v1.9.0 // indirect @@ -115,14 +120,14 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect - golang.org/x/mod v0.10.0 // indirect - golang.org/x/net v0.9.0 // indirect - golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.7.0 // indirect - golang.org/x/term v0.7.0 // indirect - golang.org/x/text v0.9.0 // indirect - golang.org/x/tools v0.8.0 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/mod v0.12.0 // indirect + golang.org/x/net v0.15.0 // indirect + golang.org/x/sync v0.3.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.13.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index 2de2646ed..51bf08c4c 100644 --- a/go.sum +++ b/go.sum @@ -54,6 +54,8 @@ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpH github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -86,6 +88,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e85keuznYcH5rqI438v41pKcBl4ZxQ= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA= +github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -150,6 +154,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQmYw= github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= +github.com/gaukas/godicttls v0.0.4 h1:NlRaXb3J6hAnTmWdsEKb9bcSBD6BvcIjdGdeb0zfXbk= +github.com/gaukas/godicttls v0.0.4/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= @@ -161,6 +167,7 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -245,6 +252,8 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230406165453-00490a63f317 h1:hFhpt7CTmR3DX+b4R19ydQFtofxT0Sv3QsKNMVQYTMQ= github.com/google/pprof v0.0.0-20230406165453-00490a63f317/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/pprof v0.0.0-20230912144702-c363fe2c2ed8 h1:gpptm606MZYGaMHMsB4Srmb6EbW/IVHnt04rcMXnkBQ= +github.com/google/pprof v0.0.0-20230912144702-c363fe2c2ed8/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -271,6 +280,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imroc/req/v3 v3.33.2 h1:mqphLIo++p+IPYdjgP/Wd5rqXUjKvuEIst2U+EsLIwQ= github.com/imroc/req/v3 v3.33.2/go.mod h1:cZ+7C3L/AYOr4tLGG16hZF90F1WzAdAdzt1xFSlizXY= +github.com/imroc/req/v3 v3.42.0 h1:g7wWva3aIJI02mrnqmXe0N5SVkXHQPsYN3Tmw2ZHn3U= +github.com/imroc/req/v3 v3.42.0/go.mod h1:W7dOrfQORA9nFoj+CafIZ6P5iyk+rWdbp2sffOAvABU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= @@ -293,6 +304,8 @@ github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uia github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= +github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= @@ -331,6 +344,8 @@ github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= +github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= @@ -363,9 +378,15 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= +github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= +github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= +github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI= +github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= +github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -421,8 +442,16 @@ github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc8 github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= +github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM= +github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= +github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA= +github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE= +github.com/quic-go/quic-go v0.38.1/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= +github.com/refraction-networking/utls v1.5.3 h1:Ds5Ocg1+MC1ahNx5iBEcHe0jHeLaA/fLey61EENm7ro= +github.com/refraction-networking/utls v1.5.3/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -523,6 +552,10 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -535,6 +568,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -561,6 +596,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -600,6 +637,10 @@ golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -622,6 +663,10 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -678,11 +723,19 @@ golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -693,6 +746,10 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -750,6 +807,10 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/common/common.go b/internal/common/common.go index c12b801d0..e868795da 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -120,6 +120,10 @@ const ( KEY_TARGET_OPTIONS = "TARGET_OPTIONS" KEY_ALL_TARGETS = "ALL_TARGETS" + // spdk_target + KEY_SPDK_TARGET_OPTIONS = "SPDK_TARGET_OPTIONS" + KEY_ALL_SPDK_TARGETS = "ALL_SPDK_TARGETS" + // playground KEY_ALL_PLAYGROUNDS_STATUS = "ALL_PLAYGROUNDS_STATUS" PLAYGROUDN_STATUS_LOSED = "Losed" diff --git a/internal/errno/errno.go b/internal/errno/errno.go index ccdbb2c3f..3d97771fe 100644 --- a/internal/errno/errno.go +++ b/internal/errno/errno.go @@ -419,15 +419,17 @@ var ( ERR_CLIENT_ID_NOT_FOUND = EC(410022, "client id not found") // 420: common (curvebs client) - ERR_VOLUME_ALREADY_MAPPED = EC(420000, "volume already mapped") - ERR_VOLUME_CONTAINER_LOSED = EC(420001, "volume container is losed") - ERR_VOLUME_CONTAINER_ABNORMAL = EC(420002, "volume container is abnormal") - ERR_CREATE_VOLUME_FAILED = EC(420003, "create volume failed") - ERR_MAP_VOLUME_FAILED = EC(420004, "map volume to NBD device failed") - ERR_ENCODE_VOLUME_INFO_TO_JSON_FAILED = EC(420005, "encode volume info to json failed") - ERR_UNMAP_VOLUME_FAILED = EC(420006, "unmap volume failed") - ERR_OLD_TARGET_DAEMON_IS_ABNORMAL = EC(420007, "old target daemon is abnormal") - ERR_TARGET_DAEMON_IS_ABNORMAL = EC(420008, "target daemon is abnormal") + ERR_VOLUME_ALREADY_MAPPED = EC(420000, "volume already mapped") + ERR_VOLUME_CONTAINER_LOSED = EC(420001, "volume container is losed") + ERR_VOLUME_CONTAINER_ABNORMAL = EC(420002, "volume container is abnormal") + ERR_CREATE_VOLUME_FAILED = EC(420003, "create volume failed") + ERR_MAP_VOLUME_FAILED = EC(420004, "map volume to NBD device failed") + ERR_ENCODE_VOLUME_INFO_TO_JSON_FAILED = EC(420005, "encode volume info to json failed") + ERR_UNMAP_VOLUME_FAILED = EC(420006, "unmap volume failed") + ERR_OLD_TARGET_DAEMON_IS_ABNORMAL = EC(420007, "old target daemon is abnormal") + ERR_TARGET_DAEMON_IS_ABNORMAL = EC(420008, "target daemon is abnormal") + ERR_OLD_SPDK_TARGET_DAEMON_IS_ABNORMAL = EC(420008, "old spdk target daemon is abnormal") + ERR_SPDK_TARGET_DAEMON_IS_ABNORMAL = EC(420009, "spdk target daemon is abnormal") // 430: common (curvefs client) ERR_FS_PATH_ALREADY_MOUNTED = EC(430000, "path already mounted") diff --git a/internal/playbook/factory.go b/internal/playbook/factory.go index 68ce8993d..7c108c2b5 100644 --- a/internal/playbook/factory.go +++ b/internal/playbook/factory.go @@ -121,6 +121,13 @@ const ( DELETE_TARGET LIST_TARGETS + // bs/target + START_SPDK_TARGET_DAEMON + STOP_SPDK_TARGET_DAEMON + ADD_SPDK_TARGET + DELETE_SPDK_TARGET + LIST_SPDK_TARGETS + // fs CHECK_CLIENT_S3 MOUNT_FILESYSTEM @@ -275,6 +282,7 @@ func (p *Playbook) createTasks(step *PlaybookStep) (*tasks.Tasks, error) { t, err = bs.NewMapTask(curveadm, config.GetCC(i)) case UNMAP_IMAGE: t, err = bs.NewUnmapTask(curveadm, nil) + // bs/target case START_TARGET_DAEMON: t, err = bs.NewStartTargetDaemonTask(curveadm, config.GetCC(i)) @@ -286,6 +294,19 @@ func (p *Playbook) createTasks(step *PlaybookStep) (*tasks.Tasks, error) { t, err = bs.NewDeleteTargetTask(curveadm, nil) case LIST_TARGETS: t, err = bs.NewListTargetsTask(curveadm, nil) + + // bs/target + case START_SPDK_TARGET_DAEMON: + t, err = bs.NewStartSpdkTargetDaemonTask(curveadm, config.GetCC(i)) + case STOP_SPDK_TARGET_DAEMON: + t, err = bs.NewStopSpdkTargetDaemonTask(curveadm, nil) + case ADD_SPDK_TARGET: + t, err = bs.NewAddSpdkTargetTask(curveadm, config.GetCC(i)) + case DELETE_SPDK_TARGET: + t, err = bs.NewDeleteSpdkTargetTask(curveadm, nil) + case LIST_SPDK_TARGETS: + t, err = bs.NewListSpdkTargetsTask(curveadm, nil) + // fs case CHECK_CLIENT_S3: t, err = checker.NewClientS3ConfigureTask(curveadm, config.GetCC(i)) diff --git a/internal/task/scripts/add_spdk_target.go b/internal/task/scripts/add_spdk_target.go new file mode 100644 index 000000000..ec38f992b --- /dev/null +++ b/internal/task/scripts/add_spdk_target.go @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-08 + * Author: Jingli Chen (Wine93) + */ + +package scripts + +/* + * Usage: target USER VOLUME CREATE SIZE + * Example: target curve test true 10 + * See Also: https://linux.die.net/man/8/tgtadm + */ + +var ADD__SPDK_TARGET = ` +#!/usr/bin/env bash + +g_sockname="/var/tmp/spdk.sock" +g_volume=$2 +g_originbdev=$3 +g_curvebdev=$4 +g_rpcpath="/usr/libexec/spdk/scripts/rpc.py" +g_blocksize=$6 +g_cdbpath=$7 +g_isexclusive=$8 +g_targetip=$9 +g_targetport=$10 +g_initiatorip=$11 +g_initiatormask=$12 +g_user=$13 +g_create=$14 +g_size=%15 +g_volumename=%16 + +mkdir -p /curvebs/nebd/data/lock +touch /etc/curve/curvetab + +mkdir -p /curvebs/nebd/data/lock +touch /etc/curve/curvetab +if [ $g_create == "true" ]; then + output=$(curve_ops_tool create -userName=$g_user -fileName=$g_volume -fileLength=$g_size) + if [ $? -ne 0 ]; then + if [ "$output" != "CreateFile fail with errCode: 101" ]; then + exit 1 + fi + fi +fi +if ${g_rpcpath} -s ${g_sockname} iscsi_get_target_nodes >/dev/null | grep "$g_curvebdev" | grep name >/dev/null; then + echo "spdk target is already created, please try anther name" + exit 1 +fi +${g_rpcpath} -s ${g_sockname} bdev_aio_create ${g_volume} ${g_originbdev} 512 >/dev/null +${g_rpcpath} -s ${g_sockname} bdev_cdb_create -b ${g_curvebdev} --cbd ${g_cbdpath} --exclusive=${g_isexclusive} --blocksize=${g_blocksize} >/dev/null +${g_rpcpath} -s ${g_sockname} bdev_ocf_create bdev_ocf_create myocf wb ${g_originbdev} > /dev/null +${g_rpcpath} -s ${g_sockname} iscsi_create_portal_group 1 ${g_targetip}:${g_targetport} > /dev/null +${g_rpcpath} -s ${g_sockname} iscsi_create_initiator_group 2 ANY ${g_initiatorip}/${g_initiatormask} > /dev/null + +${g_rpcpath} -s ${g_sockname} iscsi_create_target_node ${g_volumename} "Data Disk1" "myocf:0 ${g_originbdev}:1" 1:2 64 -d > /dev/null + + +exit 0 + +` diff --git a/internal/task/scripts/spdk_target.go b/internal/task/scripts/spdk_target.go new file mode 100644 index 000000000..da50c8807 --- /dev/null +++ b/internal/task/scripts/spdk_target.go @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-08 + * Author: Jingli Chen (Wine93) + */ + +package scripts + +/* + * Usage: target USER VOLUME CREATE SIZE + * Example: target curve test true 10 + * See Also: https://linux.die.net/man/8/tgtadm + */ + +var SPDK_TARGET = ` +#!/usr/bin/env bash + +g_binarypath="/usr/local/bin/vhost" +g_cpumask=$2 +g_sockname="/var/tmp/spdk.sock" +g_iscsi_log="/var/log/spdk.log" + +mkdir -p /curvebs/nebd/data/lock +touch /etc/curve/curvetab + +process_name="iscsi_tgt" + +if ps aux | grep -v grep | grep "$process_name" >/dev/null; then + echo "spdk iscsi_tgt has already been started, now exit!" + exit 1 +fi + +nohup ${g_binarypath} -m ${g_cpumask} -r ${g_sockname} > ${g_iscsi_log} 2>&1 & + +i=1 +while true +do + result=$(cat $VSDK_LOG_FILE | grep "please run rpc") + if [[ "$result" != "" ]]; then + i=0 + break + else + sleep 0.1 + i++ + fi + if [ "$i" -ge 50 ]; then + break + fi +done + +if [ "$i" -eq 0]; then + echo "spdk iscsi_tgt started success!" +else + echo "wait for 5s, spdk iscsi_tgt has not launched, please try again!" + exit 1 +fi + +exit 0 + +` diff --git a/internal/task/step/daemon.go b/internal/task/step/daemon.go index 71a0cd4e1..e84fb773d 100644 --- a/internal/task/step/daemon.go +++ b/internal/task/step/daemon.go @@ -77,6 +77,9 @@ type AddDaemonTask struct { type DelDaemonTask struct { ContainerId *string + Cmd string + Args []string + TaskName string Tid string MemStorage *utils.SafeMap module.ExecOptions diff --git a/internal/task/task/bs/add_spdk_target.go b/internal/task/task/bs/add_spdk_target.go new file mode 100644 index 000000000..75e127535 --- /dev/null +++ b/internal/task/task/bs/add_spdk_target.go @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2021 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-08 + * Author: Jingli Chen (Wine93) + */ + +package bs + +import ( + "fmt" + "strconv" + + "github.com/opencurve/curveadm/cli/cli" + comm "github.com/opencurve/curveadm/internal/common" + "github.com/opencurve/curveadm/internal/configure" + "github.com/opencurve/curveadm/internal/task/scripts" + "github.com/opencurve/curveadm/internal/task/step" + "github.com/opencurve/curveadm/internal/task/task" +) + +type SpdkTargetOption struct { + Host string + User string + Cpumask string + Create bool + Tid string + Volume string + OriginBdevname string + CurveBdevname string + Size uint64 + Blocksize uint64 + CbdPath string + IsExcusive bool + TargetIP string + TargetPort uint64 + InitiatorIP string + InitiatorMask uint64 + VolumeName string +} + +func NewAddSpdkTargetTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { + options := curveadm.MemStorage().Get(comm.KEY_SPDK_TARGET_OPTIONS).(SpdkTargetOption) + user, volume := options.User, options.Volume + hc, err := curveadm.GetHost(options.Host) + if err != nil { + return nil, err + } + + subname := fmt.Sprintf("host=%s volume=%s", options.Host, volume) + t := task.NewTask("Add SpdkTarget", subname, hc.GetSSHConfig()) + + // add step + var output string + containerId := DEFAULT_SPDK_TGT_CONTAINER_NAME + targetScriptPath := "/curvebs/tools/sbin/add_spdk_target.sh" + targetScript := scripts.TARGET + cmd := fmt.Sprintf("/bin/bash %s %s %s %s %d %s %v %s %d %s %d %s %v %d %s", + targetScriptPath, options.Volume, + options.OriginBdevname, options.CurveBdevname, options.Blocksize, options.CbdPath, + options.IsExcusive, options.TargetIP, options.TargetPort, + options.InitiatorIP, options.InitiatorMask, + user, options.Create, options.Size, options.VolumeName) + toolsConf := fmt.Sprintf(FORMAT_TOOLS_CONF, cc.GetClusterMDSAddr()) + + t.AddStep(&step.ListContainers{ + ShowAll: true, + Format: "'{{.ID}} {{.Status}}'", + Quiet: true, + Filter: fmt.Sprintf("name=%s", DEFAULT_SPDK_TGT_CONTAINER_NAME), + Out: &output, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step2CheckSpdkTgtStatus{ + output: &output, + }) + + t.AddStep(&step.InstallFile{ // install tools.conf + Content: &toolsConf, + ContainerId: &containerId, + ContainerDestPath: "/etc/curve/tools.conf", + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.InstallFile{ // install spdk_target.sh + Content: &targetScript, + ContainerId: &containerId, + ContainerDestPath: targetScriptPath, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.ContainerExec{ + ContainerId: &containerId, + Command: cmd, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.AddDaemonTask{ // install addSpdkTarget.task + ContainerId: &containerId, + Cmd: "/bin/bash", + Args: []string{targetScriptPath, options.Volume, + options.OriginBdevname, options.CurveBdevname, strconv.FormatUint(options.Blocksize, 10), + options.CbdPath, strconv.FormatBool(options.IsExcusive), + options.TargetIP, strconv.FormatUint(options.TargetPort, 10), + options.InitiatorIP, strconv.FormatUint(options.InitiatorMask, 10), + user, strconv.FormatBool(options.Create), strconv.FormatUint(options.Size, 10), + options.VolumeName}, + TaskName: "addSpdkTarget" + TranslateVolumeName(volume, user), + ExecOptions: curveadm.ExecOptions(), + }) + + return t, nil +} diff --git a/internal/task/task/bs/delete_spdk_target.go b/internal/task/task/bs/delete_spdk_target.go new file mode 100644 index 000000000..d6365bd70 --- /dev/null +++ b/internal/task/task/bs/delete_spdk_target.go @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2021 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-09 + * Author: Jingli Chen (Wine93) + */ + +package bs + +import ( + "fmt" + "strings" + + "github.com/opencurve/curveadm/cli/cli" + "github.com/opencurve/curveadm/internal/common" + client "github.com/opencurve/curveadm/internal/configure" + "github.com/opencurve/curveadm/internal/errno" + "github.com/opencurve/curveadm/internal/task/context" + "github.com/opencurve/curveadm/internal/task/step" + "github.com/opencurve/curveadm/internal/task/task" +) + +type ( + step2CheckSpdkTgtStatus struct{ output *string } +) + +// check spdk target daemon status +func (s *step2CheckSpdkTgtStatus) Execute(ctx *context.Context) error { + output := *s.output + items := strings.Split(output, " ") + if len(items) < 2 || !strings.HasPrefix(items[1], "Up") { + return errno.ERR_SPDK_TARGET_DAEMON_IS_ABNORMAL + } + + return nil +} + +func NewDeleteSpdkTargetTask(curveadm *cli.CurveAdm, cc *client.ClientConfig) (*task.Task, error) { + options := curveadm.MemStorage().Get(common.KEY_SPDK_TARGET_OPTIONS).(SpdkTargetOption) + hc, err := curveadm.GetHost(options.Host) + if err != nil { + return nil, err + } + + subname := fmt.Sprintf("hostname=%s", hc.GetHostname()) + t := task.NewTask("Delete SpdkTarget", subname, hc.GetSSHConfig()) + listcmd := "/usr/libexec/spdk/scripts/rpc.py -s /var/tmp/spdk.sock iscsi_get_target_nodes" + + // add step + var output string + containerId := DEFAULT_SPDK_TGT_CONTAINER_NAME + + t.AddStep(&step.ListContainers{ + ShowAll: true, + Format: "'{{.ID}} {{.Status}}'", + Quiet: true, + Filter: fmt.Sprintf("name=%s", DEFAULT_SPDK_TGT_CONTAINER_NAME), + Out: &output, + ExecOptions: curveadm.ExecOptions(), + }) + + t.AddStep(&step2CheckSpdkTgtStatus{ + output: &output, + }) + t.AddStep(&step.ContainerExec{ + ContainerId: &containerId, + Command: listcmd, + Out: &output, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step2FormatTarget{ + host: options.Host, + hostname: hc.GetHostname(), + output: &output, + memStorage: curveadm.MemStorage(), + }) + + t.AddStep(&step.DelDaemonTask{ + ContainerId: &containerId, + Tid: options.Tid, + MemStorage: curveadm.MemStorage(), + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.ContainerExec{ + ContainerId: &containerId, + Command: fmt.Sprintf("/usr/libexec/spdk/scripts/rpc.py -s /var/tmp/spdk.sock iscsi_delete_target_node %s", options.Tid), + ExecOptions: curveadm.ExecOptions(), + }) + + return t, nil +} diff --git a/internal/task/task/bs/list_targets.go b/internal/task/task/bs/list_targets.go index 32abc7dc3..c8b0f9a00 100644 --- a/internal/task/task/bs/list_targets.go +++ b/internal/task/task/bs/list_targets.go @@ -143,3 +143,44 @@ func NewListTargetsTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, erro return t, nil } + +func NewListSpdkTargetsTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { + options := curveadm.MemStorage().Get(comm.KEY_SPDK_TARGET_OPTIONS).(SpdkTargetOption) + hc, err := curveadm.GetHost(options.Host) + if err != nil { + return nil, err + } + + subname := fmt.Sprintf("host=%s", hc.GetHostname()) + t := task.NewTask("List Targets", subname, hc.GetSSHConfig()) + + // add step + var output string + containerId := DEFAULT_SPDK_TGT_CONTAINER_NAME + + t.AddStep(&step.ListContainers{ + ShowAll: true, + Format: "'{{.ID}} {{.Status}}'", + Quiet: true, + Filter: fmt.Sprintf("name=%s", DEFAULT_TGTD_CONTAINER_NAME), + Out: &output, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step2CheckTgtdStatus{ + output: &output, + }) + t.AddStep(&step.ContainerExec{ + ContainerId: &containerId, + Command: fmt.Sprintf("/usr/libexec/spdk/scripts/rpc.py -s /var/tmp/spdk.sock iscsi_delete_target_node %s", options.Tid), + Out: &output, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step2FormatTarget{ + host: options.Host, + hostname: hc.GetHostname(), + output: &output, + memStorage: curveadm.MemStorage(), + }) + + return t, nil +} diff --git a/internal/task/task/bs/start_spdk_tgt.go b/internal/task/task/bs/start_spdk_tgt.go new file mode 100644 index 000000000..053dfc40d --- /dev/null +++ b/internal/task/task/bs/start_spdk_tgt.go @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2022 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2023-08-27 + * Author: Yaoliang Shi + */ + +package bs + +import ( + "fmt" + "strings" + + "github.com/opencurve/curveadm/cli/cli" + comm "github.com/opencurve/curveadm/internal/common" + "github.com/opencurve/curveadm/internal/configure" + "github.com/opencurve/curveadm/internal/errno" + "github.com/opencurve/curveadm/internal/task/context" + "github.com/opencurve/curveadm/internal/task/scripts" + "github.com/opencurve/curveadm/internal/task/step" + "github.com/opencurve/curveadm/internal/task/task" +) + +const ( + DEFAULT_SPDK_TGT_CONTAINER_NAME = "curvebs-spdk-target-daemon" +) + +type ( + step2CheckSpdkTargetDaemonStatus struct { + host string + status *string + } +) + +func (s *step2CheckSpdkTargetDaemonStatus) Execute(ctx *context.Context) error { + if strings.HasPrefix(*s.status, "Up") { + return task.ERR_SKIP_TASK + } else if len(*s.status) == 0 { + return nil + } + + return errno.ERR_OLD_SPDK_TARGET_DAEMON_IS_ABNORMAL. + F("host=%s", s.host) +} + +func NewStartSpdkTargetDaemonTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.Task, error) { + options := curveadm.MemStorage().Get(comm.KEY_SPDK_TARGET_OPTIONS).(SpdkTargetOption) + hc, err := curveadm.GetHost(options.Host) + if err != nil { + return nil, err + } + + // new task + subname := fmt.Sprintf("host=%s image=%s", options.Host, cc.GetContainerImage()) + t := task.NewTask("Start Spdk Target Daemon", subname, hc.GetSSHConfig()) + + // add step to task + var status, containerId, out string + containerName := DEFAULT_SPDK_TGT_CONTAINER_NAME + hostname := containerName + host2addr := fmt.Sprintf("%s:%s", hostname, hc.GetHostname()) + targetScriptPath := "/curvebs/tools/sbin/start_spdk.sh" + targetScript := scripts.SPDK_TARGET + cmd := fmt.Sprintf("/bin/bash %s %s", targetScriptPath, options.Cpumask) + + + t.AddStep(&step.ListContainers{ + ShowAll: true, + Format: "'{{.Status}}'", + Quiet: true, + Filter: fmt.Sprintf("name=%s", DEFAULT_SPDK_TGT_CONTAINER_NAME), + Out: &status, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step2CheckSpdkTargetDaemonStatus{ // skip if spdk-target-daemon exist and healthy + status: &status, + }) + t.AddStep(&step.PullImage{ + Image: cc.GetContainerImage(), + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.CreateContainer{ + Image: cc.GetContainerImage(), + AddHost: []string{host2addr}, + Envs: []string{"LD_PRELOAD=/usr/local/lib/libjemalloc.so"}, + Hostname: hostname, + Command: fmt.Sprintf("--role nebd"), + Name: containerName, + Pid: "host", + Privileged: true, + Volumes: getVolumes(cc), + Out: &containerId, + Restart: comm.POLICY_UNLESS_STOPPED, + ExecOptions: curveadm.ExecOptions(), + }) + for _, filename := range []string{"client.conf", "nebd-server.conf"} { + t.AddStep(&step.SyncFile{ + ContainerSrcId: &containerId, + ContainerSrcPath: "/curvebs/conf/" + filename, + ContainerDestId: &containerId, + ContainerDestPath: "/curvebs/nebd/conf/" + filename, + KVFieldSplit: CLIENT_CONFIG_DELIMITER, + Mutate: newMutate(cc, CLIENT_CONFIG_DELIMITER), + ExecOptions: curveadm.ExecOptions(), + }) + } + t.AddStep(&step.SyncFile{ // sync client configuration for spdk tgt + ContainerSrcId: &containerId, + ContainerSrcPath: "/curvebs/conf/client.conf", + ContainerDestId: &containerId, + ContainerDestPath: "/etc/curve/client.conf", + KVFieldSplit: CLIENT_CONFIG_DELIMITER, + Mutate: newMutate(cc, CLIENT_CONFIG_DELIMITER), + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.SyncFile{ // sync nebd-client config + ContainerSrcId: &containerId, + ContainerSrcPath: "/curvebs/conf/nebd-client.conf", + ContainerDestId: &containerId, + ContainerDestPath: "/etc/nebd/nebd-client.conf", + KVFieldSplit: CLIENT_CONFIG_DELIMITER, + Mutate: newMutate(cc, CLIENT_CONFIG_DELIMITER), + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.StartContainer{ + ContainerId: &containerId, + Out: &out, + ExecOptions: curveadm.ExecOptions(), + }) + + t.AddStep(&step.InstallFile{ // install start_spdk.sh + Content: &targetScript, + ContainerId: &containerId, + ContainerDestPath: targetScriptPath, + ExecOptions: curveadm.ExecOptions(), + }) + + t.AddStep(&step.ContainerExec{ + ContainerId: &containerId, + Command: cmd, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.AddDaemonTask{ // install addTarget.task + ContainerId: &containerId, + Cmd: "/bin/bash", + Args: []string{targetScriptPath, options.Cpumask}, + TaskName: "start spdk target", + ExecOptions: curveadm.ExecOptions(), + }) + + + return t, nil +} diff --git a/internal/task/task/bs/stop_spdk_tgt.go b/internal/task/task/bs/stop_spdk_tgt.go new file mode 100644 index 000000000..762a54305 --- /dev/null +++ b/internal/task/task/bs/stop_spdk_tgt.go @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 NetEase Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Project: CurveAdm + * Created Date: 2022-02-08 + * Author: Jingli Chen (Wine93) + */ + +package bs + +import ( + "fmt" + + "github.com/opencurve/curveadm/cli/cli" + comm "github.com/opencurve/curveadm/internal/common" + "github.com/opencurve/curveadm/internal/task/context" + "github.com/opencurve/curveadm/internal/task/step" + "github.com/opencurve/curveadm/internal/task/task" +) + +func checkSpdkTargetDaemonExist(containerId *string) step.LambdaType { + return func(ctx *context.Context) error { + if len(*containerId) == 0 { + return task.ERR_TASK_DONE + } + return nil + } +} + +func NewStopSpdkTargetDaemonTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) { + options := curveadm.MemStorage().Get(comm.KEY_SPDK_TARGET_OPTIONS).(SpdkTargetOption) + hc, err := curveadm.GetHost(options.Host) + if err != nil { + return nil, err + } + + // new task + subname := fmt.Sprintf("host=%s", options.Host) + t := task.NewTask("Stop SpdkTarget Daemon", subname, hc.GetSSHConfig()) + + // add step + var containerId string + t.AddStep(&step.ListContainers{ + ShowAll: true, + Format: "'{{.ID}}'", + Quiet: true, + Filter: fmt.Sprintf("name=%s", DEFAULT_SPDK_TGT_CONTAINER_NAME), + Out: &containerId, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.Lambda{ + Lambda: checkSpdkTargetDaemonExist(&containerId), + }) + t.AddStep(&step.StopContainer{ + ContainerId: DEFAULT_SPDK_TGT_CONTAINER_NAME, + ExecOptions: curveadm.ExecOptions(), + }) + t.AddStep(&step.RemoveContainer{ + ContainerId: DEFAULT_SPDK_TGT_CONTAINER_NAME, + ExecOptions: curveadm.ExecOptions(), + }) + + return t, nil +}