Copilot commented on code in PR #3119:
URL: https://github.com/apache/hugegraph/pull/3119#discussion_r3678532008


##########
hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java:
##########
@@ -41,21 +41,64 @@
 public class InitStore {
 
     private static final Logger LOG = Log.logger(InitStore.class);
+    private static final String USE_CONFIGURED_ADMIN_PASSWORD =
+            "--use-configured-admin-password";
 
     public static void main(String[] args) throws Exception {
-        E.checkArgument(args.length == 1,
+        E.checkArgument(args.length == 1 ||
+                        args.length == 2 &&
+                        USE_CONFIGURED_ADMIN_PASSWORD.equals(args[1]),
                         "HugeGraph init-store need to pass the config file " +
-                        "of RestServer, like: conf/rest-server.properties");
+                        "of RestServer, like: conf/rest-server.properties, " +
+                        "with an optional %s flag",
+                        USE_CONFIGURED_ADMIN_PASSWORD);
         E.checkArgument(args[0].endsWith(".properties"),
                         "Expect the parameter is properties config file.");
 
         String restConf = args[0];
+        boolean useConfiguredAdminPassword = args.length == 2;
 
-        RegisterUtil.registerBackends();
-        RegisterUtil.registerPlugins();
+        /*
+         * Only the server options are needed to read the gate below. Backend
+         * and plugin registration is deferred to the enabled path:
+         * registerPlugins() invokes every discovered plugin's register() and
+         * propagates their failures, which must not happen on a path that is
+         * documented to be a no-op.
+         */
         RegisterUtil.registerServer();
 
         HugeConfig restServerConfig = new HugeConfig(restConf);
+
+        /*
+         * Distributed deployments (PD/HStore) let the storage side own the
+         * metadata, so there is nothing for init-store to do. The option
+         * defaults to true, keeping standalone/tarball installs on the full
+         * init path.
+         *
+         * The loop below already skips hstore backends, so what this gate
+         * additionally avoids is scanning the graphs directory (which must
+         * otherwise exist), and, when auth is configured, opening the auth
+         * graph store in initAdminUserIfNeeded(). On Kubernetes that ran on
+         * every Server pod restart, since the entrypoint's init flag file does
+         * not survive one.

Review Comment:
   The comment claims the init_store.enabled gate avoids scanning the graphs 
directory, but the disabled path can still call ConfigUtil.scanGraphsDir() 
inside checkAdminBootstrapReachable() when the built-in authenticator is 
configured (to validate the auth graph backend). This makes the comment 
misleading and could confuse operators relying on the documented no-scan 
behavior.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to