gharris1727 commented on code in PR #14195:
URL: https://github.com/apache/kafka/pull/14195#discussion_r1294083162


##########
tools/src/main/java/org/apache/kafka/tools/ConnectPluginPath.java:
##########
@@ -368,6 +391,30 @@ private static void endCommand(
             config.out.printf("Total plugins:      \t%d%n", totalPlugins);
             config.out.printf("Loadable plugins:   \t%d%n", loadablePlugins);
             config.out.printf("Compatible plugins: \t%d%n", compatiblePlugins);
+        } else if (config.command == Command.SYNC_MANIFESTS) {
+            if (workspace.commit(true)) {
+                if (config.dryRun) {
+                    config.out.println("Dry run passed: All above changes can 
be committed to disk if re-run with dry run disabled.");
+                } else {
+                    config.out.println("Writing changes to plugins...");
+                    workspace.commit(false);
+                    config.out.println("All plugins have accurate 
ServiceLoader manifests");
+                }
+            } else {
+                config.out.println("No changes required.");
+            }
+        }
+    }
+
+    private static void failCommand(Config config, Throwable e) {
+        if (config.command == Command.LIST) {
+            throw new RuntimeException("Unexpected error occurred while 
listing plugins", e);
+        } else if (config.command == Command.SYNC_MANIFESTS) {
+            if (config.dryRun) {
+                throw new RuntimeException("Unexpected error occurred while 
dry-running sync", e);
+            } else {
+                config.out.println("Connect plugin path now in unexpected 
state: Clear your plugin path and retry with dry run enabled");

Review Comment:
   Yes this error stacktrace should be visible. I've changed the error handling 
to only inject the warning about the corrupted plugin path when exceptions come 
from `commit(false)`. For unpredictable errors (mostly IOExceptions) I expect 
the stack trace (on stderr) to look like:
   
   ```
   RuntimeException: Unexpected error occurred while executing sync
   ...
   caused by:
   RuntimeException: Sync incomplete, plugin path may be corrupted. Clear your 
plugin path and retry with dry-run enabled
   ...
   caused by:
   IOException: filesystem broke
   ```
   
   This doesn't emphasize the corruption warning, but does make it show up 
under more accurate conditions.
   
   Overall I don't like the error handling here but I'm not sure what needs to 
change. Let me know if you have any more ideas.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to