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

fix(upgrade): remove obsolete unused option (influx-command-path) #19972

Merged
merged 3 commits into from
Nov 10, 2020
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
1. [19925](https://github.com/influxdata/influxdb/pull/19937): Create CLI configs in `influxd upgrade`
1. [19945](https://github.com/influxdata/influxdb/pull/19945): Allow write-only V1 tokens to find DBRPs
1. [19960](https://github.com/influxdata/influxdb/pull/19960): Remove bucket and mapping auto-creation from v1 /write API
1. [19972](https://github.com/influxdata/influxdb/pull/19972): Remove unused 'influx-command-path' option from upgrade command

## v2.0.0-rc.4 [2020-11-05]

Expand Down
70 changes: 11 additions & 59 deletions cmd/influxd/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import (
"io/ioutil"
"net/url"
"os"
"os/exec"
"os/user"
"path/filepath"
"runtime"
"strings"

"github.com/influxdata/influxdb/v2"
Expand Down Expand Up @@ -91,25 +89,17 @@ func (o *optionsV1) checkDirs() error {
}

type optionsV2 struct {
boltPath string
configsPath string
enginePath string
userName string
password string
orgName string
bucket string
orgID influxdb.ID
userID influxdb.ID
token string
retention string
influx2CommandPath string
}

func (o *optionsV2) checkPaths() error {
if o.influx2CommandPath == "" {
return errors.New("influx command path not specified")
}
return nil
boltPath string
configsPath string
enginePath string
userName string
password string
orgName string
bucket string
orgID influxdb.ID
userID influxdb.ID
token string
retention string
}

var options = struct {
Expand Down Expand Up @@ -243,12 +233,6 @@ func NewCommand() *cobra.Command {
Default: influxConfigPathV1(),
Desc: "optional: Custom InfluxDB 1.x config file path, else the default config file",
},
{
DestP: &options.target.influx2CommandPath,
Flag: "influx-command-path",
Default: influxExePathV2(),
Desc: "path to influx command",
},
{
DestP: &options.logPath,
Flag: "log-path",
Expand Down Expand Up @@ -324,10 +308,6 @@ func runUpgradeE(*cobra.Command, []string) error {
return err
}

if err := options.target.checkPaths(); err != nil {
return err
}

log.Info("Starting InfluxDB 1.x upgrade")

if options.source.configFile != "" {
Expand Down Expand Up @@ -576,34 +556,6 @@ func influxConfigPathV1() string {
return ""
}

func influxExePathV2() string {
var exeName string
if runtime.GOOS == "win" {
exeName = "influx.exe"
} else {
exeName = "influx"
}
isV2 := func(path string) bool {
return exec.Command(path, "version").Run() == nil
}

exePath, err := exec.LookPath(exeName)
if err == nil {
if isV2(exePath) {
return exePath
}
}
exePath, err = os.Executable()
if err == nil {
exePath = filepath.Join(filepath.Dir(exePath), exeName)
if isV2(exePath) {
return exePath
}
}

return ""
}

// homeOrAnyDir retrieves user's home directory, current working one or just none.
func homeOrAnyDir() string {
var dir string
Expand Down
10 changes: 0 additions & 10 deletions cmd/influxd/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ func TestPathValidations(t *testing.T) {

cmd := NewCommand()
cmd.SetArgs(largs)

err = cmd.Execute()
require.NotNil(t, err, "Must fail")
assert.Contains(t, err.Error(), "influx command path not specified")

influxPath := "/usr/local/bin/influx" // fake
largs = append(largs, "--influx-command-path", influxPath)
cmd = NewCommand()
cmd.SetArgs(largs)

err = cmd.Execute()
require.NotNil(t, err, "Must fail")
assert.Contains(t, err.Error(), "1.x metadb error")
Expand Down