smolnar82 opened a new pull request #71: KNOX-1804 - Moving copy-pasted bash functions to knox-function.sh URL: https://github.com/apache/knox/pull/71 ## What changes were proposed in this pull request? Removing code duplication in `gateway.sh` and `ldap.sh` files. ## How was this patch tested? Executing the following manual test steps: ``` -- Gateway test -- $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh status Gateway is not running. No PID file found. $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh clean Removed the Gateway PID file: /home/knox/knox-1.3.0-SNAPSHOT/pids/gateway.pid. Removed the Gateway OUT file: /home/knox/knox-1.3.0-SNAPSHOT/logs/gateway.out. Removed the Gateway ERR file: /home/knox/knox-1.3.0-SNAPSHOT/logs/gateway.err. $ export KNOX_GATEWAY_CONF_DIR=~knox/nonExistingFolder $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh start --printEnv APP_CONF_DIR = /home/knox/nonExistingFolder APP_LOG_DIR = /home/knox/knox-1.3.0-SNAPSHOT/logs APP_DATA_DIR = /home/knox/knox-1.3.0-SNAPSHOT/data APP_PID_DIR = /home/knox/knox-1.3.0-SNAPSHOT/pids APP_JAVA_LIB_PATH = -Djava.library.path=/home/knox/knox-1.3.0-SNAPSHOT/ext/native APP_JAR = /home/knox/knox-1.3.0-SNAPSHOT/bin/gateway.jar Starting Gateway failed. $ tail -20 knox-1.3.0-SNAPSHOT/logs/gateway.log 2019-03-13 13:23:18,473 INFO knox.gateway (GatewayServer.java:logSysProp(218)) - System Property: java.home=/usr/jdk64/jdk1.8.0_112/jre 2019-03-13 13:23:18,910 INFO knox.gateway (GatewayConfigImpl.java:loadConfigResource(398)) - Loading configuration resource jar:file:/home/knox/knox-1.3.0-SNAPSHOT/bin/../lib/gateway-server-1.3.0-SNAPSHOT.jar!/conf/gateway-default.xml 2019-03-13 13:23:19,176 INFO knox.gateway (GatewayConfigImpl.java:loadConfigFile(386)) - Loading configuration file /home/knox/knox-1.3.0-SNAPSHOT/bin/../conf/gateway-site.xml 2019-03-13 13:23:19,274 INFO knox.gateway (GatewayConfigImpl.java:initGatewayHomeDir(326)) - Using /home/knox/knox-1.3.0-SNAPSHOT/bin/.. as GATEWAY_HOME via system property. 2019-03-13 13:23:19,274 INFO knox.gateway (GatewayConfigImpl.java:init(319)) - Cookie scoping feature enabled: false 2019-03-13 13:23:19,278 FATAL knox.gateway (GatewayServer.java:main(176)) - Failed to start gateway: org.apache.knox.gateway.config.GatewayConfigurationException: Found configurations errors: GATEWAY_CONF_HOME is set to a non-existing directory: /home/knox/nonExistingFolder org.apache.knox.gateway.config.GatewayConfigurationException: Found configurations errors: GATEWAY_CONF_HOME is set to a non-existing directory: /home/knox/nonExistingFolder at org.apache.knox.gateway.GatewayServer.validateConfigurableGatewayDirectories(GatewayServer.java:261) at org.apache.knox.gateway.GatewayServer.main(GatewayServer.java:160) 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) $ unset KNOX_GATEWAY_CONF_DIR $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh start --printEnv APP_CONF_DIR = /home/knox/knox-1.3.0-SNAPSHOT/conf APP_LOG_DIR = /home/knox/knox-1.3.0-SNAPSHOT/logs APP_DATA_DIR = /home/knox/knox-1.3.0-SNAPSHOT/data APP_PID_DIR = /home/knox/knox-1.3.0-SNAPSHOT/pids APP_JAVA_LIB_PATH = -Djava.library.path=/home/knox/knox-1.3.0-SNAPSHOT/ext/native APP_JAR = /home/knox/knox-1.3.0-SNAPSHOT/bin/gateway.jar Starting Gateway succeeded with PID 22783. $ tail knox-1.3.0-SNAPSHOT/logs/gateway.log 2019-03-13 13:24:35,165 INFO knox.gateway (DefaultGatewayServices.java:initializeContribution(240)) - Credential store found for the cluster: admin - no need to create one. 2019-03-13 13:24:35,230 INFO knox.gateway (GatewayServer.java:internalActivateTopology(828)) - Activating topology admin 2019-03-13 13:24:35,231 INFO knox.gateway (GatewayServer.java:internalActivateArchive(838)) - Activating topology admin archive %2F 2019-03-13 13:24:35,232 INFO knox.gateway (GatewayServer.java:handleCreateDeployment(943)) - Deploying topology default to /home/knox/knox-1.3.0-SNAPSHOT/data/deployments/default.topo.168dc3b4f48 2019-03-13 13:24:35,232 INFO knox.gateway (GatewayServer.java:internalDeactivateTopology(862)) - Deactivating topology default 2019-03-13 13:24:35,382 INFO knox.gateway (DefaultGatewayServices.java:initializeContribution(240)) - Credential store found for the cluster: default - no need to create one. 2019-03-13 13:24:35,417 ERROR knox.gateway (GatewayServer.java:handleCreateDeployment(967)) - Failed to deploy topology default: org.apache.knox.gateway.deploy.DeploymentException: Failed to contribute provider. Role: authorization Name: XASecurePDPKnox. Please check the topology for errors in name and role and that the provider is on the classpath. 2019-03-13 13:24:35,633 INFO knox.gateway (GatewayServer.java:start(626)) - Topology port mapping feature enabled: true 2019-03-13 13:24:40,054 INFO knox.gateway (GatewayServer.java:start(661)) - Monitoring topologies in directory: /home/knox/knox-1.3.0-SNAPSHOT/conf/topologies 2019-03-13 13:24:40,077 INFO knox.gateway (GatewayServer.java:startGateway(384)) - Started gateway on port 8,443. $ ps -ef | grep gateway.jar knox 1679 1 47 13:24 pts/0 00:00:09 /bin/java -Djava.library.path=/home/knox/knox-1.3.0-SNAPSHOT/ext/native -jar /home/knox/knox-1.3.0-SNAPSHOT/bin/gateway.jar knox 1929 20240 0 13:24 pts/0 00:00:00 grep --color=auto gateway.jar $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh status Gateway is running with PID 22783. $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh stop Stopping Gateway with PID 22783 succeeded. $ ./knox-1.3.0-SNAPSHOT/bin/gateway.sh status Gateway is not running. No PID file found. $ ps -ef | grep gateway.jar knox 3108 20240 0 13:25 pts/0 00:00:00 grep --color=auto gateway.jar -- LDAP test -- $ ./knox-1.3.0-SNAPSHOT/bin/ldap.sh clean Removed the LDAP PID file: /home/knox/knox-1.3.0-SNAPSHOT/pids/ldap.pid. Removed the LDAP OUT file: /home/knox/knox-1.3.0-SNAPSHOT/logs/ldap.out. Removed the LDAP ERR file: /home/knox/knox-1.3.0-SNAPSHOT/logs/ldap.err. $ ./knox-1.3.0-SNAPSHOT/bin/ldap.sh status LDAP is not running. No PID file found. $ ./knox-1.3.0-SNAPSHOT/bin/ldap.sh start --printEnv APP_CONF_DIR = /home/knox/knox-1.3.0-SNAPSHOT/conf APP_LOG_DIR = /home/knox/knox-1.3.0-SNAPSHOT/logs APP_PID_DIR = /home/knox/knox-1.3.0-SNAPSHOT/pids APP_JAR = /home/knox/knox-1.3.0-SNAPSHOT/bin/ldap.jar Starting LDAP succeeded with PID 28458. $ tail knox-1.3.0-SNAPSHOT/logs/ldap.log 2019-03-13 13:29:48,691 ERROR entry.Value (Value.java:<init>(273)) - ERR_13725_CANNOT_HANDLE_NAME_AND_OPTIONAL_UID_NORM I do not know how to handle NameAndOptionalUID normalization with objects of class: homeurl 2019-03-13 13:29:48,692 ERROR entry.Value (Value.java:<init>(273)) - ERR_13725_CANNOT_HANDLE_NAME_AND_OPTIONAL_UID_NORM I do not know how to handle NameAndOptionalUID normalization with objects of class: workurl 2019-03-13 13:29:48,692 ERROR entry.Value (Value.java:<init>(273)) - ERR_13725_CANNOT_HANDLE_NAME_AND_OPTIONAL_UID_NORM I do not know how to handle NameAndOptionalUID normalization with objects of class: custom1 2019-03-13 13:29:48,692 ERROR entry.Value (Value.java:<init>(273)) - ERR_13725_CANNOT_HANDLE_NAME_AND_OPTIONAL_UID_NORM I do not know how to handle NameAndOptionalUID normalization with objects of class: custom2 2019-03-13 13:29:48,692 ERROR entry.Value (Value.java:<init>(273)) - ERR_13725_CANNOT_HANDLE_NAME_AND_OPTIONAL_UID_NORM I do not know how to handle NameAndOptionalUID normalization with objects of class: custom3 2019-03-13 13:29:48,692 ERROR entry.Value (Value.java:<init>(273)) - ERR_13725_CANNOT_HANDLE_NAME_AND_OPTIONAL_UID_NORM I do not know how to handle NameAndOptionalUID normalization with objects of class: custom4 2019-03-13 13:29:48,692 ERROR entry.Value (Value.java:<init>(273)) - ERR_13725_CANNOT_HANDLE_NAME_AND_OPTIONAL_UID_NORM I do not know how to handle NameAndOptionalUID normalization with objects of class: nsAIMid 2019-03-13 13:29:48,699 ERROR entry.Value (Value.java:<init>(273)) - ERR_13725_CANNOT_HANDLE_NAME_AND_OPTIONAL_UID_NORM I do not know how to handle NameAndOptionalUID normalization with objects of class: automountInformation 2019-03-13 13:29:50,844 INFO ldap.LdapServer (LdapServer.java:startNetwork(722)) - Successful bind of an LDAP Service (33389) is completed. 2019-03-13 13:29:50,845 INFO ldap.LdapServer (LdapServer.java:start(589)) - Ldap service started. $ ps -ef | grep ldap.jar knox 30767 1 33 13:31 pts/0 00:00:07 /bin/java -jar /home/knox/knox-1.3.0-SNAPSHOT/bin/ldap.jar /home/knox/knox-1.3.0-SNAPSHOT/conf knox 30988 20240 0 13:32 pts/0 00:00:00 grep --color=auto ldap.jar $ ./knox-1.3.0-SNAPSHOT/bin/ldap.sh status LDAP is running with PID 28458. $ ./knox-1.3.0-SNAPSHOT/bin/ldap.sh stop Stopping LDAP with PID 28458 succeeded. $ ./knox-1.3.0-SNAPSHOT/bin/ldap.sh status LDAP is not running. No PID file found. $ ps -ef | grep ldap.jar knox 30698 20240 0 13:31 pts/0 00:00:00 grep --color=auto ldap.jar ``` After both the Gateway server and the test LDAP instance were up&running I was able to login to admin UI.
---------------------------------------------------------------- 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
