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

Better printing during inabox failure mode #1101

Merged
merged 1 commit into from
Jan 14, 2025
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
5 changes: 5 additions & 0 deletions inabox/bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ function start_graph {
popd
./wait-for http://0.0.0.0:8000 -- echo "GraphQL up"

if [ $? -ne 0 ]; then
echo "Failed to start graph node"
exit 1
fi

echo "Graph node started ....."
}

Expand Down
10 changes: 5 additions & 5 deletions inabox/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (env *Config) RegisterBlobVersionAndRelays(ethClient common.EthClient) map[
// TODO: Supply the test path to the runner utility
func (env *Config) StartBinaries() {
changeDirectory(filepath.Join(env.rootPath, "inabox"))
err := execCmd("./bin.sh", []string{"start-detached"}, []string{})
err := execCmd("./bin.sh", []string{"start-detached"}, []string{}, true)

if err != nil {
log.Panicf("Failed to start binaries. Err: %s", err)
Expand All @@ -339,23 +339,23 @@ func (env *Config) StartBinaries() {
// TODO: Supply the test path to the runner utility
func (env *Config) StopBinaries() {
changeDirectory(filepath.Join(env.rootPath, "inabox"))
err := execCmd("./bin.sh", []string{"stop"}, []string{})
err := execCmd("./bin.sh", []string{"stop"}, []string{}, true)
if err != nil {
log.Panicf("Failed to stop binaries. Err: %s", err)
}
}

func (env *Config) StartAnvil() {
changeDirectory(filepath.Join(env.rootPath, "inabox"))
err := execCmd("./bin.sh", []string{"start-anvil"}, []string{})
err := execCmd("./bin.sh", []string{"start-anvil"}, []string{}, false) // printing output causes hang
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because too many prints?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure what the root cause is. It may be something like that.

if err != nil {
log.Panicf("Failed to start anvil. Err: %s", err)
}
}

func (env *Config) StopAnvil() {
changeDirectory(filepath.Join(env.rootPath, "inabox"))
err := execCmd("./bin.sh", []string{"stop-anvil"}, []string{})
err := execCmd("./bin.sh", []string{"stop-anvil"}, []string{}, true)
if err != nil {
log.Panicf("Failed to stop anvil. Err: %s", err)
}
Expand All @@ -381,7 +381,7 @@ func (env *Config) RunNodePluginBinary(operation string, operator OperatorVars)
"NODE_NUM_CONFIRMATIONS=0",
}

err := execCmd("./node-plugin.sh", []string{}, envVars)
err := execCmd("./node-plugin.sh", []string{}, envVars, true)

if err != nil {
log.Panicf("Failed to run node plugin. Err: %s", err)
Expand Down
6 changes: 5 additions & 1 deletion inabox/deploy/localstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ func DeployResources(
changeDirectory(filepath.Join(rootPath, "inabox"))
if err := pool.Retry(func() error {
fmt.Println("Creating S3 bucket")
return execCmd("./create-s3-bucket.sh", []string{}, []string{fmt.Sprintf("AWS_URL=http://0.0.0.0:%s", localStackPort)})
return execCmd(
"./create-s3-bucket.sh",
[]string{},
[]string{fmt.Sprintf("AWS_URL=http://0.0.0.0:%s", localStackPort)},
true)
}); err != nil {
fmt.Println("Could not connect to docker:", err)
return err
Expand Down
4 changes: 2 additions & 2 deletions inabox/deploy/subgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ func (env *Config) updateSubgraph(updater subgraphUpdater, path string, startBlo

func (env *Config) StartGraphNode() {
changeDirectory(filepath.Join(env.rootPath, "inabox"))
err := execCmd("./bin.sh", []string{"start-graph"}, []string{})
err := execCmd("./bin.sh", []string{"start-graph"}, []string{}, true)
if err != nil {
log.Panicf("Failed to start graph node. Err: %s", err)
}
}

func (env *Config) StopGraphNode() {
changeDirectory(filepath.Join(env.rootPath, "inabox"))
err := execCmd("./bin.sh", []string{"stop-graph"}, []string{})
err := execCmd("./bin.sh", []string{"stop-graph"}, []string{}, true)
if err != nil {
log.Panicf("Failed to stop graph node. Err: %s", err)
}
Expand Down
11 changes: 6 additions & 5 deletions inabox/deploy/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func CreateNewTestDirectory(templateName, rootPath string) (string, error) {
templatePath := filepath.Join(rootPath, fmt.Sprintf("inabox/templates/%s", templateName))
err = execCmd(
"cp",
[]string{templatePath, fmt.Sprintf("%s/config.yaml", testPath)}, []string{})
[]string{templatePath, fmt.Sprintf("%s/config.yaml", testPath)}, []string{}, true)
if err != nil {
return "", fmt.Errorf("failed to copy template to test directory: %s", err.Error())
}
Expand All @@ -297,17 +297,18 @@ func GetLatestTestDirectory(rootPath string) (string, error) {
return testname, nil
}

func execCmd(name string, args []string, envVars []string) error {
func execCmd(name string, args []string, envVars []string, print bool) error {
cmd := exec.Command(name, args...)
if len(envVars) > 0 {
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, envVars...)
}
var out bytes.Buffer
var stderr bytes.Buffer
// TODO: When these are uncommented, the deployer sometimes fails to start anvil
// cmd.Stdout = &out
// cmd.Stderr = &stderr
if print {
cmd.Stdout = &out
cmd.Stderr = &stderr
}

err := cmd.Run()
if err != nil {
Expand Down
Loading