Skip to content

Conversation

@darshanime-d11
Copy link

currently, aerospike-loader exits using 0 exit code, even in the case of an exception. this PR uses a non-zero code for the error flow.

@darshanime-d11 darshanime-d11 force-pushed the exitCode branch 2 times, most recently from 0bc8fee to dd640ea Compare February 12, 2025 09:54
@darshanime-d11
Copy link
Author

@dwelch-spike @a-spiker requesting review

@darshanime-d11
Copy link
Author

gentle bump please @dwelch-spike @a-spiker

@a-spiker
Copy link
Collaborator

Hi, @darshanime-d11. Thanks for raising this. Please allow us some time, we will be reviewing this PR.

@a-spiker
Copy link
Collaborator

@darshanime-d11 I have reviewed this PR and noticed gaps in addressing the problem statement. The current change only handles exceptions at the main function level but does not account for errors occurring within execution threads or deeper in the stack.

It is crucial to ensure that all errors propagate correctly to the main function. Certain functions or threads might encounter errors that are not being surfaced, which could lead to scenarios where failures are not detected and the process does not exit with a non-zero exit code when necessary.

Could you provide more context on the use case that led to this change request? Understanding the intent behind it will help assess the best approach for handling errors comprehensively.

@rrutum
Copy link

rrutum commented Feb 19, 2025

@a-spiker We are using the aerospike-loader tool inside one of our microservices to load data into Aerospike clusters. Our API (which inserts data) relies on the exit code of aerospike-loader to determine whether the insert was successful.
We observed that even in cases where the loader was unable to connect to the Aerospike cluster, we got an exit code 0 with console output mentioning an error message. Currently to overcome this limitation we are parsing the console output and error to check if any error logs are encountered.

public static void main(String[] args) throws IOException {
int exitCode = -1;
try {
CommandLine cl = parseArgs(args);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move the parseArgs to launch and let launch take full responsibility for the functionality. In that way, we don't need to include system-lambda for testing.

int exitCode = AerospikeLoad.launch(new String[]{"-h", host, "-p", port, "-n", ns, "-ec", error_count, "-wa", write_action, "-c", "/non/existing/config.json", dataFile});
assertEquals(-1, exitCode);

CommandLine cl = parseArgs(args);
exitCode = launch(cl);
} catch (Exception e) {
if (log.isDebugEnabled()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's ensure we print the exception error as before.


public static void main(String[] args) throws IOException {
long processStart = System.currentTimeMillis();
public static void main(String[] args) throws IOException {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There seems to be formatting issue with this PR. Please double check.

Copy link
Collaborator

@a-spiker a-spiker left a comment

Choose a reason for hiding this comment

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

While this PR takes a step towards handling exit codes, it does not yet cover all possible error scenarios comprehensively.

Further contributions would be beneficial to enhance exception handling at a deeper level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants