Added helm history to collect output

Added outputs of 'helm history' for all releases.
Output is saved to /var/extra/helm/helm-history.info for helm v3
and to /var/extra/helm/<name>.history for helm v2 releases

Test Plan:
pass: /etc/collect.d/collect_containerization outputs the logs

Story: 2010390
Task: 46695

Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
Change-Id: I116501f0a46768d18bec6e7b202253edb4fc8516
This commit is contained in:
Leonardo Fagundes Luz Serrano 2022-10-31 22:55:48 -03:00
parent ce99797f67
commit 8f51932b77

View File

@ -150,6 +150,7 @@ if [ "$nodetype" = "controller" -a "${ACTIVE}" = true ] ; then
helm status ${APPNAME} > ${HELM_DIR}/${APPNAME}.status helm status ${APPNAME} > ${HELM_DIR}/${APPNAME}.status
helm get values ${APPNAME} --revision ${APPREVISION} \ helm get values ${APPNAME} --revision ${APPREVISION} \
> ${HELM_DIR}/${APPNAME}.v${APPREVISION} > ${HELM_DIR}/${APPNAME}.v${APPREVISION}
helm history ${APPNAME} > ${HELM_DIR}/${APPNAME}.history
done <<< "${APPLIST}" done <<< "${APPLIST}"
elif [[ $HELM_VERSION =~ v3 ]]; then elif [[ $HELM_VERSION =~ v3 ]]; then
# NOTE: helm environment not configured for root user # NOTE: helm environment not configured for root user
@ -157,6 +158,16 @@ if [ "$nodetype" = "controller" -a "${ACTIVE}" = true ] ; then
delimiter ${LOGFILE_HELM} "${CMD}" delimiter ${LOGFILE_HELM} "${CMD}"
${CMD} 2>>${COLLECT_ERROR_LOG} >>${LOGFILE_HELM} ${CMD} 2>>${COLLECT_ERROR_LOG} >>${LOGFILE_HELM}
# Save history for each helm release
mapfile -t RELEASES < <( ${CMD} 2>>${COLLECT_ERROR_LOG} )
for RELEASE in "${RELEASES[@]:1}"; do
NAME=$(echo ${RELEASE} | awk '{print $1}')
NAMESPACE=$(echo ${RELEASE} | awk '{print $2}')
CMD="sudo -u sysadmin KUBECONFIG=${KUBECONFIG} helm history -n ${NAMESPACE} ${NAME}"
delimiter ${HELM_DIR}/helm-history.info "${CMD}"
${CMD} >> ${HELM_DIR}/helm-history.info 2>>${COLLECT_ERROR_LOG}
done
CMD="sudo -u sysadmin KUBECONFIG=${KUBECONFIG} helm search repo" CMD="sudo -u sysadmin KUBECONFIG=${KUBECONFIG} helm search repo"
delimiter ${LOGFILE_HELM} "${CMD}" delimiter ${LOGFILE_HELM} "${CMD}"
${CMD} 2>>${COLLECT_ERROR_LOG} >>${LOGFILE_HELM} ${CMD} 2>>${COLLECT_ERROR_LOG} >>${LOGFILE_HELM}
@ -183,6 +194,7 @@ if [ "$nodetype" = "controller" -a "${ACTIVE}" = true ] ; then
${HELM2CLI} -- helm status ${APPNAME} > ${HELM_DIR}/${APPNAME}.status ${HELM2CLI} -- helm status ${APPNAME} > ${HELM_DIR}/${APPNAME}.status
${HELM2CLI} -- helm get values ${APPNAME} --revision ${APPREVISION} \ ${HELM2CLI} -- helm get values ${APPNAME} --revision ${APPREVISION} \
> ${HELM_DIR}/${APPNAME}.v${APPREVISION} > ${HELM_DIR}/${APPNAME}.v${APPREVISION}
${HELM2CLI} -- helm history ${APPNAME} > ${HELM_DIR}/${APPNAME}.history
done <<< "${APPLIST}" done <<< "${APPLIST}"
CMD="helmv2-cli -- helm search" CMD="helmv2-cli -- helm search"