summaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/main
diff options
context:
space:
mode:
authorwr148d <wr148d@att.com>2021-08-18 20:07:45 -0400
committerwr148d <wr148d@att.com>2021-08-19 15:54:48 -0400
commitb0a918e6c3dd77fdf456160257680f5c519aa94b (patch)
tree51cb41933e8cb440f0672166bcaa27e46743054c /aai-traversal/src/main
parentfd3ec07e00ff409d92fea0a3ae11260669a9197a (diff)
[AAI] Updates for latest versions for Istanbul
Issue-ID: AAI-3361 Change-Id: I0af66a4e683cea6d543a77b8cc4a329cc92a8a95 Signed-off-by: wr148d <wr148d@att.com>
Diffstat (limited to 'aai-traversal/src/main')
-rw-r--r--aai-traversal/src/main/resources/application.properties4
1 files changed, 2 insertions, 2 deletions
diff --git a/aai-traversal/src/main/resources/application.properties b/aai-traversal/src/main/resources/application.properties
index 4ef501b..0cc0473 100644
--- a/aai-traversal/src/main/resources/application.properties
+++ b/aai-traversal/src/main/resources/application.properties
@@ -55,7 +55,7 @@ server.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
server.ssl.trust-store=${server.certs.location}${server.truststore.name}
server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23
+schema.version.list=v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24
# Specifies which component should the oxm be looking at
schema.source.name=onap
# End of Internal Specific Properties
@@ -92,7 +92,7 @@ schema.version.namespace.change.start=v12
# Specifies from which version should the client start seeing the edge label in payload
schema.version.edge.label.start=v12
# Specifies the version that the application should default to
-schema.version.api.default=v23
+schema.version.api.default=v24
schema.translator.list=config
schema.service.base.url=https://localhost:8452/aai/schema-service/v1/
'n181' href='#n181'>181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
{{/*
# Copyright © 2019 Amdocs, Bell Canada
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/}}
{{- if .Values.backup.enabled }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: {{ include "common.fullname" . }}-backup
  namespace: {{ include "common.namespace" . }}
  labels: {{- include "common.labels" . | nindent 4 }}
spec:
  schedule: {{ .Values.backup.cron | quote }}
  concurrencyPolicy: Forbid
  startingDeadlineSeconds: 120
  jobTemplate:
    spec:
      template:
        metadata:
          labels: {{- include "common.labels" . | nindent 12 }}
          annotations: {{- include "common.tplValue" (dict "value" .Values.podAnnotations "context" .) | nindent 12 }}
          name: {{ include "common.name" . }}
        spec:
          restartPolicy: Never
          initContainers:
            - command:
              - /app/ready.py
              args:
              - --container-name
              - {{ include "common.name" . }}
              env:
              - name: NAMESPACE
                valueFrom:
                  fieldRef:
                    apiVersion: v1
                    fieldPath: metadata.namespace
              image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
              imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
              name: {{ include "common.name" . }}-readiness
            - name: "cassandra-backup-init"
              image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
              imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
              command:
              - /bin/bash
              - -c
              - |
                clearSnapshot(){
                  curr_time=$1
                  echo "Clearing snapshots!!!"
                  command="nodetool clearsnapshot -t $curr_time"
                  /app/exec.py -p "{{ include "common.name" . }}" -c "$command"
                }
                {{ $root := . }}
                curr_time=`date +%s`
                pids=""
                set -x

                echo "Copying data"
                {{ range $i, $e := until (int .Values.replicaCount) }}
                  target_dir=/backup/temp/cassandra-{{ $i }}
                  mkdir -p $target_dir
                  cp -Ra /onap-data/cassandra-{{ $i }}/data/ $target_dir/
                {{- end }}

                echo "Executing cleanup!!"
                command="nodetool cleanup"
                /app/exec.py -p "{{ include "common.name" . }}" -c "$command"
                echo "Cleaned Node!! Backing up database now!!!"

                command="nodetool snapshot -t $curr_time"
                /app/exec.py -p "{{ include "common.name" . }}" -c "$command"
                retCode=$?
                if [ $retCode -ne 0 ]; then
                  echo "Backup Failed!!!"
                  rm -rf /backup/temp
                  clearSnapshot $curr_time
                  echo "Failed" > /backup/backup.log
                  exit 0
                fi

                backup_dir=/backup/temp
                {{ range $i, $e := until (int .Values.replicaCount) }}
                  for d in $backup_dir/cassandra-{{ $i }}/data/*/ ; do
                    d=$(echo $d | sed 's:/*$::')
                    keyspace_name=$(echo "$d" | awk -F/ '{ print $NF }')
                    if [ 1 ] {{- range $t, $keyspace := $root.Values.backup.keyspacesToSkip }} && [ "{{ $keyspace.name }}" != "$keyspace_name" ] {{- end }}; then
                      /app/restore.sh -b $backup_dir/cassandra-{{ $i }}/data -s  /onap-data/cassandra-{{ $i }}/data/$keyspace_name -k $keyspace_name -t $curr_time &
                      pids="$pids $!"
                    fi
                  done
                {{- end }}

                for p in $pids; do
                  wait $p
                  if [ $? -ne 0 ]; then
                    rm -rf /backup/temp
                    echo "Creation of Backup Failed!!!"
                    clearSnapshot $curr_time
                    echo "Failed" > /backup/backup.log
                    exit 0
                  fi
                done

                clearSnapshot $curr_time

                exit_code=$?
                if [ $exit_code -ne 0 ]; then
                  rm -rf /backup/temp
                  echo "Backup Failed!!!"
                  echo "Failed" > /backup/backup.log
                  exit 0
                fi

                mv /backup/temp /backup/backup-${curr_time}
                echo "Success" > /backup/backup.log
                echo "Cassandra Backup Succeeded"
              env:
              - name: NAMESPACE
                valueFrom:
                  fieldRef:
                    apiVersion: v1
                    fieldPath: metadata.namespace
              volumeMounts:
              - mountPath: /etc/localtime
                name: localtime
                readOnly: true
              {{- range $i := until (int .Values.replicaCount)}}
              - mountPath: /onap-data/cassandra-{{ $i }}
                name: data-dir-{{ $i }}
              {{- end }}
              - mountPath: /backup
                name: backup-dir
              - name: scripts
                mountPath: /app/restore.sh
                subPath: restore.sh
              - name: scripts
                mountPath: /app/exec.py
                subPath: exec.py
          containers:
            - name: cassandra-backup-validate
              image: "{{ .Values.image }}"
              imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
              command:
              - /bin/bash
              - -c
              - |
                remove_dir(){
                  dirToRemove=$1
                  rm -rf $dirToRemove
                }

                backup_result=`cat /backup/backup.log`
                rm -rf /backup/backup.log

                if [ "$backup_result" == "Failed" ]; then
                  echo "Backup Failed!!! So Validation Failed!!!";
                  exit 0
                fi

                target_dir=$(ls -td -- /backup/*/ | head -n 1)
                chown -R cassandra.cassandra $target_dir
                {{- $root := . -}}
                {{ range $i, $e := until (int .Values.replicaCount) }}
                  dbSize=$(du -ks $target_dir/cassandra-{{ $i }}/data|awk -F " " '{ printf $1 }')
                  minDbSize={{ (int $root.Values.backup.dbSize) }}
                  if [ $dbSize -lt $minDbSize ]; then
                    remove_dir $target_dir
                    echo "Validation Failed!!! dbSize ($dbSize) is less than minimum size (1)!!!"
                    exit 0
                  fi
                  rm -rf /var/lib/cassandra/*
                  cp -Ra $target_dir/cassandra-{{ $i }}/data /var/lib/cassandra
                  export CASSANDRA_LISTEN_ADDRESS="127.0.0.1"
                  /docker-entrypoint.sh -Dcassandra.ignore_dc=true -Dcassandra.ignore_rack=true &
                  CASS_PID=$!
                  sleep 45

                  for d in $target_dir/cassandra-{{ $i }}/data/*/; do
                      d=$(echo $d | sed 's:/*$::')
                      keyspace_name=$(echo "$d" | awk -F/ '{ print $NF }')
                      if [ 1 ] {{- range $t, $keyspace := $root.Values.backup.keyspacesToSkip }} && [ "{{ $keyspace.name }}" != "$keyspace_name" ] {{- end }}; then
                        echo "Verifying the data for  $keyspace_name "
                        nodetool verify -e $keyspace_name
                        ret=$?
                        if [ $ret -ne 0 ]; then
                          remove_dir $target_dir
                          echo "Validation Failed!!!"
                          exit 0
                        fi
                      fi
                  done
                  kill -9 $CASS_PID
                {{- end }}
                echo "Validation Successful!!!"
                cd /backup
                totalFiles=`ls -t | grep "backup-" | wc -l`
                if [ $totalFiles -gt {{ .Values.backup.retentionPeriod }} ]; then
                  filestoDelete=`expr $totalFiles - {{ .Values.backup.retentionPeriod }}`
                  ls -tr | grep backup | head -$filestoDelete | xargs rm -rf
                fi
              env:
              - name: CASSANDRA_CLUSTER_NAME
                value: {{ .Values.config.clusterName }}
              - name: MAX_HEAP_SIZE
                value: {{ .Values.config.heap.max }}
              - name: HEAP_NEWSIZE
                value: {{ .Values.config.heap.min }}
              - name: HOST_IP
                valueFrom:
                  fieldRef:
                    fieldPath: status.podIP
              volumeMounts:
              - name: backup-dir
                mountPath: /backup
              - name: localtime
                mountPath: /etc/localtime
                readOnly: true
          volumes:
          - name: localtime
            hostPath:
              path: /etc/localtime
          - name: scripts
            configMap:
              name: {{ include "common.fullname" . }}-configmap
              defaultMode: 0755
          {{- range $i := until (int .Values.replicaCount)}}
          - name: data-dir-{{ $i }}
            persistentVolumeClaim:
              claimName: {{ include "common.fullname" . }}-data-{{ $i }}
          {{- end }}
          - name: backup-dir
            persistentVolumeClaim:
              claimName: {{ include "common.fullname" . }}-backup-data
{{- end -}}