You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/08/15 09:42:00 UTC
[jira] [Work logged] (KNOX-1957) gateway.sh doesn't handle
KNOX_GATEWAY_DBG_OPTS env var correctly
[ https://issues.apache.org/jira/browse/KNOX-1957?focusedWorklogId=295356&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-295356 ]
ASF GitHub Bot logged work on KNOX-1957:
----------------------------------------
Author: ASF GitHub Bot
Created on: 15/Aug/19 09:41
Start Date: 15/Aug/19 09:41
Worklog Time Spent: 10m
Work Description: smolnar82 commented on pull request #131: KNOX-1957 - Optional APP_JAVA_OPTS are handled properly
URL: https://github.com/apache/knox/pull/131
## What changes were proposed in this pull request?
It seems [KNOX-1816](https://issues.apache.org/jira/browse/KNOX-1816) caused a regression wrt the way options are handled in the scripts (e.g., gateway.sh).
Specifically, if the `KNOX_GATEWAY_DBG_OPTS `env var is set, even though the value is included in the resulting command, the JVM does not listen on the configured port.
The issue appears to be the double-quoting of `$APP_JAVA_OPTS` in knox-functions.sh, specifically in the `appStart` function (for this particular error).
## How was this patch tested?
Running JUnit tests:
```
$ mvn clean -Dshellcheck=true -T1C verify -Prelease,package
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17:52 min (Wall Clock)
[INFO] Finished at: 2019-08-15T11:17:57+02:00
[INFO] Final Memory: 383M/2232M
[INFO] ------------------------------------------------------------------------
```
Additionally, I tested the Knox CLI as follows:
```
################
## knoxcli.sh ##
################
$ bin/knoxcli.sh create-master --master master
APP_JAVA_OPTS = -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Djava.library.path=/Users/smolnar/test/knoxGateway/ext/native
Listening for transport dt_socket at address: 5005
$ unset KNOX_CLI_DBG_OPTS
$ bin/knoxcli.sh create-master --master master
APP_JAVA_OPTS = -Djava.library.path=/Users/smolnar/test/knoxGateway/ext/native
Master secret has been persisted to disk.
$ bin/knoxcli.sh create-master --master master
APP_JAVA_OPTS = -Djava.library.path=/Users/smolnar/test/knoxGateway/ext/native
Master secret is already present on disk. Please be aware that overwriting it will require updating other security artifacts. Use --force to overwrite the existing master secret.
$ bin/knoxcli.sh create-master --master master --force
APP_JAVA_OPTS = -Djava.library.path=/Users/smolnar/test/knoxGateway/ext/native
Master secret has been persisted to disk.
```
```
################
## gateway.sh ##
################
$ bin/gateway.sh
Usage: bin/gateway.sh {start|stop|status|clean}
$ bin/gateway.sh status
Gateway is not running. No PID file found.
$ bin/gateway.sh clean
Removed the Gateway PID file.
Removed the Gateway OUT file.
Removed the Gateway ERR file.
$ bin/gateway.sh start
APP_JAVA_OPTS = -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Djava.library.path=/Users/smolnar/test/knoxGateway/ext/native
Starting Gateway succeeded with PID 49362.
$ bin/gateway.sh status
Gateway is running with PID 49362.
$ bin/gateway.sh clean
Can't clean files. Gateway is running with PID 49362.
$ bin/gateway.sh start
APP_JAVA_OPTS = -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Djava.library.path=/Users/smolnar/test/knoxGateway/ext/native
Gateway is already running with PID 49362.
$ bin/gateway.sh stop
Stopping Gateway with PID 49362 succeeded.
$ bin/gateway.sh status
Gateway is not running. No PID file found.
```
During gateway start I was able to connect to the Java process on localhost:5005 using my IDE's remote debugging feature.
```
#############
## ldap.sh ##
#############
$ bin/ldap.sh
Usage: bin/ldap.sh {start|stop|status|clean}
$ bin/ldap.sh status
LDAP is not running. No PID file found.
$ bin/ldap.sh stop
LDAP is not running.
$ bin/ldap.sh clean
Removed the LDAP PID file.
Removed the LDAP OUT file.
Removed the LDAP ERR file.
$ bin/ldap.sh start
APP_JAVA_OPTS = -Djava.library.path=/Users/smolnar/test/knoxGateway/ext/native
Starting LDAP succeeded with PID 49719.
$ bin/ldap.sh start
APP_JAVA_OPTS = -Djava.library.path=/Users/smolnar/test/knoxGateway/ext/native
LDAP is already running with PID 49719.
$ bin/ldap.sh clean
Can't clean files. LDAP is running with PID 49719.
$ bin/ldap.sh status
LDAP is running with PID 49719.
$ bin/ldap.sh clean
Can't clean files. LDAP is running with PID 49719.
$ bin/ldap.sh stop
Stopping LDAP with PID 49719 succeeded.
$ bin/ldap.sh stop
LDAP is not running.
```
```
##################
## knoxshell.sh ##
##################
$ bin/knoxshell.sh help
Apache Knox Client Shell
The client shell facility provide a CLI for establishing and managing Apache Knox Sessions
and executing the Apache Knox groovy-based DSL scripts. It may also be used to enter an
interactive shell where groovy-based DSL and groovy code may be entered and executed in realtime.
knoxshell usage:
knoxshell.sh [[buildTrustStore <knox-gateway-url>|init <topology-url>|list|destroy|help] | [<script-file-name>]]
----------------------------------------------------------
buildTrustStore <knox-gateway-url> - downloads the given gateway server's public certificate and builds a trust store to be used by KnoxShell
example: knoxshell.sh buildTrustStore https://localhost:8443/
init <topology-url> - requests a session from the knox token service at the url
example: knoxshell.sh init https://localhost:8443/gateway/sandbox
list - lists the details of the cached knox session token
example: knoxshell.sh list
destroy - removes the cached knox session token
example: knoxshell.sh destroy
<script-file-name> - executes the groovy script file
example: knoxshell.sh ~/bin/ls.groovy
$ bin/knoxshell.sh buildTrustStore https://localhost:8443/
Opening connection to localhost:8443...
Starting SSL handshake...
Gateway server's certificate is exported into /Users/smolnar/gateway-client-trust.jks
$ bin/knoxshell.sh init https://localhost:8443/gateway/sandbox
Enter username: admin
Enter password:
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
knoxinit successful!
Token Type: Bearer
Expires On: 08/15/2019 08:44:49
Target URL: https://localhost:8443/gateway/tokenbased
$ bin/knoxshell.sh list
Token Type: Bearer
Expires On: 08/15/2019 08:44:49
Target URL: https://localhost:8443/gateway/tokenbased
```
----------------------------------------------------------------
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:
users@infra.apache.org
Issue Time Tracking
-------------------
Worklog Id: (was: 295356)
Time Spent: 10m
Remaining Estimate: 0h
> gateway.sh doesn't handle KNOX_GATEWAY_DBG_OPTS env var correctly
> -----------------------------------------------------------------
>
> Key: KNOX-1957
> URL: https://issues.apache.org/jira/browse/KNOX-1957
> Project: Apache Knox
> Issue Type: Bug
> Components: Server
> Affects Versions: 1.4.0
> Reporter: Phil Zampino
> Assignee: Sandor Molnar
> Priority: Major
> Fix For: 1.4.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> It seems KNOX-1816 caused a regression wrt the way options are handled in the scripts (e.g., gateway.sh).
> Specifically, if the KNOX_GATEWAY_DBG_OPTS env var is set, even though the value is included in the resulting command, the JVM does not listen on the configured port.
> The issue appears to be the double-quoting of $APP_JAVA_OPTS in knox-functions.sh, specifically in the appStart function (for this particular error).
> This shellcheck doc may be helpful in resolving this issue: [https://github.com/koalaman/shellcheck/wiki/SC2086]
>
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)