diff options
Diffstat (limited to 'client')
31 files changed, 49 insertions, 49 deletions
diff --git a/client/go/internal/admin/clusterstate/cluster_state.go b/client/go/internal/admin/clusterstate/cluster_state.go index 52f7c2181b4..6863e0a75d1 100644 --- a/client/go/internal/admin/clusterstate/cluster_state.go +++ b/client/go/internal/admin/clusterstate/cluster_state.go @@ -117,6 +117,6 @@ func (model *VespaModelConfig) getClusterState(cluster string) (*ClusterState, * return &parsedJson, &cc } // no success: - util.JustExitMsg(fmt.Sprint(errs)) + util.ExitMsg(fmt.Sprint(errs)) panic("unreachable") } diff --git a/client/go/internal/admin/clusterstate/detect_model.go b/client/go/internal/admin/clusterstate/detect_model.go index 0f261526145..d9589575c49 100644 --- a/client/go/internal/admin/clusterstate/detect_model.go +++ b/client/go/internal/admin/clusterstate/detect_model.go @@ -21,7 +21,7 @@ func getConfigServerHosts(s string) []string { got, err := backticks.Run(vespa.FindHome()+"/bin/vespa-print-default", "configservers") res := strings.Fields(got) if err != nil || len(res) < 1 { - util.JustExitMsg("bad configservers: " + got) + util.ExitMsg("bad configservers: " + got) } trace.Debug("found", len(res), "configservers:", res) return res @@ -37,7 +37,7 @@ func getConfigServerPort(i int) int { i, err = strconv.Atoi(strings.TrimSpace(got)) } if err != nil || i < 1 { - util.JustExitMsg("bad configserver_rpc_port: " + got) + util.ExitMsg("bad configserver_rpc_port: " + got) } trace.Debug("found configservers rpc port:", i) return i @@ -62,6 +62,6 @@ func detectModel(opts *Options) *VespaModelConfig { return parsed } } - util.JustExitMsg("could not get model config") + util.ExitMsg("could not get model config") panic("unreachable") } diff --git a/client/go/internal/admin/clusterstate/set_node_state.go b/client/go/internal/admin/clusterstate/set_node_state.go index a838b43503f..ed120d99218 100644 --- a/client/go/internal/admin/clusterstate/set_node_state.go +++ b/client/go/internal/admin/clusterstate/set_node_state.go @@ -80,7 +80,7 @@ func runSetNodeState(opts *Options, args []string) { } wanted, err := knownState(args[0]) if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } reason := "" if len(args) > 1 { @@ -138,7 +138,7 @@ func (cc *ClusterControllerSpec) setNodeUserState(s serviceSpec, wanted KnownSta } jsonBytes, err := json.Marshal(request) if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } url := fmt.Sprintf("http://%s:%d/cluster/v2/%s/%s/%d", cc.host, cc.port, diff --git a/client/go/internal/admin/deploy/cmd.go b/client/go/internal/admin/deploy/cmd.go index 955ae93f859..b82d1bf2968 100644 --- a/client/go/internal/admin/deploy/cmd.go +++ b/client/go/internal/admin/deploy/cmd.go @@ -24,7 +24,7 @@ func NewDeployCmd() *cobra.Command { curOptions Options ) if err := vespa.LoadDefaultEnv(); err != nil { - util.JustExitWith(err) + util.ExitErr(err) } cobra.EnableCommandSorting = false cmd := &cobra.Command{ diff --git a/client/go/internal/admin/deploy/curl.go b/client/go/internal/admin/deploy/curl.go index 0ce1305226f..77f280b06c4 100644 --- a/client/go/internal/admin/deploy/curl.go +++ b/client/go/internal/admin/deploy/curl.go @@ -60,20 +60,20 @@ func urlWithoutQuery(url string) string { func newCurlCommand(url string, args []string) *curl.Command { tls, err := vespa.LoadTlsConfig() if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } if tls != nil && strings.HasPrefix(url, "http:") { url = "https:" + url[5:] } cmd, err := curl.RawArgs(url, args...) if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } if tls != nil { if tls.DisableHostnameValidation { cmd, err = curl.RawArgs(url, append(args, "--insecure")...) if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } } cmd.PrivateKey = tls.Files.PrivateKey diff --git a/client/go/internal/admin/deploy/fetch.go b/client/go/internal/admin/deploy/fetch.go index 9b4a927882d..bb68722b6fe 100644 --- a/client/go/internal/admin/deploy/fetch.go +++ b/client/go/internal/admin/deploy/fetch.go @@ -90,7 +90,7 @@ func getPartAfterSlash(path string) string { return parts[idx-1] } if idx == 0 { - util.JustExitMsg("cannot find part after slash: " + path) + util.ExitMsg("cannot find part after slash: " + path) } return parts[idx] } diff --git a/client/go/internal/admin/deploy/persist.go b/client/go/internal/admin/deploy/persist.go index 2c40606e1ab..bfa43ec4126 100644 --- a/client/go/internal/admin/deploy/persist.go +++ b/client/go/internal/admin/deploy/persist.go @@ -43,11 +43,11 @@ func configsourceUrlUsedFile() string { func createTenantDir(tenant string) string { vespaDeployTempDir, err := createVespaDeployDir() if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } tdir := filepath.Join(vespaDeployTempDir, tenant) if err := os.MkdirAll(tdir, 0700); err != nil { - util.JustExitWith(err) + util.ExitErr(err) } return tdir } @@ -80,7 +80,7 @@ func getSessionIdFromFile(tenant string) string { fn := filepath.Join(dir, sessionIdFileName) bytes, err := os.ReadFile(fn) if err != nil { - util.JustExitMsg("Could not read session id from file, and no session id supplied as argument. Exiting.") + util.ExitMsg("Could not read session id from file, and no session id supplied as argument. Exiting.") } trace.Trace("Session-id", string(bytes), "found from file", fn) return string(bytes) diff --git a/client/go/internal/admin/jvm/application_container.go b/client/go/internal/admin/jvm/application_container.go index 3959ccca5e9..37f9bccd1ff 100644 --- a/client/go/internal/admin/jvm/application_container.go +++ b/client/go/internal/admin/jvm/application_container.go @@ -177,6 +177,6 @@ func (c *ApplicationContainer) exportExtraEnv(ps *prog.Spec) { if c.ConfigId() != "" { ps.Setenv(envvars.VESPA_CONFIG_ID, c.ConfigId()) } else { - util.JustExitMsg("application container requires a config id") + util.ExitMsg("application container requires a config id") } } diff --git a/client/go/internal/admin/jvm/container.go b/client/go/internal/admin/jvm/container.go index 4788eba76cb..5384a6c1ea5 100644 --- a/client/go/internal/admin/jvm/container.go +++ b/client/go/internal/admin/jvm/container.go @@ -72,5 +72,5 @@ func (cb *containerBase) Exec() { trace.Info("JVM env:", readableEnv(p.Env)) trace.Info("JVM exec:", argv) err := p.Run() - util.JustExitWith(err) + util.ExitErr(err) } diff --git a/client/go/internal/admin/jvm/properties.go b/client/go/internal/admin/jvm/properties.go index 446f218a2ad..367de49d6c9 100644 --- a/client/go/internal/admin/jvm/properties.go +++ b/client/go/internal/admin/jvm/properties.go @@ -101,6 +101,6 @@ func writeEnvAsProperties(envv []string, propsFile string) { trace.Trace("write props file:", propsFile) err := os.WriteFile(propsFile, envAsProperties(envv), 0600) if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } } diff --git a/client/go/internal/admin/jvm/qr_start_cfg.go b/client/go/internal/admin/jvm/qr_start_cfg.go index 4edb02b2a84..7177c4c1a2f 100644 --- a/client/go/internal/admin/jvm/qr_start_cfg.go +++ b/client/go/internal/admin/jvm/qr_start_cfg.go @@ -45,7 +45,7 @@ func (a *ApplicationContainer) getQrStartCfg() *QrStartConfig { backticks := util.BackTicksForwardStderr data, err := backticks.Run("vespa-get-config", args...) if err != nil { - util.JustExitMsg("could not get qr-start config: " + err.Error()) + util.ExitMsg("could not get qr-start config: " + err.Error()) } else { codec := json.NewDecoder(strings.NewReader(data)) err = codec.Decode(&parsedJson) diff --git a/client/go/internal/admin/jvm/standalone_container.go b/client/go/internal/admin/jvm/standalone_container.go index 542304c099a..23f712851ff 100644 --- a/client/go/internal/admin/jvm/standalone_container.go +++ b/client/go/internal/admin/jvm/standalone_container.go @@ -82,6 +82,6 @@ func (c *StandaloneContainer) exportExtraEnv(ps *prog.Spec) { if ioutil.IsDir(app) { ps.Setenv(envvars.STANDALONE_JDISC_APP_LOCATION, app) } else { - util.JustExitMsg("standalone container requires an application directory, missing: " + app) + util.ExitMsg("standalone container requires an application directory, missing: " + app) } } diff --git a/client/go/internal/admin/jvm/zk_locks.go b/client/go/internal/admin/jvm/zk_locks.go index 90a05f94905..0a307c5a38a 100644 --- a/client/go/internal/admin/jvm/zk_locks.go +++ b/client/go/internal/admin/jvm/zk_locks.go @@ -22,6 +22,6 @@ func RemoveStaleZkLocks(c Container) { out, err := backticks.Run("/bin/sh", "-c", cmd) if err != nil { trace.Warning("Failure [", out, "] when running command:", cmd) - util.JustExitWith(err) + util.ExitErr(err) } } diff --git a/client/go/internal/admin/prog/valgrind_test.go b/client/go/internal/admin/prog/valgrind_test.go index 5bc9c1625fe..0b61d5c499c 100644 --- a/client/go/internal/admin/prog/valgrind_test.go +++ b/client/go/internal/admin/prog/valgrind_test.go @@ -22,7 +22,7 @@ func useMock(prog, target string) { os.Remove(symlink) err := os.Symlink(mock, symlink) if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } } diff --git a/client/go/internal/admin/vespa-wrapper/configserver/check.go b/client/go/internal/admin/vespa-wrapper/configserver/check.go index 73270271051..2629d64bdc4 100644 --- a/client/go/internal/admin/vespa-wrapper/configserver/check.go +++ b/client/go/internal/admin/vespa-wrapper/configserver/check.go @@ -20,5 +20,5 @@ func checkIsConfigserver(myname string) { } } trace.Warning("only these hosts should run a config server:", onlyHosts) - util.JustExitMsg(fmt.Sprintf("this host [%s] should not run a config server", myname)) + util.ExitMsg(fmt.Sprintf("this host [%s] should not run a config server", myname)) } diff --git a/client/go/internal/admin/vespa-wrapper/configserver/runserver.go b/client/go/internal/admin/vespa-wrapper/configserver/runserver.go index a3b656782db..6249d2bb6e8 100644 --- a/client/go/internal/admin/vespa-wrapper/configserver/runserver.go +++ b/client/go/internal/admin/vespa-wrapper/configserver/runserver.go @@ -57,5 +57,5 @@ func (rs *RunServer) Exec(prog string) { } argv.AppendAll(rs.Args...) err := util.Execvp(rs.ProgPath(), argv) - util.JustExitWith(err) + util.ExitErr(err) } diff --git a/client/go/internal/admin/vespa-wrapper/configserver/start.go b/client/go/internal/admin/vespa-wrapper/configserver/start.go index 91064b21849..e1ccccee912 100644 --- a/client/go/internal/admin/vespa-wrapper/configserver/start.go +++ b/client/go/internal/admin/vespa-wrapper/configserver/start.go @@ -37,7 +37,7 @@ func commonPreChecks() (veHome string) { checkIsConfigserver(veHost) e = os.Chdir(veHome) if e != nil { - util.JustExitWith(e) + util.ExitErr(e) } return } diff --git a/client/go/internal/admin/vespa-wrapper/main.go b/client/go/internal/admin/vespa-wrapper/main.go index ad1eee52b63..b760c09b857 100644 --- a/client/go/internal/admin/vespa-wrapper/main.go +++ b/client/go/internal/admin/vespa-wrapper/main.go @@ -99,7 +99,7 @@ func main() { func handleSimplePanic() { if r := recover(); r != nil { - if jee, ok := r.(*util.JustExitError); ok { + if jee, ok := r.(*util.ExitError); ok { fmt.Fprintln(os.Stderr, jee) os.Exit(1) } else { diff --git a/client/go/internal/admin/vespa-wrapper/services/configproxy.go b/client/go/internal/admin/vespa-wrapper/services/configproxy.go index e92b05ccc1e..e96ee38dcb5 100644 --- a/client/go/internal/admin/vespa-wrapper/services/configproxy.go +++ b/client/go/internal/admin/vespa-wrapper/services/configproxy.go @@ -30,7 +30,7 @@ func JustRunConfigproxy() int { vespa.CheckCorrectUser() configsources := defaults.VespaConfigserverRpcAddrs() if len(configsources) < 1 { - util.JustExitMsg("could not find any configservers") + util.ExitMsg("could not find any configservers") } util.TuneResourceLimits() c := jvm.NewConfigProxyJvm(PROXY_SERVICE_NAME) diff --git a/client/go/internal/admin/vespa-wrapper/services/prechecks.go b/client/go/internal/admin/vespa-wrapper/services/prechecks.go index bb6bf55e06b..5cba69a4824 100644 --- a/client/go/internal/admin/vespa-wrapper/services/prechecks.go +++ b/client/go/internal/admin/vespa-wrapper/services/prechecks.go @@ -31,7 +31,7 @@ func commonPreChecks() (veHome, veHost string) { } err = os.Chdir(veHome) if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } return } diff --git a/client/go/internal/admin/vespa-wrapper/services/start.go b/client/go/internal/admin/vespa-wrapper/services/start.go index d2c2fb6f5ba..408fc196fec 100644 --- a/client/go/internal/admin/vespa-wrapper/services/start.go +++ b/client/go/internal/admin/vespa-wrapper/services/start.go @@ -37,10 +37,10 @@ func checkjava() { out, err := backticks.Run("java", "-version") if err != nil { trace.Warning("cannot run 'java -version'") - util.JustExitWith(err) + util.ExitErr(err) } if !strings.Contains(out, "64-Bit Server VM") { - util.JustExitWith(fmt.Errorf("java must invoke the 64-bit Java VM, but -version says:\n%s\n", out)) + util.ExitErr(fmt.Errorf("java must invoke the 64-bit Java VM, but -version says:\n%s\n", out)) } } @@ -64,7 +64,7 @@ func VespaStartServices() int { drop_caches() err := vespa.MaybeSwitchUser("start-services") if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } return StartServices() } diff --git a/client/go/internal/admin/vespa-wrapper/services/stop.go b/client/go/internal/admin/vespa-wrapper/services/stop.go index 54d557847ce..9fd19e991a3 100644 --- a/client/go/internal/admin/vespa-wrapper/services/stop.go +++ b/client/go/internal/admin/vespa-wrapper/services/stop.go @@ -21,11 +21,11 @@ func VespaStopServices() int { } err := vespa.LoadDefaultEnv() if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } err = vespa.MaybeSwitchUser("vespa-stop-services") if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } vespa.CheckCorrectUser() trace.Debug("running as correct user") diff --git a/client/go/internal/admin/vespa-wrapper/standalone/start.go b/client/go/internal/admin/vespa-wrapper/standalone/start.go index add29d37671..309e668b4d4 100644 --- a/client/go/internal/admin/vespa-wrapper/standalone/start.go +++ b/client/go/internal/admin/vespa-wrapper/standalone/start.go @@ -23,11 +23,11 @@ func commonPreChecks() { veHome := vespa.FindAndVerifyVespaHome() err := os.Chdir(veHome) if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } err = vespa.LoadDefaultEnv() if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } } @@ -36,7 +36,7 @@ func StartStandaloneContainer(extraArgs []string) int { util.TuneResourceLimits() serviceName := os.Getenv("VESPA_SERVICE_NAME") if serviceName == "" { - util.JustExitMsg("Missing service name, ensure VESPA_SERVICE_NAME is set in the environment") + util.ExitMsg("Missing service name, ensure VESPA_SERVICE_NAME is set in the environment") } c := jvm.NewStandaloneContainer(serviceName) jvmOpts := c.JvmOptions() diff --git a/client/go/internal/admin/vespa-wrapper/startcbinary/cmd.go b/client/go/internal/admin/vespa-wrapper/startcbinary/cmd.go index 657c941ad51..3cc20c43896 100644 --- a/client/go/internal/admin/vespa-wrapper/startcbinary/cmd.go +++ b/client/go/internal/admin/vespa-wrapper/startcbinary/cmd.go @@ -23,7 +23,7 @@ func Run(args []string) int { spec := NewProgSpec(args) err := vespa.LoadDefaultEnv() if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } hostname, err := vespa.FindOurHostname() if err != nil { diff --git a/client/go/internal/util/fix_fs.go b/client/go/internal/util/fix_fs.go index 12d49462e07..9e09a2cbc32 100644 --- a/client/go/internal/util/fix_fs.go +++ b/client/go/internal/util/fix_fs.go @@ -149,5 +149,5 @@ func (spec *FixSpec) complainAndExit(got error, fn string, wanted os.FileMode) { out, _ := BackTicksWithStderr.Run("stat", "--", fn) trace.Warning(out) trace.Warning("this is a fatal error!") - JustExitWith(got) + ExitErr(got) } diff --git a/client/go/internal/util/fix_fs_test.go b/client/go/internal/util/fix_fs_test.go index 535da2c80ad..e6a87d10717 100644 --- a/client/go/internal/util/fix_fs_test.go +++ b/client/go/internal/util/fix_fs_test.go @@ -119,7 +119,7 @@ func TestSuperUserOnly(t *testing.T) { func expectSimplePanic() { if r := recover(); r != nil { - if jee, ok := r.(*JustExitError); ok { + if jee, ok := r.(*ExitError); ok { trace.Trace("got as expected:", jee) return } diff --git a/client/go/internal/util/just_exit.go b/client/go/internal/util/just_exit.go index ad07f451c9c..6be0df0f30f 100644 --- a/client/go/internal/util/just_exit.go +++ b/client/go/internal/util/just_exit.go @@ -9,12 +9,12 @@ import ( "github.com/vespa-engine/vespa/client/go/internal/admin/trace" ) -type JustExitError struct { +type ExitError struct { err error msg string } -func (j *JustExitError) String() string { +func (j *ExitError) String() string { if j.err != nil { if j.msg == "" { return j.err.Error() @@ -27,22 +27,22 @@ func (j *JustExitError) String() string { return j.msg } -func (j *JustExitError) Error() string { +func (j *ExitError) Error() string { return j.String() } -func JustExitMsg(message string) { +func ExitMsg(message string) { trace.Trace("just exit with message") - j := JustExitError{ + j := ExitError{ err: nil, msg: message, } panic(&j) } -func JustExitWith(e error) { +func ExitErr(e error) { trace.Trace("just exit with error") - j := JustExitError{ + j := ExitError{ err: e, msg: "", } diff --git a/client/go/internal/vespa/find_home.go b/client/go/internal/vespa/find_home.go index 1043e5c785b..e1ee776eb45 100644 --- a/client/go/internal/vespa/find_home.go +++ b/client/go/internal/vespa/find_home.go @@ -85,7 +85,7 @@ func FindAndVerifyVespaHome() string { myself := fmt.Sprintf("%s/%s", vespaHome, scriptUtilsFilename) if !ioutil.IsExecutable(myself) { trace.Warning("missing or bad file:", myself) - util.JustExitMsg("Not a valid VESPA_HOME: " + vespaHome) + util.ExitMsg("Not a valid VESPA_HOME: " + vespaHome) } return vespaHome } diff --git a/client/go/internal/vespa/load_env.go b/client/go/internal/vespa/load_env.go index 4457ec20d90..31a91ef39de 100644 --- a/client/go/internal/vespa/load_env.go +++ b/client/go/internal/vespa/load_env.go @@ -249,7 +249,7 @@ func shellQuote(s string) string { } if i != l { err := fmt.Errorf("expected length %d but was %d", l, i) - util.JustExitWith(err) + util.ExitErr(err) } return string(res) } diff --git a/client/go/internal/vespa/prestart.go b/client/go/internal/vespa/prestart.go index 5b29915bcb2..6fe6d50b1fe 100644 --- a/client/go/internal/vespa/prestart.go +++ b/client/go/internal/vespa/prestart.go @@ -57,7 +57,7 @@ func RunPreStart() error { // fix wrong ownerships within directories: var fixer fs.WalkDirFunc = func(path string, d fs.DirEntry, err error) error { if err != nil { - util.JustExitWith(err) + util.ExitErr(err) } if d.IsDir() { fixSpec.FixDir(path) diff --git a/client/go/internal/vespa/switch_user.go b/client/go/internal/vespa/switch_user.go index c84da567224..096ba85b375 100644 --- a/client/go/internal/vespa/switch_user.go +++ b/client/go/internal/vespa/switch_user.go @@ -55,7 +55,7 @@ func CheckCorrectUser() { if err2 != nil { trace.Warning("note: user.Lookup(", vespaUser, ") failed:", err2) } - util.JustExitMsg("running as wrong user. Check your VESPA_USER setting") + util.ExitMsg("running as wrong user. Check your VESPA_USER setting") } // re-execute a vespa-wrapper action after switching to the vespa user |