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

Return proper exit code for lucene-client commands #724

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

sarthakn7
Copy link
Contributor

@sarthakn7 sarthakn7 commented Sep 19, 2024

Many lucene-client commands return code 0 even when there is an error in the grpc call. Changing this to throw the exceptions when they are caught so that the error code is 1.

I've deleted the Settings and LiveSettings commands since only the V2 versions of these commands should be used now.

Test:

# Correct address
$ ./build/install/nrtsearch/bin/lucene-client -h 10.93.180.30 -p 8000 settingsV2 -i doc_chunks_v1
[INFO ] 2024-09-19 13:46:09.499 [main] LuceneServerClient - Server returned : {
  "nrtCachingDirectoryMaxMergeSizeMB": 5.0,
  "nrtCachingDirectoryMaxSizeMB": 6.0,
  "concurrentMergeSchedulerMaxThreadCount": 8,
  "concurrentMergeSchedulerMaxMergeCount": 16,
  "indexMergeSchedulerAutoThrottle": false,
  "directory": "MMapDirectory"
}

$ echo $?
0

# Incorrect port
$ ./build/install/nrtsearch/bin/lucene-client -h 10.93.180.30 -p 8010 settingsV2 -i doc_chunks_v1
[ERROR] 2024-09-19 13:46:16.818 [main] LuceneServerClient - Unable to apply settings
io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:268)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:249)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:167)
	at com.yelp.nrtsearch.server.grpc.LuceneServerGrpc$LuceneServerBlockingStub.settingsV2(LuceneServerGrpc.java:2030)
	at com.yelp.nrtsearch.server.grpc.LuceneServerClient.settingsV2(LuceneServerClient.java:170)
	at com.yelp.nrtsearch.server.cli.SettingsV2Command.call(SettingsV2Command.java:57)
	at com.yelp.nrtsearch.server.cli.SettingsV2Command.call(SettingsV2Command.java:24)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
	at picocli.CommandLine.execute(CommandLine.java:2174)
	at com.yelp.nrtsearch.server.cli.LuceneClientCommand.main(LuceneClientCommand.java:88)
Caused by: io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: /10.93.180.30:8010
Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
	at io.grpc.netty.shaded.io.netty.channel.unix.Errors.newConnectException0(Errors.java:166)
	at io.grpc.netty.shaded.io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:131)
	at io.grpc.netty.shaded.io.netty.channel.unix.Socket.finishConnect(Socket.java:359)
	at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:710)
	at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:687)
	at io.grpc.netty.shaded.io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:567)
	at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:499)
	at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:407)
	at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)

$ echo $?
1

@sarthakn7 sarthakn7 marked this pull request as ready for review September 19, 2024 21:20
Comment on lines 116 to 117
logger.error("Unable to create index {}", indexName, e);
throw e;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason the exception is being provided to the logging call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was leftover from some trial-and-error, removed now. Thanks for catching!

@sarthakn7 sarthakn7 merged commit 50e4766 into main Sep 20, 2024
1 check passed
@sarthakn7 sarthakn7 deleted the sarthakn_lucene_client_error_codes branch September 20, 2024 17:27
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.

2 participants