Skip to content

Commit

Permalink
Merge pull request juju#17105 from anvial/add-condition-for-empty-sg
Browse files Browse the repository at this point in the history
juju#17105

This PR introduces a new condition to handle scenarios where the security group is empty. This enhances the robustness of our security group handling logic and prevents potential errors due to empty security groups.

## Checklist

- [x] Code style: imports ordered, good names, simple structure, etc
- [x] Comments saying why design decisions were made
- [x] Go unit tests, with comments saying what you're testing
- [ ] [Integration tests](https://github.com/juju/juju/tree/main/tests), with comments saying what you're testing
- [ ] [doc.go](https://discourse.charmhub.io/t/readme-in-packages/451) added or updated in changed packages

## QA steps

```
cd tests
./main.sh -v -c aws firewall test_expose_app_ec2
```

## Links

**Jira card:** JUJU-
  • Loading branch information
jujubot committed Mar 26, 2024
2 parents 13f571b + 99faf8b commit d52737e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/includes/wait-for.sh
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ wait_for_aws_ingress_cidrs_for_port_range() {
secgrp_list=$(aws ec2 describe-security-groups --filters Name=ip-permission.from-port,Values=${from_port} Name=ip-permission.to-port,Values=${to_port})
# print the security group rules
# shellcheck disable=SC2086
got_cidrs=$(echo ${secgrp_list} | jq -r ".SecurityGroups[0].IpPermissions | .[] | select(.FromPort == ${from_port} and .ToPort == ${to_port}) | .Ip${ipV6Suffix}Ranges | .[] | .CidrIp${ipV6Suffix}" | sort | paste -sd, -)
got_cidrs=$(echo ${secgrp_list} | jq -r ".SecurityGroups[0].IpPermissions // [] | .[] | select(.FromPort == ${from_port} and .ToPort == ${to_port}) | .Ip${ipV6Suffix}Ranges // [] | .[] | .CidrIp${ipV6Suffix}" | sort | paste -sd, -)

attempt=0
# shellcheck disable=SC2046,SC2143
Expand All @@ -360,7 +360,7 @@ wait_for_aws_ingress_cidrs_for_port_range() {
# shellcheck disable=SC2086
secgrp_list=$(aws ec2 describe-security-groups --filters Name=ip-permission.from-port,Values=${from_port} Name=ip-permission.to-port,Values=${to_port})
# shellcheck disable=SC2086
got_cidrs=$(echo ${secgrp_list} | jq -r ".SecurityGroups[0].IpPermissions | .[] | select(.FromPort == ${from_port} and .ToPort == ${to_port}) | .Ip${ipV6Suffix}Ranges | .[] | .CidrIp${ipV6Suffix}" | sort | paste -sd, -)
got_cidrs=$(echo ${secgrp_list} | jq -r ".SecurityGroups[0].IpPermissions // [] | .[] | select(.FromPort == ${from_port} and .ToPort == ${to_port}) | .Ip${ipV6Suffix}Ranges // [] | .[] | .CidrIp${ipV6Suffix}" | sort | paste -sd, -)
sleep "${SHORT_TIMEOUT}"

if [ "$got_cidrs" == "$exp_cidrs" ]; then
Expand Down

0 comments on commit d52737e

Please sign in to comment.