Skip to content

Commit 20afa65

Browse files
jpalagirHenry Wagner
authored andcommitted
Invalid IP event generation message updated. Removed unnecessary echo statements
1 parent a83e2c8 commit 20afa65

File tree

4 files changed

+10
-20
lines changed

4 files changed

+10
-20
lines changed

e2e/test/lb-created-with-invalid-ip/chainsaw-test.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ spec:
6767
- script:
6868
content: |
6969
set -e
70-
70+
sleep 30
7171
invalid_ip=$(kubectl get configmap invalid-ip-config -o=jsonpath='{.data.InvalidIP}' -n $NAMESPACE)
7272
if [[ -z "$invalid_ip" ]]; then
7373
echo "Error: No invalid ip found in configmap"
@@ -77,23 +77,24 @@ spec:
7777
events=$(kubectl get events -n $NAMESPACE --field-selector reason=SyncLoadBalancerFailed --sort-by='.lastTimestamp' -o json)
7878
message=$(echo $events | jq .items[0].message)
7979
80-
if [[ "$message" =~ ^\"Error\ syncing\ load\ balancer:\ failed\ to\ ensure\ load\ balancer:\ invalid\ IPv4\ address\ in\ annotation\ $annotation:\ invalid\ IP\ address\ format:\ $invalid_ip\"$ ]]; then
80+
if [[ "$message" == *"Error syncing load balancer: failed to ensure load balancer: [400] Invalid IPv4 address"* ]]; then
8181
echo "Warning event found"
8282
else
8383
echo "Warning event not found"
8484
fi
85-
85+
8686
service_ip=$(kubectl get svc svc-test -n $NAMESPACE -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
8787
if [[ "$service_ip" != "" ]]; then
8888
echo "Error: service ip found for service svc-test"
8989
fi
90-
echo "{\"service_ip\": $service_ip}"
91-
echo "{\"invalid_ip\": $invalid_ip}"
9290
if [[ "$service_ip" == "$invalid_ip" ]]; then
9391
echo "Expected service ip to be null got the invalid ip: $invalid_ip"
9492
fi
93+
echo "{\"service_ip\": $service_ip}"
94+
echo "{\"invalid_ip\": $invalid_ip}"
9595
check:
9696
($error == null): true
9797
(contains($stdout, 'Warning event not found')): false
9898
(contains($stdout, 'No invalid ip found in configmap')): false
9999
(contains($stdout, 'Expected service ip to be null got the invalid ip')): false
100+

e2e/test/lb-created-with-reserved-ip-change-ip-unreserved/chainsaw-test.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ spec:
131131
132132
message=$(echo $events | jq .items[0].message)
133133
134-
echo $message
135-
136134
if [[ "$message" =~ ^\"IPv4\ annotation\ changed\ to\ $unreserved_ip,\ but\ NodeBalancer\ \([0-9]+\)\ IP\ cannot\ be\ updated\ after\ creation.\ It\ will\ remain\ $reserved_ip\"$ ]]; then
137135
echo "Warning event found"
138136
else

e2e/test/lb-created-with-reserved-ip-change-ip/chainsaw-test.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ spec:
159159
160160
message=$(echo $events | jq .items[0].message)
161161
162-
echo $message
163-
164162
if [[ "$message" =~ ^\"IPv4\ annotation\ changed\ to\ $reserved_ip2,\ but\ NodeBalancer\ \([0-9]+\)\ IP\ cannot\ be\ updated\ after\ creation.\ It\ will\ remain\ $reserved_ip\"$ ]]; then
165163
echo "Warning event found"
166164
else

e2e/test/lb-created-with-reserved-ip-multiple-change-ip/chainsaw-test.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: chainsaw.kyverno.io/v1alpha1
33
kind: Test
44
metadata:
5-
name: lb-created-with-reserved-ip-multiple-change-ip
5+
name: c
66
labels:
77
all:
88
lke:
@@ -143,8 +143,6 @@ spec:
143143
echo "Error: No reserved ip found in configmap"
144144
fi
145145
146-
echo $NAMESPACE
147-
echo $reserved_ip2
148146
patch=$(kubectl patch service svc-test -n $NAMESPACE --patch "{
149147
\"metadata\": {
150148
\"annotations\": {
@@ -153,7 +151,7 @@ spec:
153151
}
154152
}")
155153
156-
sleep 10
154+
sleep 30
157155
158156
patch2=$(kubectl patch service svc-test -n $NAMESPACE --patch "{
159157
\"metadata\": {
@@ -163,30 +161,25 @@ spec:
163161
}
164162
}")
165163
164+
sleep 30
166165
if [[ "$patch" != "service/svc-test patched" ]]; then
167166
echo "Unable to update annotation"
168167
fi
169168
if [[ "$patch2" != "service/svc-test patched" ]]; then
170169
echo "Unable to update annotation"
171170
fi
172171
173-
sleep 10
174-
175172
events=$(kubectl get events -n $NAMESPACE --field-selector reason=NodeBalancerIPChangeIgnored --sort-by='.lastTimestamp' -o json)
176173
177174
message=$(echo $events | jq .items[0].message)
178175
message2=$(echo $events | jq .items[1].message)
179176
180-
echo $events
181-
echo $message
182-
echo $message2
183-
184177
if [[ "$message" =~ ^\"IPv4\ annotation\ changed\ to\ $reserved_ip2,\ but\ NodeBalancer\ \([0-9]+\)\ IP\ cannot\ be\ updated\ after\ creation.\ It\ will\ remain\ $reserved_ip\"$ ]]; then
185178
echo "Warning event found"
186179
else
187180
echo "Warning event not found"
188181
fi
189-
182+
190183
if [[ "$message2" =~ ^\"IPv4\ annotation\ changed\ to\ 100.10.10.10,\ but\ NodeBalancer\ \([0-9]+\)\ IP\ cannot\ be\ updated\ after\ creation.\ It\ will\ remain\ $reserved_ip\"$ ]]; then
191184
echo "Warning event found"
192185
else

0 commit comments

Comments
 (0)