[GitHub] nifi pull request #2746: NIFI-5247 NiFi toolkit signal handling changes, Doc...

2018-06-01 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/nifi/pull/2746


---


[GitHub] nifi pull request #2746: NIFI-5247 NiFi toolkit signal handling changes, Doc...

2018-05-31 Thread jtstorck
Github user jtstorck commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2746#discussion_r192240524
  
--- Diff: nifi-toolkit/nifi-toolkit-assembly/docker/tests/exit-codes.sh ---
@@ -0,0 +1,35 @@
+#!/bin/bash
--- End diff --

This file needs to be added to the excludes for the apache-rat-plugin in 
nifi-toolkit-assembly.


---


[GitHub] nifi pull request #2746: NIFI-5247 NiFi toolkit signal handling changes, Doc...

2018-05-31 Thread jtstorck
Github user jtstorck commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2746#discussion_r192240688
  
--- Diff: nifi-toolkit/nifi-toolkit-assembly/docker/tests/tls-toolkit.sh ---
@@ -0,0 +1,17 @@
+#!/bin/bash
--- End diff --

This file needs to be added to the excludes for the apache-rat-plugin in 
nifi-toolkit-assembly.


---


[GitHub] nifi pull request #2746: NIFI-5247 NiFi toolkit signal handling changes, Doc...

2018-05-30 Thread pepov
Github user pepov commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2746#discussion_r191681207
  
