From 5ccf8bb312ce43bfe87c5509c844f849a1fb61bc Mon Sep 17 00:00:00 2001 From: Priya Bibra Date: Thu, 5 Sep 2024 10:08:59 -0700 Subject: [PATCH] call vtops --- go/cmd/vtorc/cli/cli.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/go/cmd/vtorc/cli/cli.go b/go/cmd/vtorc/cli/cli.go index f521ae05e57..ee14c2cae2e 100644 --- a/go/cmd/vtorc/cli/cli.go +++ b/go/cmd/vtorc/cli/cli.go @@ -17,6 +17,10 @@ limitations under the License. package cli import ( + "io" + "os/exec" + "time" + "github.com/spf13/cobra" "vitess.io/vitess/go/acl" @@ -68,6 +72,34 @@ func run(cmd *cobra.Command, args []string) { // Log final config values to debug if something goes wrong. config.LogConfigValues() + + log.Info("sleeping for 30s...\n") + time.Sleep(30 * time.Second) + vtopsCmd := exec.Command("/vt/v19/bin/vtops", "problems", "--hostname", "vtctld-dev-iad-wc2-rcqw", "--raise", "--tablet", "tablet-iad-dev-loadtest-00-80-nf2k", "--problem", "orc-dead-tablet") + // out, err := vtopsCmd.CombinedOutput() + // if err != nil { + // log.Errorf("Error executing vtops command for vtorc: %+v", err) + // } else { + // log.Infof("Executed vtops command successfully: %s", string(out)) + // } + + stderrPipe, _ := vtopsCmd.StderrPipe() + stdoutPipe, _ := vtopsCmd.StdoutPipe() + + if err := vtopsCmd.Start(); err != nil { + log.Errorf("Error starting vtops command: %+v", err) + } + + stderr, _ := io.ReadAll(stderrPipe) + stdout, _ := io.ReadAll(stdoutPipe) + + if err := vtopsCmd.Wait(); err != nil { + log.Errorf("vtops Command failed with error: %+v", err) + } + + log.Infof("vtops Stdout: %s", string(stdout)) + log.Errorf("vtops Stderr: %s", string(stderr)) + server.StartVTOrcDiscovery() server.RegisterVTOrcAPIEndpoints()