diff options
author | Instrumental <jonathan.gathman@att.com> | 2019-03-29 15:42:37 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2019-03-29 16:53:00 -0500 |
commit | aae5c072bcb4608ae87c70fd1edf7ac5b1794ccf (patch) | |
tree | 3607e74c88a9c8f054c5535b25f1781513b3acac | |
parent | 1ee8f051ba40bf4f3578952ae499dd15549a86a9 (diff) |
Refine Container Startup
Issue-ID: AAF-773
Change-Id: Ia198a11eceb9bfacafde26cde97d15949a3fe78c
Signed-off-by: Instrumental <jonathan.gathman@att.com>
-rw-r--r-- | auth/auth-cass/cass_init/cmd.sh | 2 | ||||
-rw-r--r-- | auth/auth-cass/docker/Dockerfile.cass | 2 | ||||
-rw-r--r-- | auth/auth-cass/docker/dbuild.sh | 8 | ||||
-rw-r--r-- | auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java | 1 | ||||
-rw-r--r-- | auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java | 38 | ||||
-rw-r--r-- | auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java | 5 | ||||
-rw-r--r-- | auth/docker/Dockerfile.base | 2 | ||||
-rw-r--r-- | auth/docker/Dockerfile.client | 1 | ||||
-rw-r--r-- | auth/docker/Dockerfile.config | 1 | ||||
-rw-r--r-- | auth/docker/agent.sh | 12 | ||||
-rw-r--r-- | auth/docker/d.props.init | 2 | ||||
-rwxr-xr-x | auth/docker/dbuild.sh | 15 | ||||
-rw-r--r-- | auth/helm/aaf/aaf.sh | 84 | ||||
-rw-r--r-- | auth/helm/aaf/templates/aaf-fs.yaml | 2 | ||||
-rw-r--r-- | auth/helm/aaf/templates/aaf-locate.yaml | 2 | ||||
-rw-r--r-- | auth/helm/aaf/values.yaml | 12 | ||||
-rw-r--r-- | auth/sample/bin/pod_wait.sh | 32 | ||||
-rw-r--r-- | auth/sample/etc/org.osaaf.aaf.locate.props | 2 | ||||
-rw-r--r-- | docs/sections/configuration/AAF_4.1_config.rst | 4 | ||||
-rw-r--r-- | docs/sections/configuration/onboard.rst | 1 |
20 files changed, 173 insertions, 55 deletions
diff --git a/auth/auth-cass/cass_init/cmd.sh b/auth/auth-cass/cass_init/cmd.sh index b26536d6..b6650122 100644 --- a/auth/auth-cass/cass_init/cmd.sh +++ b/auth/auth-cass/cass_init/cmd.sh @@ -149,7 +149,7 @@ case "$1" in # Startup like normal echo "Cassandra Startup" - exec /usr/local/bin/docker-entrypoint.sh + exec -c "/usr/local/bin/docker-entrypoint.sh" ;; wait) # Wait for initialization. This can be called from Docker only as a check to make sure it is ready diff --git a/auth/auth-cass/docker/Dockerfile.cass b/auth/auth-cass/docker/Dockerfile.cass index 52aa49c8..0406411f 100644 --- a/auth/auth-cass/docker/Dockerfile.cass +++ b/auth/auth-cass/docker/Dockerfile.cass @@ -18,7 +18,7 @@ # ============LICENSE_END==================================================== # # Use dbuild.sh input parameter to set registry -FROM ${REGISTRY}cassandra:3.11 +FROM ${REGISTRY}/cassandra:3.11 MAINTAINER AAF Team, AT&T 2018 ENV VERSION=${AAF_VERSION} diff --git a/auth/auth-cass/docker/dbuild.sh b/auth/auth-cass/docker/dbuild.sh index 2913b1af..17d359ce 100644 --- a/auth/auth-cass/docker/dbuild.sh +++ b/auth/auth-cass/docker/dbuild.sh @@ -29,10 +29,10 @@ DOCKER=${DOCKER:-docker} echo "$0: Building aaf_cass Container for aaf_cass:$VERSION" # default nexus repo only contains Amd64 images, use docker.io for multi-platform builds -if [[ $1 && $1 == "docker.io" ]]; then - DOCKER_PULL_REGISTRY='' -else - DOCKER_PULL_REGISTRY='nexus3.onap.org:10001\/' +if [ $# -gt 0 ]; then + if [ "$1" == "-r" ]; then + DOCKER_PULL_REGISTRY=$2 + fi fi echo "$0: DOCKER_PULL_REGISTRY=${DOCKER_REGISTRY}" diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java index e2317a52..02d93512 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java @@ -187,5 +187,4 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte } return def; } - } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java index fe610e57..ee92540b 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java @@ -19,7 +19,10 @@ * */ package org.onap.aaf.auth.server; +import java.io.File; import java.io.IOException; +import java.net.Inet4Address; +import java.net.UnknownHostException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @@ -29,6 +32,7 @@ import org.onap.aaf.auth.org.OrganizationFactory; import org.onap.aaf.auth.rserv.RServlet; import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.Access.Level; +import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.register.Registrant; import org.onap.aaf.cadi.register.Registrar; import org.onap.aaf.misc.env.Trans; @@ -38,6 +42,7 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr private Registrar<ENV> registrar; private boolean do_register; protected AbsService<ENV,TRANS> service; + protected String hostname; public AbsServiceStarter(final AbsService<ENV,TRANS> service) { @@ -52,6 +57,14 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr // for Debugging purposes without fear that real clients will start to call your debug instance do_register = !"TRUE".equalsIgnoreCase(access().getProperty("aaf_locate_no_register",null)); _propertyAdjustment(); + hostname = access().getProperty(Config.HOSTNAME, null); + if (hostname==null) { + try { + hostname = Inet4Address.getLocalHost().getHostName(); + } catch (UnknownHostException e) { + hostname= "cannotBeDetermined"; + } + } } public abstract void _start(RServlet<TRANS> rserv) throws Exception; @@ -70,6 +83,8 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr ExecutorService es = Executors.newSingleThreadExecutor(); Future<?> app = es.submit(this); final AbsServiceStarter<?,?> absSS = this; + // Docker/K8 may separately create startup Status in this dir for startup + // sequencing. If so, delete ON EXIT Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { @@ -120,7 +135,28 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr registrar=null; } if (service!=null) { - service.destroy(); + File status = new File("/opt/app/aaf/status/"); + boolean deleted = false; + if(status.exists()) { + int lastdot = service.app_name.lastIndexOf("aaf."); + String fname; + if(lastdot<0) { + fname = service.app_name + '-' + hostname; + } else { + fname = service.app_name.substring(lastdot).replace('.', '-') + + '-' + hostname; + } + status = new File(status, fname); + if(status.exists()) { + status.delete(); + } + } + if(deleted) { + service.access.log(Level.INIT, "Deleted Status",status.getAbsolutePath()); + } else { + service.access.log(Level.INIT, "Status not deleted: ",status.getAbsolutePath()); + } + service.destroy(); } } } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java index 1256c601..182956cf 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java @@ -21,7 +21,6 @@ package org.onap.aaf.auth.server; import java.io.IOException; -import java.net.Inet4Address; import java.net.InetAddress; import java.util.Properties; @@ -93,10 +92,6 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex @Override public void _start(RServlet<TRANS> rserv) throws Exception { - String hostname = access().getProperty(Config.HOSTNAME, null); - if (hostname==null) { - hostname = Inet4Address.getLocalHost().getHostName(); - } final int port = Integer.parseInt(access().getProperty("port","0")); final String keystore = access().getProperty(Config.CADI_KEYSTORE, null); final int IDLE_TIMEOUT = Integer.parseInt(access().getProperty(Config.AAF_CONN_IDLE_TIMEOUT, Config.AAF_CONN_IDLE_TIMEOUT_DEF)); diff --git a/auth/docker/Dockerfile.base b/auth/docker/Dockerfile.base index ad8e271c..35ade62b 100644 --- a/auth/docker/Dockerfile.base +++ b/auth/docker/Dockerfile.base @@ -18,7 +18,7 @@ # ============LICENSE_END==================================================== # # Use dbuild.sh input parameter to set registry -FROM ${REGISTRY}openjdk:8-jre-alpine +FROM ${REGISTRY}/openjdk:8-jre-alpine MAINTAINER AAF Team, AT&T 2018 LABEL description="aaf_base" diff --git a/auth/docker/Dockerfile.client b/auth/docker/Dockerfile.client index 111c3774..b62f7b4f 100644 --- a/auth/docker/Dockerfile.client +++ b/auth/docker/Dockerfile.client @@ -18,7 +18,6 @@ # ============LICENSE_END==================================================== # FROM ${DOCKER_REPOSITORY}/onap/aaf/aaf_base:${AAF_VERSION} -#FROM nexus3.onap.org:10001/onap/aaf/aaf-base-xenial:latest MAINTAINER AAF Team, AT&T 2018 ENV VERSION=${AAF_VERSION} diff --git a/auth/docker/Dockerfile.config b/auth/docker/Dockerfile.config index 7e442b2a..27b2ffff 100644 --- a/auth/docker/Dockerfile.config +++ b/auth/docker/Dockerfile.config @@ -18,7 +18,6 @@ # ============LICENSE_END==================================================== # FROM ${DOCKER_REPOSITORY}/onap/aaf/aaf_base:${AAF_VERSION} -#FROM nexus3.onap.org:10001/onap/aaf/aaf-base-xenial:latest MAINTAINER AAF Team, AT&T 2018 ENV VERSION=${AAF_VERSION} diff --git a/auth/docker/agent.sh b/auth/docker/agent.sh index ce878f58..931249b0 100644 --- a/auth/docker/agent.sh +++ b/auth/docker/agent.sh @@ -159,10 +159,10 @@ case "$1" in aafcli) shift reset_sso - if [ -f aaf-auth-cmd-$VERSION*-full.jar ]; then - java -Dcadi_prop_files="$HOME/.aaf/sso.props" -jar aaf-auth-cmd-$VERSION*-full.jar $@ + if [ -f aaf-cadi-aaf-$VERSION-full.jar ]; then + java -Dcadi_prop_files="$HOME/.aaf/sso.props" -jar aaf-cadi-aaf-$VERSION-full.jar $@ else - echo "For local use, you need to have 'aaf-auth-cmd-$VERSION*-full.jar' (or newer)" + echo "For local use, you need to have 'aaf-cadi-aaf-$VERSION-full.jar' (or newer)" fi ;; local) @@ -185,10 +185,10 @@ case "$1" in reset_sso sso aaf_id "$DEPLOY_FQI" sso aaf_password "$DEPLOY_PASSWORD" - if [ -f aaf-auth-cmd-$VERSION*-full.jar ]; then - java -Dcadi_prop_files="$HOME/.aaf/sso.props" -cp aaf-auth-cmd-$VERSION*-full.jar org.onap.aaf.cadi.configure.Agent $CMD + if [ -f aaf-cadi-aaf-$VERSION-full.jar ]; then + java -Dcadi_prop_files="$HOME/.aaf/sso.props" -cp aaf-cadi-aaf-$VERSION-full.jar org.onap.aaf.cadi.configure.Agent $CMD else - echo "For local use, you need to have 'aaf-cadi-aaf-$VERSION*-full.jar' (or newer)" + echo "For local use, you need to have 'aaf-cadi-aaf-$VERSION-full.jar' (or newer)" fi ;; *) diff --git a/auth/docker/d.props.init b/auth/docker/d.props.init index 54a3926d..b9eb0162 100644 --- a/auth/docker/d.props.init +++ b/auth/docker/d.props.init @@ -20,6 +20,8 @@ # Variables for building Docker entities ORG=onap PROJECT=aaf +# Note: Override can happen on dbuild.sh Commandline, -r <registry> +DOCKER_PULL_REGISTRY=nexus3.onap.org:10001 DOCKER_REPOSITORY=nexus3.onap.org:10003 VERSION=2.1.11-SNAPSHOT CONF_ROOT_DIR=/opt/app/osaaf diff --git a/auth/docker/dbuild.sh b/auth/docker/dbuild.sh index cdd97fc7..b2a5d510 100755 --- a/auth/docker/dbuild.sh +++ b/auth/docker/dbuild.sh @@ -21,7 +21,13 @@ # Docker Building Script. Reads all the components generated by install, on per-version basis # -DOCKER_PULL_REGISTRY='nexus3.onap.org:10001\/' +# Pull in Variables from d.props +if [ ! -e ./d.props ]; then + cp d.props.init d.props +fi + +. ./d.props + AAF_COMPONENTS=ALL # process input. originally, an optional positional parameter is used to designate a component. @@ -45,13 +51,6 @@ fi echo "$0: AAF_COMPONENTS=$AAF_COMPONENTS DOCKER_PULL_REGISTRY=$DOCKER_PULL_REGISTRY" -# Pull in Variables from d.props -if [ ! -e ./d.props ]; then - cp d.props.init d.props -fi - -. ./d.props - DOCKER=${DOCKER:=docker} echo "Building Containers for aaf components, version $VERSION" diff --git a/auth/helm/aaf/aaf.sh b/auth/helm/aaf/aaf.sh new file mode 100644 index 00000000..5bb83515 --- /dev/null +++ b/auth/helm/aaf/aaf.sh @@ -0,0 +1,84 @@ +. ../../docker/d.props +IMAGE=onap/aaf/aaf_agent:$VERSION + +kubectl -n onap run -it --rm aaf-agent-$USER --image=$IMAGE --overrides=' +{ + "spec": { + "containers": [ + { + "name": "aaf-agent-'$USER'", + "image": "'$IMAGE'", + "imagePullPolicy": "IfNotPresent", + "command": [ + "bash", + "-c", + "/opt/app/aaf_config/bin/agent.sh && cd /opt/app/osaaf/local && exec bash" + ], + "env": [ + { + "name": "aaf_locator_container", + "value": "helm" + },{ + "name": "aaf_locator_fqdn", + "value": "'$HOSTNAME'" + },{ + "name": "aaf_locator_url", + "value": "https://aaf-locate:8095" + },{ + "name": "aaf_locator_public_hostname", + "value": "'$HOSTNAME'" + },{ + "name": "AAF_ENV", + "value": "'$AAF_ENV'" + },{ + "name": "LATITUDE", + "value": "'$LATITUDE'" + },{ + "name": "LONGITUDE", + "value": "'$LONGITUDE'" + },{ + "name": "CASSANDRA_CLUSTER", + "value": "'$CASSANDRA_CLUSTER'" + },{ + "name": "CASSANDRA_USER", + "value": "'$CASSANDRA_USER'" + },{ + "name": "CASSANDRA_PASSWORD", + "value": "'$CASSANDRA_PASSWORD'" + },{ + "name": "CASSANDRA_PORT", + "value": "'$CASSANDRA_PORT'" + } + ], + "stdin": true, + "stdinOnce": true, + "tty": true, + "volumeMounts": [ + { + "mountPath": "/opt/app/osaaf", + "name": "aaf-config-vol" + }, + { + "mountPath": "/opt/app/aaf/status", + "name": "aaf-status-vol" + } + ] + } + ], + "volumes": [ + { + "name": "aaf-config-vol", + "persistentVolumeClaim": { + "claimName": "aaf-config-pvc" + } + }, + { + "name": "aaf-status-vol", + "persistentVolumeClaim": { + "claimName": "aaf-status-pvc" + } + } + ] + } +} +' --restart=Never -- bash diff --git a/auth/helm/aaf/templates/aaf-fs.yaml b/auth/helm/aaf/templates/aaf-fs.yaml index 999b8d13..d53e9201 100644 --- a/auth/helm/aaf/templates/aaf-fs.yaml +++ b/auth/helm/aaf/templates/aaf-fs.yaml @@ -41,7 +41,7 @@ metadata: labels: app: aaf-fs spec: - replicas: 0 + replicas: {{ .Values.replicas.fs }} selector: matchLabels: app: aaf-fs diff --git a/auth/helm/aaf/templates/aaf-locate.yaml b/auth/helm/aaf/templates/aaf-locate.yaml index 1e05dcb7..b09c80b8 100644 --- a/auth/helm/aaf/templates/aaf-locate.yaml +++ b/auth/helm/aaf/templates/aaf-locate.yaml @@ -41,7 +41,7 @@ metadata: labels: app: aaf-locate spec: - replicas: 0 + replicas: {{ .Values.replicas.locate }} selector: matchLabels: app: aaf-locate diff --git a/auth/helm/aaf/values.yaml b/auth/helm/aaf/values.yaml index 417e9fb5..7556f251 100644 --- a/auth/helm/aaf/values.yaml +++ b/auth/helm/aaf/values.yaml @@ -30,11 +30,11 @@ global: replicas: cass: 1 - service: 0 - locator: 0 - oauth: 0 - cm: 0 - gui: 0 + service: 1 + locator: 1 + oauth: 1 + cm: 1 + gui: 1 hello: 0 ingress: @@ -56,7 +56,7 @@ persistence: mountSubPath: "config" storageClass: "manual" status: - volumeReclaimPolicy: Retain + volumeReclaimPolicy: Delete accessMode: ReadWriteOnce size: 10M mountSubPath: "status" diff --git a/auth/sample/bin/pod_wait.sh b/auth/sample/bin/pod_wait.sh index 07ff9814..3d6a1b9e 100644 --- a/auth/sample/bin/pod_wait.sh +++ b/auth/sample/bin/pod_wait.sh @@ -29,17 +29,17 @@ shift function status { if [ -d "$DIR" ]; then - echo "$@" > $DIR/$APP + echo "$@" > $DIR/$APP-$HOSTNAME fi } function check { if [ -d "$DIR" ]; then - if [ -e "$DIR/$OTHER" ]; then - echo "$(cat $DIR/$OTHER)" - else + if [ -z "$(ls $DIR/$OTHER* 2> /dev/null)" ]; then echo "$DIR/$OTHER does not exist" + else + echo "$(cat $DIR/$OTHER*)" fi else echo "$DIR does not exist" @@ -51,13 +51,13 @@ function wait { while [ $n -lt 40 ]; do rv="$(check)" echo "$rv" - if [ "$rv" = "ready" ]; then - echo "$OTHER is $rv" - n=10000 - else + if [ -z "$(echo $rv | grep "ready")" ]; then (( ++n )) echo "Sleep 10 (iteration $n)" sleep 10 + else + echo "$OTHER is $rv" + n=10000 fi done } @@ -67,15 +67,15 @@ function start { while [ $n -lt 40 ]; do rv="$(check)" echo "$OTHER is $rv" - if [ "$rv" = "ready" ]; then + if [ -z "$(echo $rv | grep "ready")" ]; then + (( ++n )) + echo "Sleep 10 (iteration $n)" + sleep 10 + else # This is critical. Until status is literally "ready" in the status directory, no processes will start status ready echo "Starting $@" n=10000 - else - (( ++n )) - echo "Sleep 10 (iteration $n)" - sleep 10 fi done } @@ -89,6 +89,10 @@ case "$OTHER" in status "ready" echo "Done" ;; + stop) + echo "Removing $DIR/$APP-$HOSTNAME" + rm $DIR/$APP-$HOSTNAME + ;; wait) OTHER="$1" shift @@ -102,4 +106,4 @@ case "$OTHER" in ;; esac -eval "$@" +eval "$@" diff --git a/auth/sample/etc/org.osaaf.aaf.locate.props b/auth/sample/etc/org.osaaf.aaf.locate.props index 09798334..a132abd6 100644 --- a/auth/sample/etc/org.osaaf.aaf.locate.props +++ b/auth/sample/etc/org.osaaf.aaf.locate.props @@ -22,7 +22,7 @@ ## AAF Locator Properties ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props -aaf_locator_entries=locator +aaf_locator_entries=locate port=8095 aaf_locator_public_port.helm=30081 #aaf_locator_public_port.oom= diff --git a/docs/sections/configuration/AAF_4.1_config.rst b/docs/sections/configuration/AAF_4.1_config.rst index ff9816a1..453ee231 100644 --- a/docs/sections/configuration/AAF_4.1_config.rst +++ b/docs/sections/configuration/AAF_4.1_config.rst @@ -48,11 +48,11 @@ Prerequisites * (You can also get the ONAP TEST Root CA there) - * the latest aaf-auth-cmd-<VERSION>-full.jar from `ONAP Nexus`_. + * the latest aaf-cadi-aaf-<VERSION>-full.jar from `ONAP Nexus`_. * you can still use the same "agent.sh" script below .. _AAF FileServer: http://aaf-onap-test.osaaf.org/- -.. _ONAP Nexus: https://nexus.onap.org/#nexus-search;quick~aaf-auth-cmd +.. _ONAP Nexus: https://nexus.onap.org/#nexus-search;gav~~aaf-cadi-aaf~~~ ----------------------- Obtain the Agent Script diff --git a/docs/sections/configuration/onboard.rst b/docs/sections/configuration/onboard.rst index 6f80e6e9..4a1fa73b 100644 --- a/docs/sections/configuration/onboard.rst +++ b/docs/sections/configuration/onboard.rst @@ -8,6 +8,7 @@ In running AAF cd /opt/app/osaaf/data vi identities.dat insert like the following + ngi|ONAP NGI Application|NGI|ONAP Application|||a|aaf_admin Save (:wq) |