ci: do not count Warning: matches in kubectl_retry()

Depending on the Kubernetes version, the following warning is reported
regulary:

> Warning: policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+,
> unavailable in v1.25+

The warning is written to stderr, so skipping AlreadyExists or NotFound
is not sufficient to trigger a retry. Ignoring '^Warning:' in the stderr
output should prevent unneeded failures while deploying Rook or other
components.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
(cherry picked from commit 89e2ff39f1)
This commit is contained in:
Niels de Vos 2022-04-24 09:35:41 +02:00 committed by mergify[bot]
parent 2f7fb80498
commit 2accbe66b1

View File

@ -16,8 +16,8 @@ kubectl_retry() {
# in case of a failure when running "create", ignore errors with "AlreadyExists" # in case of a failure when running "create", ignore errors with "AlreadyExists"
if [ "${action}" == 'create' ] if [ "${action}" == 'create' ]
then then
# count lines in stderr that do not have "AlreadyExists" # count lines in stderr that do not have "AlreadyExists" or "Warning"
ret=$(grep -cvw 'AlreadyExists' "${stderr}") ret=$(grep -cvw -e 'AlreadyExists' -e '^Warning:' "${stderr}")
if [ "${ret}" -eq 0 ] if [ "${ret}" -eq 0 ]
then then
# Success! stderr is empty after removing all "AlreadyExists" lines. # Success! stderr is empty after removing all "AlreadyExists" lines.
@ -28,8 +28,8 @@ kubectl_retry() {
# in case of a failure when running "delete", ignore errors with "NotFound" # in case of a failure when running "delete", ignore errors with "NotFound"
if [ "${action}" == 'delete' ] if [ "${action}" == 'delete' ]
then then
# count lines in stderr that do not have "NotFound" # count lines in stderr that do not have "NotFound" or "Warning"
ret=$(grep -cvw 'NotFound' "${stderr}") ret=$(grep -cvw -e 'NotFound' -e '^Warning:' "${stderr}")
if [ "${ret}" -eq 0 ] if [ "${ret}" -eq 0 ]
then then
# Success! stderr is empty after removing all "NotFound" lines. # Success! stderr is empty after removing all "NotFound" lines.