--- Diff: nifi-toolkit/nifi-toolkit-assembly/src/main/resources/bin/cli.sh 
---
@@ -111,8 +111,7 @@ run() {
export NIFI_TOOLKIT_HOME="$NIFI_TOOLKIT_HOME"
 
umask 0077
-   "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms128m -Xmx256m} 
org.apache.nifi.toolkit.cli.CLIMain "$@"
-   return $?
+   exec "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms128m -Xmx256m} 
org.apache.nifi.toolkit.cli.CLIMain "$@"
--- End diff --

I've also ran `mvn package -P docker` in the 
nifi-toolkit/nifi-toolkit-assembly folder and ran the following return code 
tests using the newly built dockerfile:

Command not specified:
```
docker run --rm apache/nifi-toolkit:1.7.0-SNAPSHOT tls-toolkit; echo $?
Expected at least a service argument.

Usage: tls-toolkit service [-h] [args]

Services:
   standalone: Creates certificates and config files for nifi cluster.
   server: Acts as a Certificate Authority that can be used by clients to 
get Certificates
   client: Generates a private key and gets it signed by the certificate 
authority.
   status: Checks the status of an HTTPS endpoint by making a GET request 
using a supplied keystore and truststore.

2
```

Argument error:
```
docker run --rm apache/nifi-toolkit:1.7.0-SNAPSHOT tls-toolkit client; echo 
$?
token argument must not be empty unless useConfigJson or configJsonIn set

usage: org.apache.nifi.toolkit.tls.TlsToolkitMain [-a ] [-c ] [-C 
] [--configJsonIn ] [-D ] [-f ] [-F] [-g] [-h] [-k ] 
[-p
   ] [--subjectAlternativeNames ] [-T ] [-t ]

Generates a private key and gets it signed by the certificate authority.

 -a,--keyAlgorithmAlgorithm to use for generated 
keys. (default: RSA)
 -c,--certificateAuthorityHostnameHostname of NiFi Certificate 
Authority (default: localhost)
 -C,--certificateDirectoryThe file to write the CA 
certificate to (default: .)
--configJsonInThe place to read configuration 
info from (defaults to the value of configJson), implies useConfigJson if set.
   (default: configJson value)
 -D,--dn  The dn to use for the client 
certificate (default: CN=0d2f3cfed775,OU=NIFI)
 -f,--configJson  The place to write configuration 
info (default: config.json)
 -F,--useConfigJsonFlag specifying that all 
configuration is read from configJson to facilitate automated use (otherwise 
configJson will
   only be written to.
 -g,--differentKeyAndKeystorePasswords Use different generated password 
for the key and the keyStore.
 -h,--help Print help and exit.
 -k,--keySize Number of bits for generated 
keys. (default: 2048)
 -p,--PORTThe port to use to communicate 
with the Certificate Authority (default: 8443)
--subjectAlternativeNames Comma-separated list of domains 
to use as Subject Alternative Names in the certificate
 -T,--keyStoreTypeThe type of keyStores to 
generate. (default: jks)
 -t,--token   The token to use to prevent MITM 
(required and must be same as one used by CA)

Java home: /usr/lib/jvm/java-1.8-openjdk/jre
NiFi Toolkit home: /opt/nifi-toolkit/nifi-toolkit-1.7.0-SNAPSHOT
8
```

Service error:
```
docker run --rm apache/nifi-toolkit:1.7.0-SNAPSHOT tls-toolkit client -t 
$(uuidgen); echo $?
2018/05/30 08:23:44 INFO [main] 
org.apache.nifi.toolkit.tls.service.client.TlsCertificateAuthorityClient: 
Requesting new certificate from localhost:8443
2018/05/30 08:23:45 INFO [main] 
org.apache.nifi.toolkit.tls.service.client.TlsCertificateSigningRequestPerformer:
 Requesting certificate with dn CN=24e8d8c4c0da,OU=NIFI from localhost:8443
Service client error: Connect to localhost:8443 [localhost/127.0.0.1] 
failed: Connection refused (Connection refused)

Usage: tls-toolkit service [-h] [args]

Services:
   standalone: Creates certificates and config files for nifi cluster.
   server: Acts as a Certificate Authority that can be used by clients to 
get Certificates
   client: Generates a private key and gets it signed by the certificate 
authority.
   status: Checks the status of an HTTPS endpoint by making a GET request 
using a supplied keystore and truststore.

3
```


---


[GitHub] nifi pull request #2746: NIFI-5247 NiFi toolkit signal handling changes, Doc...

2018-05-30 Thread pepov
Github user pepov commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2746#discussion_r191668440
  
--- Diff: nifi-toolkit/nifi-toolkit-assembly/src/main/resources/bin/cli.sh 
---
@@ -111,8 +111,7 @@ run() {
export NIFI_TOOLKIT_HOME="$NIFI_TOOLKIT_HOME"
 
umask 0077
-   "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms128m -Xmx256m} 
org.apache.nifi.toolkit.cli.CLIMain "$@"
-   return $?
+   exec "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms128m -Xmx256m} 
org.apache.nifi.toolkit.cli.CLIMain "$@"
--- End diff --

exec is typically used for redirecting file descriptors for the current 
shell, the redirection errors should refer to that. Otherwise the return code 
of the program is not modified, since exec gets out of the way as soon as the 
program is started so that the return code is not manipulated in any way.

```sh
# start a container 
docker run --rm -ti debian bash

# setup a file to exit with the input argument
cat < test.sh
#!/bin/bash

exit \$1
EOF
chmod +x test.sh

# observe that exit codes are preserved
for i in 0 1 2 3; do sh -c "exec ./test.sh $i"; echo $?; done
```


---


[GitHub] nifi pull request #2746: NIFI-5247 NiFi toolkit signal handling changes, Doc...

2018-05-29 Thread bbende
Github user bbende commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2746#discussion_r191555681
  
--- Diff: nifi-toolkit/nifi-toolkit-assembly/src/main/resources/bin/cli.sh 
---
@@ -111,8 +111,7 @@ run() {
export NIFI_TOOLKIT_HOME="$NIFI_TOOLKIT_HOME"
 
umask 0077
-   "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms128m -Xmx256m} 
org.apache.nifi.toolkit.cli.CLIMain "$@"
-   return $?
+   exec "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms128m -Xmx256m} 
org.apache.nifi.toolkit.cli.CLIMain "$@"
--- End diff --

Does this have the same behavior in terms of the exit code that will be 
returned from calling cli.sh?

I'm not familiar with exec, but it is import for the CLI that exit code 
from the Java process is returned from calling cli.sh. 

The man page for exec says:
"If there are no redirection errors, the return status is zero; otherwise 
the return status is non-zero."

It is not clear to me if a redirection error is an error from the Java 
process, or an error replacing the current shell with the Java process.


---


[GitHub] nifi pull request #2746: NIFI-5247 NiFi toolkit signal handling changes, Doc...

2018-05-29 Thread pepov
GitHub user pepov opened a pull request:

https://github.com/apache/nifi/pull/2746

NIFI-5247 NiFi toolkit signal handling changes, Dockerfile enhancements

nifi-toolkit bash entry points should leverage exec to replace bash with 
the current java process in order to handle signals properly in docker. Also 
add bash, openssl, jq to make certificate request operations easier

Thank you for submitting a contribution to Apache NiFi.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

### For all changes:
- [x] Is there a JIRA ticket associated with this PR? Is it referenced 
 in the commit message?

- [x] Does your PR title start with NIFI- where  is the JIRA number 
you are trying to resolve? Pay particular attention to the hyphen "-" character.

- [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?

- [x] Is your initial contribution a single, squashed commit?

### For code changes:
- [ ] Have you ensured that the full suite of tests is executed via mvn 
-Pcontrib-check clean install at the root nifi folder?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? 
- [ ] If applicable, have you updated the LICENSE file, including the main 
LICENSE file under nifi-assembly?
- [ ] If applicable, have you updated the NOTICE file, including the main 
NOTICE file found under nifi-assembly?
- [ ] If adding new Properties, have you added .displayName in addition to 
.name (programmatic access) for each of the new properties?

### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in 
which it is rendered?

### Note:
Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/pepov/nifi NIFI-5247

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/nifi/pull/2746.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2746


commit f20b05b8560426ee3c195d2480379771cee066f3
Author: pepov 
Date:   2018-05-24T14:15:55Z

NIFI-5247 nifi-toolkit bash entry points should leverage exec to replace 
bash with the current java process in order to handle signals properly in 
docker. Also add bash, openssl, jq to make certificate request operations easier




---