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

[fix] stop status updates on 404 #1620

Merged
merged 1 commit into from
Jul 30, 2021
Merged
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
33 changes: 33 additions & 0 deletions internal/ctrlutils/ingress-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/kong/deck/file"
"github.com/prometheus/common/log"
apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -144,6 +145,10 @@ func UpdateIngressV1(ctx context.Context, logger logr.Logger, svc file.FService,
for retry < statusUpdateRetry {
curIng, err := ingCli.Get(ctx, name, metav1.GetOptions{})
if err != nil || curIng == nil {
if errors.IsNotFound(err) {
return nil
}

log.Errorf("failed to fetch Ingress %v/%v: %v. retrying...", namespace, name, err)
retry++
time.Sleep(time.Second)
Expand All @@ -166,6 +171,10 @@ func UpdateIngressV1(ctx context.Context, logger logr.Logger, svc file.FService,
if err == nil {
break
}
if errors.IsNotFound(err) {
return nil
}

log.Errorf("failed to update Ingress V1 status. %v. retrying...", err)
time.Sleep(time.Second)
retry++
Expand All @@ -189,6 +198,10 @@ func UpdateUDPIngress(ctx context.Context, logger logr.Logger, svc file.FService
for retry < statusUpdateRetry {
curIng, err := ingCli.Get(ctx, name, metav1.GetOptions{})
if err != nil || curIng == nil {
if errors.IsNotFound(err) {
return nil
}

log.Errorf("failed to fetch UDP Ingress %v/%v: %v", namespace, name, err)
time.Sleep(time.Second)
retry++
Expand All @@ -211,6 +224,10 @@ func UpdateUDPIngress(ctx context.Context, logger logr.Logger, svc file.FService
if err == nil {
break
}
if errors.IsNotFound(err) {
return nil
}

log.Errorf("failed to update UDPIngress status: %v. retry...", err)
time.Sleep(time.Second)
retry++
Expand All @@ -232,6 +249,10 @@ func UpdateTCPIngress(ctx context.Context, logger logr.Logger, svc file.FService
ingCli := kiccli.ConfigurationV1beta1().TCPIngresses(namespace)
curIng, err := ingCli.Get(ctx, name, metav1.GetOptions{})
if err != nil || curIng == nil {
if errors.IsNotFound(err) {
return nil
}

return fmt.Errorf("failed to fetch TCP Ingress %v/%v: %w", namespace, name, err)
}

Expand All @@ -248,6 +269,10 @@ func UpdateTCPIngress(ctx context.Context, logger logr.Logger, svc file.FService
curIng.Status.LoadBalancer.Ingress = status
_, err = ingCli.UpdateStatus(ctx, curIng, metav1.UpdateOptions{})
if err != nil {
if errors.IsNotFound(err) {
return nil
}

return fmt.Errorf("failed to update TCPIngress status: %v", err)
}
}
Expand Down Expand Up @@ -277,6 +302,10 @@ func UpdateKnativeIngress(ctx context.Context, logger logr.Logger, svc file.FSer
for retry < statusUpdateRetry {
curIng, err := ingClient.Get(ctx, name, metav1.GetOptions{})
if err != nil || curIng == nil {
if errors.IsNotFound(err) {
return nil
}

log.Errorf("failed to fetch Knative Ingress %v/%v: %v", namespace, name, err)
time.Sleep(time.Second)
retry++
Expand Down Expand Up @@ -310,6 +339,10 @@ func UpdateKnativeIngress(ctx context.Context, logger logr.Logger, svc file.FSer
if err == nil {
break
}
if errors.IsNotFound(err) {
return nil
}

log.Errorf("failed to update ingress status: %v. retrying...", err)
time.Sleep(time.Second)
retry++
Expand Down