smolnar82 opened a new pull request #68: KNOX-1814 - Moving conf/data folder checking to Java layer from bash URL: https://github.com/apache/knox/pull/68 ## What changes were proposed in this pull request? `conf` and `data` directories are configurable using GATEWAY_HOME (or newly introduced env variable) in the Java layer, therefore those checks should either be removed from the `bash` layer, so they take those variables into account within the Java code. ## How was this patch tested? Running JUnit tests: ``` $ mvn -T1C verify -Prelease,package ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 19:13 min (Wall Clock) [INFO] Finished at: 2019-03-11T11:04:32+01:00 [INFO] Final Memory: 272M/1965M [INFO] ------------------------------------------------------------------------ ``` Additionally, the following manual test steps were executed: 1. Using non-existing `conf` and `data` folders: ``` $ ls -al $GATEWAY_CONF_HOME ls: cannot access /home/knox/nonExistingFolder: No such file or directory $ ls -al $GATEWAY_DATA_HOME ls: cannot access /home/knox/nonExistingFolder: No such file or directory $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh start Starting Gateway succeeded with PID 32349. // wait 10 seconds $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh status Gateway is not running. No PID file found. This error found in gateway.log: 2019-03-11 10:37:13,405 FATAL knox.gateway (GatewayServer.java:main(175)) - Failed to start gateway: org.apache.knox.gateway.config.GatewayConfigurationException: Found configurations errors: GATEWAY_DATA_HOME is set to a non-existing directory: /home/knox/nonExistingFolder GATEWAY_CONF_HOME is set to a non-existing directory: /home/knox/nonExistingFolder org.apache.knox.gateway.config.GatewayConfigurationException: Found configurations errors: GATEWAY_DATA_HOME is set to a non-existing directory: /home/knox/nonExistingFolder GATEWAY_CONF_HOME is set to a non-existing directory: /home/knox/nonExistingFolder at org.apache.knox.gateway.GatewayServer.validateConfigurableGatewayDirectories(GatewayServer.java:260) at org.apache.knox.gateway.GatewayServer.main(GatewayServer.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.knox.gateway.launcher.Invoker.invokeMainMethod(Invoker.java:68) at org.apache.knox.gateway.launcher.Invoker.invoke(Invoker.java:39) at org.apache.knox.gateway.launcher.Command.run(Command.java:99) at org.apache.knox.gateway.launcher.Launcher.run(Launcher.java:75) at org.apache.knox.gateway.launcher.Launcher.main(Launcher.java:52) ``` 2. Using non-readable `conf` folder: ``` $ export GATEWAY_CONF_HOME=/home/knox/testFolder $ mkdir /home/knox/testFolder $ chmod -r /home/knox/testFolder $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh start Starting Gateway succeeded with PID 11511. // wait 10 seconds $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh status Gateway is not running. No PID file found. The following error found in gateway.log: 2019-03-11 10:40:19,813 FATAL knox.gateway (GatewayServer.java:main(175)) - Failed to start gateway: org.apache.knox.gateway.config.GatewayConfigurationException: Found configurations errors: GATEWAY_CONF_HOME is set to a non-readable directory: /home/knox/testFolder org.apache.knox.gateway.config.GatewayConfigurationException: Found configurations errors: GATEWAY_CONF_HOME is set to a non-readable directory: /home/knox/testFolder at org.apache.knox.gateway.GatewayServer.validateConfigurableGatewayDirectories(GatewayServer.java:260) at org.apache.knox.gateway.GatewayServer.main(GatewayServer.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.knox.gateway.launcher.Invoker.invokeMainMethod(Invoker.java:68) at org.apache.knox.gateway.launcher.Invoker.invoke(Invoker.java:39) at org.apache.knox.gateway.launcher.Command.run(Command.java:99) at org.apache.knox.gateway.launcher.Launcher.run(Launcher.java:75) at org.apache.knox.gateway.launcher.Launcher.main(Launcher.java:52) ``` 3. Using non-writeable `data` folder: ``` $ export GATEWAY_DATA_HOME=/home/knox/testFolder $ chmod +r /home/knox/testFolder/ $ chmod -w /home/knox/testFolder/ $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh start Starting Gateway failed. This error found in gateway.log: 2019-03-11 10:42:51,596 FATAL knox.gateway (GatewayServer.java:main(175)) - Failed to start gateway: org.apache.knox.gateway.config.GatewayConfigurationException: Found configurations errors: GATEWAY_DATA_HOME is set to a non-writeable directory: /home/knox/testFolder org.apache.knox.gateway.config.GatewayConfigurationException: Found configurations errors: GATEWAY_DATA_HOME is set to a non-writeable directory: /home/knox/testFolder at org.apache.knox.gateway.GatewayServer.validateConfigurableGatewayDirectories(GatewayServer.java:260) at org.apache.knox.gateway.GatewayServer.main(GatewayServer.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.knox.gateway.launcher.Invoker.invokeMainMethod(Invoker.java:68) at org.apache.knox.gateway.launcher.Invoker.invoke(Invoker.java:39) at org.apache.knox.gateway.launcher.Command.run(Command.java:99) at org.apache.knox.gateway.launcher.Launcher.run(Launcher.java:75) at org.apache.knox.gateway.launcher.Launcher.main(Launcher.java:52) ```
---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
