Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add retry in func UpdateEgressGateway #662

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions test/e2e/common/egressgateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,33 @@ func DeleteEgressGateway(f *framework.Framework, gateway *egressv1beta1.EgressGa
return f.DeleteResource(gateway, opts...)
}

func UpdateEgressGateway(f *framework.Framework, gateway *egressv1beta1.EgressGateway, opts ...client.UpdateOption) error {
return f.UpdateResource(gateway, opts...)
func UpdateEgressGateway(f *framework.Framework, gateway *egressv1beta1.EgressGateway, timeout time.Duration, opts ...client.UpdateOption) error {
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
defer cancel()

eg := new(egressv1beta1.EgressGateway)
for {
select {
case <-ctx.Done():
return ERR_TIMEOUT
default:
e := GetEgressGateway(f, gateway.Name, eg)
if e != nil {
return e
}
gateway.ResourceVersion = eg.ResourceVersion
e = f.UpdateResource(gateway, opts...)
if e == nil {
GinkgoWriter.Printf("the latest resourceVersion is: %s\n", eg.ResourceVersion)
return nil
}
if !errors.IsConflict(e) {
return e
}
GinkgoWriter.Printf("conflict, need retry, now the request resourceVersion is: %s\n", eg.ResourceVersion)
time.Sleep(time.Second)
}
}
}

// DeleteEgressGatewayIfExists delete egressGateway if its exists
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/common/eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ func CheckEipInClientPod(f *framework.Framework, pod *corev1.Pod, eIP, serverIP
default:
out, err := GetClientPodLog(f, pod, serverIP, connectionTimeout, logDuration)
Expect(err).NotTo(HaveOccurred())
GinkgoWriter.Printf("the client-pod log: \n%s\n", out)
if err != nil {
GinkgoWriter.Printf("the client-pod log: \n%s\n", out)
}
if expect {
if strings.Contains(out, WEBSOCKET) && strings.Contains(out, eIP) {
webSocketOk = true
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/egressgateway/egressgateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,40 +178,40 @@ var _ = Describe("Operate egressGateway", Label("egressGateway"), func() {
}
},
Entry("Failed when add invalid `IP` to `Ippools`", Label("G00009"), false, func() error {
Expect(common.GetEgressGateway(f, name, eg)).NotTo(HaveOccurred())
if enableV4 {
eg.Spec.Ippools.IPv4 = append(eg.Spec.Ippools.IPv4, invalidIPv4)
}
if enableV6 {
eg.Spec.Ippools.IPv6 = append(eg.Spec.Ippools.IPv6, invalidIPv6)
}
return common.UpdateEgressGateway(f, eg)
GinkgoWriter.Printf("UpdateEgressGateway: %s\n", eg.Name)
return common.UpdateEgressGateway(f, eg, time.Second*10)
}),
Entry("Succeeded when add valid `IP` to `Ippools`", Label("G00012", "G00013"), true, func() error {
Expect(common.GetEgressGateway(f, name, eg)).NotTo(HaveOccurred())
if enableV4 {
eg.Spec.Ippools.IPv4 = append(eg.Spec.Ippools.IPv4, singleIpv4Pool...)
}
if enableV6 {
eg.Spec.Ippools.IPv6 = append(eg.Spec.Ippools.IPv6, singleIpv6Pool...)
}
return common.UpdateEgressGateway(f, eg)
GinkgoWriter.Printf("UpdateEgressGateway: %s\n", eg.Name)
return common.UpdateEgressGateway(f, eg, time.Second*10)
}),
Entry("Failed when delete `IP` that being used", Label("G00010"), false, func() error {
Expect(common.GetEgressGateway(f, name, eg)).NotTo(HaveOccurred())
if enableV4 {
eg.Spec.Ippools.IPv4 = tools.RemoveValueFromSlice(eg.Spec.Ippools.IPv4, v4DefaultEip)
}
if enableV6 {
eg.Spec.Ippools.IPv6 = tools.RemoveValueFromSlice(eg.Spec.Ippools.IPv6, v6DefaultEip)
}
return common.UpdateEgressGateway(f, eg)
GinkgoWriter.Printf("UpdateEgressGateway: %s\n", eg.Name)
return common.UpdateEgressGateway(f, eg, time.Second*10)
}),
Entry("Failed when add different number of ip to `Ippools.IPv4` and `Ippools.IPv6`", Label("G00011"), false, func() error {
Expect(common.GetEgressGateway(f, name, eg)).NotTo(HaveOccurred())
if enableV4 && enableV6 {
eg.Spec.Ippools.IPv4 = append(eg.Spec.Ippools.IPv4, singleIpv4Pool...)
return common.UpdateEgressGateway(f, eg)
GinkgoWriter.Printf("UpdateEgressGateway: %s\n", eg.Name)
return common.UpdateEgressGateway(f, eg, time.Second*10)
}
return ErrNotNeed
}),
Expand Down
2 changes: 2 additions & 0 deletions test/yaml/calico.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4495,6 +4495,8 @@ spec:
# Use Kubernetes API as the backing datastore.
- name: DATASTORE_TYPE
value: "kubernetes"
- name: "CALICO_IPV6POOL_NAT_OUTGOING"
value: "true"
# Wait for the datastore.
- name: WAIT_FOR_DATASTORE
value: "true"
Expand Down
Loading