Skip to content

Commit

Permalink
fix: ACS tasks
Browse files Browse the repository at this point in the history
* fix copy-paste typo in output
* add retry mechanism to acs-image-scan to help with RHTAPBUGS-1316
  • Loading branch information
Roming22 committed Nov 13, 2024
1 parent b2f800c commit 022d3bb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion task/acs-deploy-check/0.1/acs-deploy-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
image: registry.redhat.io/openshift4/ose-cli:4.13@sha256:73df37794ffff7de1101016c23dc623e4990810390ebdabcbbfa065214352c7c
script: |
#!/usr/bin/env bash
echo "acs-image-scan $(context.taskRun.name)"
echo "acs-deploy-check $(context.taskRun.name)"
oc annotate taskrun $(context.taskRun.name) task.results.format=application/json
oc annotate taskrun $(context.taskRun.name) task.results.type=roxctl-deployment-check
oc annotate taskrun $(context.taskRun.name) task.results.container=step-report
Expand Down
2 changes: 1 addition & 1 deletion task/acs-image-check/0.1/acs-image-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
image: registry.redhat.io/openshift4/ose-cli:4.13@sha256:73df37794ffff7de1101016c23dc623e4990810390ebdabcbbfa065214352c7c
script: |
#!/usr/bin/env bash
echo "acs-image-scan $(context.taskRun.name)"
echo "acs-image-check $(context.taskRun.name)"
oc annotate taskrun $(context.taskRun.name) task.results.format=application/json
oc annotate taskrun $(context.taskRun.name) task.results.type=roxctl-image-check
oc annotate taskrun $(context.taskRun.name) task.results.container=step-report
Expand Down
39 changes: 25 additions & 14 deletions task/acs-image-scan/0.1/acs-image-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,31 @@ spec:
echo "roxctl image scan"
IMAGE=${PARAM_IMAGE}@${PARAM_IMAGE_DIGEST}
./roxctl image scan \
$( [ "${PARAM_INSECURE_SKIP_TLS_VERIFY}" = "true" ] && \
echo -n "--insecure-skip-tls-verify") \
-e "${ROX_CENTRAL_ENDPOINT}" --image "$IMAGE" --output json --force \
> roxctl_image_scan_output.json
image_scan_err_code=$?
cp roxctl_image_scan_output.json /steps-shared-folder/acs-image-scan.json
if [ $image_scan_err_code -ne 0 ]; then
cat roxctl_image_scan_output.json
note='ACS image scan failed to process the image. See the task logs for more details.'
echo $note
set_test_output_result ERROR "$note"
exit 2
fi
retry=3
while true; do
retry=$(( retry - 1 ))
./roxctl image scan \
$( [ "${PARAM_INSECURE_SKIP_TLS_VERIFY}" = "true" ] && \
echo -n "--insecure-skip-tls-verify") \
-e "${ROX_CENTRAL_ENDPOINT}" --image "$IMAGE" --output json --force \
> roxctl_image_scan_output.json
image_scan_err_code=$?
cp -f roxctl_image_scan_output.json /steps-shared-folder/acs-image-scan.json
if [ $image_scan_err_code -ne 0 ]; then
cat roxctl_image_scan_output.json
if [ $(grep -c "context deadline exceeded" roxctl_image_scan_output.json) -ne 0 -a $retry -gt 0 ]; then
echo "Retry in 5m"
sleep 300
else
note='ACS image scan failed to process the image. See the task logs for more details.'
echo $note
set_test_output_result ERROR "$note"
exit 2
fi
else
break
fi
done
# Set SCAN_OUTPUT result
critical=$(cat roxctl_image_scan_output.json | grep -oP '(?<="CRITICAL": )\d+')
Expand Down

0 comments on commit 022d3bb

Please sign in to comment.