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

Kurtosis shell exec does not return the return value of command #688

Closed
victorcolombo opened this issue Jun 7, 2023 · 1 comment · Fixed by #690
Closed

Kurtosis shell exec does not return the return value of command #688

victorcolombo opened this issue Jun 7, 2023 · 1 comment · Fixed by #690
Labels
bug Something isn't working critical Critical bug or feature

Comments

@victorcolombo
Copy link
Contributor

victorcolombo commented Jun 7, 2023

What's your CLI version?

0.77.0

Description & steps to reproduce

$ kurtosis enclave add --name test-enclave
$ kurtosis service add test-enclave test2 httpd --ports http=80
$ kurtosis service shell test-enclave test2 --exec "exit 1"
echo $? # prints 0

This is critical for usage in CI systems that check exit code to report failure

Desired behavior

echo $? should print 1

This behavior happens because we use GetConnectionWithUserService to act both as a attach terminal and as an exec with the param commandToRunInsteadOfBash.

GetConnectionWithUserService(ctx context.Context, enclaveUuid enclave.EnclaveUUID, serviceUuid service.ServiceUUID, commandToRunInsteadOfBash string) (resultConn net.Conn, resultErr error)

I believe GetConnectionWithUserService should be reserved for interactive operations, since we are attaching a connection. So getting an interactive shell or even some interactive programs like cat (equivalent to -it flag in Docker)

For non interactive ones, like echo, could simply use RunUserServiceExecCommands when running kurtosis service shell ... --exec ..., since that command and blocking, and returns all information about the program execution (return status), but does not offer interactivity (maybe kurtosis service exec to match Dockers terminology?)

What is the severity of this bug?

Critical; I am blocked and Kurtosis is unusable for me because of this bug.

@victorcolombo victorcolombo added the bug Something isn't working label Jun 7, 2023
@github-actions github-actions bot added the critical Critical bug or feature label Jun 7, 2023
@gbouv
Copy link
Contributor

gbouv commented Jun 8, 2023

Adding kurtosis service exec in #690

@gbouv gbouv closed this as completed in #690 Jun 8, 2023
gbouv pushed a commit that referenced this issue Jun 8, 2023
## Description:
Users can now run `kurtosis service exec <ENCLAVE_ID> <SERVICE_ID> 'any
sh command'`. The command will be executed inside the designated user
service and the result will be printed in the CLI output.

The main different with `kurtosis service shell <ENCLAVE_ID>
<SERVICE_ID> --exec 'any sh command'` is that the former expects a zero
exit code for the command otherwise throws an exception, whereas the
latter returns gracefully whatever the exit code of the command was.

In short, `kurtosis service shell` is designed for interactive sessions
and will always return gracefully as long as the session terminated is
ended successfully. `kurtosis service exec` provides a way to run a
single command and returns immediately, taking the status of the command
into account.

Fixes #688 

## Is this change user facing?
YES
<!-- If yes, please add the "user facing" label to the PR -->
<!-- If yes, don't forget to include docs changes where relevant -->

## References (if applicable):
<!-- Add relevant Github Issues, Discord threads, or other helpful
information. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working critical Critical bug or feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants