Skip to content

Commit

Permalink
redirect process errors to log files (#38)
Browse files Browse the repository at this point in the history
Signed-off-by: Arindam Nayak <[email protected]>
  • Loading branch information
arindamnayak committed Dec 10, 2019
1 parent 5306db9 commit 5a2a8f1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
30 changes: 13 additions & 17 deletions go/test/endtoend/cluster/cluster_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,44 +357,40 @@ func (cluster *LocalProcessCluster) WaitForTabletsToHealthyInVtgate() (err error
}

// Teardown brings down the cluster by invoking teardown for individual processes
func (cluster *LocalProcessCluster) Teardown() (err error) {
if err = cluster.VtgateProcess.TearDown(); err != nil {
log.Error(err.Error())
return
func (cluster *LocalProcessCluster) Teardown() {
if err := cluster.VtgateProcess.TearDown(); err != nil {
log.Errorf("Error in vtgate teardown - %s", err.Error())
}
mysqlctlProcessList := []*exec.Cmd{}
for _, keyspace := range cluster.Keyspaces {
for _, shard := range keyspace.Shards {
for _, tablet := range shard.Vttablets {
if proc, err := tablet.MysqlctlProcess.StopProcess(); err != nil {
log.Error(err.Error())
return err
log.Errorf("Error in mysqlctl teardown - %s", err.Error())
} else {
mysqlctlProcessList = append(mysqlctlProcessList, proc)
}

if err = tablet.VttabletProcess.TearDown(); err != nil {
log.Error(err.Error())
return
if err := tablet.VttabletProcess.TearDown(); err != nil {
log.Errorf("Error in vttablet teardown - %s", err.Error())
}
}
}
}

for _, proc := range mysqlctlProcessList {
proc.Wait()
if err := proc.Wait(); err != nil {
log.Errorf("Error in mysqlctl teardown wait - %s", err.Error())
}
}

if err = cluster.VtctldProcess.TearDown(); err != nil {
log.Error(err.Error())
return
if err := cluster.VtctldProcess.TearDown(); err != nil {
log.Errorf("Error in vtctld teardown - %s", err.Error())
}

if err = cluster.TopoProcess.TearDown(cluster.Cell, cluster.OriginalVTDATAROOT, cluster.CurrentVTDATAROOT, *keepData); err != nil {
log.Error(err.Error())
return
if err := cluster.TopoProcess.TearDown(cluster.Cell, cluster.OriginalVTDATAROOT, cluster.CurrentVTDATAROOT, *keepData); err != nil {
log.Errorf("Error in etcd teardown - %s", err.Error())
}
return err
}

// GetAndReservePort gives port for required process
Expand Down
8 changes: 4 additions & 4 deletions go/test/endtoend/cluster/etcd_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func (etcd *EtcdProcess) Setup() (err error) {
"--initial-cluster", fmt.Sprintf("%s=%s", etcd.Name, etcd.PeerURL),
)

etcd.proc.Stderr = os.Stderr
etcd.proc.Stdout = os.Stdout
errFile, _ := os.Create(path.Join(etcd.DataDirectory, "etcd-stderr.txt"))
etcd.proc.Stderr = errFile

etcd.proc.Env = append(etcd.proc.Env, os.Environ()...)

Expand Down Expand Up @@ -110,9 +110,9 @@ func (etcd *EtcdProcess) TearDown(Cell string, originalVtRoot string, currentRoo
}
_ = os.Setenv("VTDATAROOT", originalVtRoot)
select {
case err := <-etcd.exit:
case <-etcd.exit:
etcd.proc = nil
return err
return nil

case <-time.After(10 * time.Second):
etcd.proc.Process.Kill()
Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/cluster/vtctld_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func (vtctld *VtctldProcess) Setup(cell string, extraArgs ...string) (err error)
)
vtctld.proc.Args = append(vtctld.proc.Args, extraArgs...)

vtctld.proc.Stderr = os.Stderr
vtctld.proc.Stdout = os.Stdout
errFile, _ := os.Create(path.Join(vtctld.LogDir, "vtctld-stderr.txt"))
vtctld.proc.Stderr = errFile

vtctld.proc.Env = append(vtctld.proc.Env, os.Environ()...)

Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/cluster/vtgate_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func (vtgate *VtgateProcess) Setup() (err error) {
)
vtgate.proc.Args = append(vtgate.proc.Args, vtgate.ExtraArgs...)

vtgate.proc.Stderr = os.Stderr
vtgate.proc.Stdout = os.Stdout
errFile, _ := os.Create(path.Join(vtgate.LogDir, "vtgate-stderr.txt"))
vtgate.proc.Stderr = errFile

vtgate.proc.Env = append(vtgate.proc.Env, os.Environ()...)

Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/cluster/vttablet_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func (vttablet *VttabletProcess) Setup() (err error) {

vttablet.proc.Args = append(vttablet.proc.Args, vttablet.ExtraArgs...)

vttablet.proc.Stderr = os.Stderr
vttablet.proc.Stdout = os.Stdout
errFile, _ := os.Create(path.Join(vttablet.LogDir, vttablet.TabletPath+"-vttablet-stderr.txt"))
vttablet.proc.Stderr = errFile

vttablet.proc.Env = append(vttablet.proc.Env, os.Environ()...)

Expand Down

0 comments on commit 5a2a8f1

Please sign in to comment.