Skip to content
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

enhance: Add auto detect rootPath for connect command #271

Merged
merged 2 commits into from
Jun 7, 2024
Merged
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
16 changes: 16 additions & 0 deletions states/etcd_connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type ConnectParams struct {
RootCA string `name:"rootCAPem" default:"" desc:"root CA pem file path"`
ETCDPem string `name:"etcdCert" default:"" desc:"etcd tls cert file path"`
ETCDKey string `name:"etcdKey" default:"" desc:"etcd tls key file path"`
Auto bool `name:"auto" default:"false" desc:"auto detect rootPath if possible"`
}

func (s *disconnectState) getTLSConfig(cp *ConnectParams) (*tls.Config, error) {
Expand Down Expand Up @@ -111,6 +112,21 @@ func (s *disconnectState) ConnectCommand(ctx context.Context, cp *ConnectParams)
return errors.Wrap(err, "failed to connect to etcd")
}

if cp.Auto {
candidates, err := findMilvusInstance(ctx, etcdCli)
if err != nil {
return err
}
if len(candidates) == 1 {
cp.RootPath = candidates[0]
} else if len(candidates) > 1 {
fmt.Println("multiple possible rootPath find, cannot use auto mode")
} else {
fmt.Println("failed to find rootPath candidate")
return nil
}
}

etcdState := getEtcdConnectedState(etcdCli, cp.EtcdAddr, s.config)
if !cp.Dry {
// ping etcd
Expand Down
Loading