Don't crash when GuardDuty is in use#83
Open
acdha wants to merge 1 commit into
Open
Conversation
This avoids crashing on the GuardDuty sidecars which do not have the managed agents. Closes aws-containers#67
|
That doesn't QUITE do it, because then the indices of the tasks get off and you end up with misleading info later on THIS is my block for the same issue: # 6. Check the managed agents' status
printf "${COLOR_DEFAULT} Container-Level Checks | \n"
printf "${COLOR_DEFAULT} ----------\n"
printf "${COLOR_DEFAULT} Managed Agent Status"
if [[ "${executeCommandEnabled}" = "false" ]]; then
printf " - ${COLOR_YELLOW}SKIPPED\n"
printf "${COLOR_DEFAULT} ----------\n"
else
printf "\n"
printf "${COLOR_DEFAULT} ----------\n"
agentsStatus=$(echo "${describedTaskJson}" | jq -r '.tasks[0].containers[] |
if has("managedAgents") and (.managedAgents | length) > 0 then
.managedAgents[] .status
else
"ABSENT"
end
')
idx=0
for S in $agentsStatus; do
containerName=$(echo "${describedTaskJson}" | jq -r ".tasks[0].containers[${idx}].name")
if [[ "$S" != ABSENT ]]; then
status=$(echo "${describedTaskJson}" | jq -r ".tasks[0].containers[${idx}].managedAgents[0].lastStatus")
reason=$(echo "${describedTaskJson}" | jq -r ".tasks[0].containers[${idx}].managedAgents[0].reason")
lastStartedAt=$(echo "${describedTaskJson}" | jq -r ".tasks[0].containers[${idx}].managedAgents[0].lastStartedAt")
else
status="ABSENT"
fi
printf " $((idx+1)). "
case "${status}" in
*STOPPED* ) printf "${COLOR_RED}STOPPED (Reason: ${reason})";;
*ABSENT* ) printf "${COLOR_YELLOW}NOT PRESENT";;
*PENDING* ) printf "${COLOR_YELLOW}PENDING";;
* ) printf "${COLOR_GREEN}RUNNING";;
esac
printf "${COLOR_DEFAULT} for \"${containerName}\""
if [[ "${status}" = "STOPPED" ]]; then
printf " - LastStartedAt: ${lastStartedAt}"
fi
printf "\n"
idx=$((idx+1))
done
fi
# 7. Check the "initProcessEnabled" flag added in the task definition (yellow) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This avoids crashing on the GuardDuty sidecars which do not have the managed agents.
Closes #67
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.