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

Keep trying reconciliation in case of discovery error #324

Merged
merged 1 commit into from
Aug 28, 2024
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
9 changes: 8 additions & 1 deletion pkg/graph/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ package graph

import (
"context"
"errors"
"time"

core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/discovery"
kmapi "kmodules.xyz/client-go/api/v1"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -59,7 +61,12 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco
Client: r.Client,
}
if result, err := finder.ListConnectedObjectIDs(&obj, rd.Spec.Connections); err != nil {
log.Error(err, "unable to list connections", "group", r.R.Group, "kind", r.R.Kind)
// In case of discovery error, we don't return error because errors are rate limited.
// We need to keep trying until the reconciliation is successful.
if errors.Is(err, &discovery.ErrGroupDiscoveryFailed{}) {
log.Error(err, "unable to list connections", "group", r.R.Group, "kind", r.R.Kind)
return reconcile.Result{RequeueAfter: 500 * time.Millisecond}, nil
}
// we'll ignore not-found errors, since they can't be fixed by an immediate
// requeue (we'll need to wait for a new notification), and we can get them
// on deleted requests.
Expand Down
Loading