Skip to content

Commit

Permalink
Merge branch 'K8SPSMDB-927_pass_termnationGracePeriodSeconds_rs_conta…
Browse files Browse the repository at this point in the history
…iners' of https://github.com/percona/percona-server-mongodb-operator into K8SPSMDB-927_pass_termnationGracePeriodSeconds_rs_containers
  • Loading branch information
nmarukovich committed Aug 7, 2023
2 parents cb85e7b + f3ce225 commit abaa0aa
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions e2e-tests/demand-backup-sharded/run
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,8 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
check_backup_deletion "https://engk8soperators.blob.core.windows.net/operator-testing/${backup_dest_azure}" "azure-blob"
fi

desc 'check for passwords leak'
check_passwords_leak

kubectl_bin delete -f "$conf_dir/container-rc.yaml"
destroy "$namespace"
3 changes: 3 additions & 0 deletions e2e-tests/demand-backup/run
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ if [ -z "$SKIP_BACKUPS_TO_AWS_GCP_AZURE" ]; then
check_backup_deletion "https://engk8soperators.blob.core.windows.net/operator-testing/${backup_dest_azure}" "azure-blob"
fi

desc 'check for passwords leak'
check_passwords_leak

destroy $namespace

desc 'test passed'
42 changes: 42 additions & 0 deletions e2e-tests/functions
Original file line number Diff line number Diff line change
Expand Up @@ -1217,3 +1217,45 @@ function get_mongod_ver_from_image() {
fi
echo ${version_info}
}

check_passwords_leak() {
secrets=$(kubectl_bin get secrets -o json | jq -r '.items[].data | to_entries | .[] | select(.key | (contains("_PASSWORD"))) | .value')
echo secrets=$secrets

passwords="$(for i in $secrets; do base64 -d <<< $i; echo; done) $secrets"
echo passwords=$passwords

pods=$(kubectl_bin get pods -o name | awk -F "/" '{print $2}')
echo pods=$pods

TEMP_DIR=$(mktemp -d)

collect_logs() {
NS=$1
for p in $pods; do
containers=$(kubectl_bin -n "$NS" get pod $p -o jsonpath='{.spec.containers[*].name}')
for c in $containers; do
# temporary, because of: https://jira.percona.com/browse/PMM-8357
if [[ ${c} =~ "pmm" ]]; then
continue
fi
kubectl_bin -n "$NS" logs $p -c $c > ${TEMP_DIR}/logs_output-$p-$c.txt
echo logs saved in: ${TEMP_DIR}/logs_output-$p-$c.txt
for pass in $passwords; do
count=$(grep -c --fixed-strings -- "$pass" ${TEMP_DIR}/logs_output-$p-$c.txt || :)
if [[ $count != 0 ]]; then
echo leaked passwords are found in log ${TEMP_DIR}/logs_output-$p-$c.txt
false
fi
done
done
echo
done
}

collect_logs $namespace
if [ -n "$OPERATOR_NS" ]; then
pods=$(kubectl_bin -n "${OPERATOR_NS}" get pods -o name | awk -F "/" '{print $2}')
collect_logs $OPERATOR_NS
fi
}
3 changes: 3 additions & 0 deletions e2e-tests/init-deploy/run
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ compare_mongo_cmd "find" "myApp:myPass@$cluster2-0.$cluster2.$namespace" "-3rd"
compare_mongo_cmd "find" "myApp:myPass@$cluster2-1.$cluster2.$namespace" "-3rd"
compare_mongo_cmd "find" "myApp:myPass@$cluster2-2.$cluster2.$namespace" "-3rd"

desc 'check for passwords leak'
check_passwords_leak

desc 'delete custom RuntimeClass'
kubectl_bin delete -f "$conf_dir/container-rc.yaml"
destroy $namespace
Expand Down
3 changes: 3 additions & 0 deletions e2e-tests/monitoring-2-0/run
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ if [[ -n ${OPENSHIFT} ]]; then
oc adm policy remove-scc-from-user privileged -z percona-server-mongodb-operator
fi

desc 'check for passwords leak'
check_passwords_leak

helm uninstall monitoring
destroy $namespace

Expand Down

0 comments on commit abaa0aa

Please sign in to comment.