diff --git a/api/v1/epic_types.go b/api/v1/epic_types.go index 00dddff..7312d6b 100644 --- a/api/v1/epic_types.go +++ b/api/v1/epic_types.go @@ -4,7 +4,9 @@ import ( "context" "net" "os" + "time" + "k8s.io/apimachinery/pkg/util/wait" "github.com/go-logr/logr" "github.com/vishvananda/netlink" "github.com/vishvananda/netlink/nl" @@ -172,7 +174,14 @@ func addrFamily(lbIP net.IP) (lbIPFamily int) { // this call succeeds (i.e., error is nil) then the returned ID will // be unique. func AllocateTunnelID(ctx context.Context, l logr.Logger, cl client.Client) (tunnelID uint32, err error) { - return tunnelID, retry.RetryOnConflict(retry.DefaultRetry, func() error { + var Retry = wait.Backoff{ + Steps: 5, + Duration: 2 * time.Second, + Factor: 1.0, + Jitter: 0.1, + } + + return tunnelID, retry.RetryOnConflict(Retry, func() error { var epic EPIC // Fetch the resource here; you need to refetch it on every try, diff --git a/cmd/controller_manager.go b/cmd/controller_manager.go index fef544a..059e756 100644 --- a/cmd/controller_manager.go +++ b/cmd/controller_manager.go @@ -2,6 +2,7 @@ package cmd import ( "context" + "fmt" marin3r "github.com/3scale-ops/marin3r/apis/marin3r/v1alpha1" marin3roperator "github.com/3scale-ops/marin3r/apis/operator.marin3r/v1alpha1" @@ -182,6 +183,20 @@ func prebootCleanup(ctx context.Context, log logr.Logger) error { return err } + // Allocate a tunnel ID so we start at 1 (yes, we will waste + // some but they're plentiful). + var epic epicv1.EPIC + err = fmt.Errorf("Placeholder") + for err != nil { + err = cl.Get(ctx, client.ObjectKey{Namespace: epicv1.ConfigNamespace, Name: epicv1.ConfigName}, &epic) + if err != nil { + log.Info("can't find EPIC singleton", "message", err) + } + } + if _, err := epicv1.AllocateTunnelID(ctx, log, cl); err != nil { + log.Error(err, "incrementing tunnel ID") + } + // "Nudge" the proxy pods to trigger the python daemon to // re-populate the ifindex and ifname annotations proxies, err := listProxyPods(ctx, cl)