Skip to content
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
6 changes: 6 additions & 0 deletions internal/controller/networkpresence_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,12 @@ func (r *NetworkPresenceReconciler) SetupWithManager(mgr manager.Manager) error
r.hub = mgr.GetClient()

builder := ctrl.NewControllerManagedBy(mgr).
// A presence is keyed as the hub's copy of its context is: the same
// namespace and name. The copy lasts as long as the presence does, so the
// list of copies on start brings back every presence, the ones nothing
// declares included, whose waits went with the process that set them.
For(&networkingv1alpha.NetworkContext{}).
// A binding declares a presence, also before its context has a copy.
Watches(&networkingv1alpha.NetworkBinding{}, handler.EnqueueRequestsFromMapFunc(
func(_ context.Context, obj client.Object) []reconcile.Request {
binding, ok := obj.(*networkingv1alpha.NetworkBinding)
Expand Down
5 changes: 4 additions & 1 deletion internal/controller/networkpresence_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/cluster"
Expand Down Expand Up @@ -51,6 +52,7 @@ type presenceScenario struct {
ctx context.Context

hub client.Client
restConfig *rest.Config
reconciler *NetworkPresenceReconciler

hubNamespace string
Expand Down Expand Up @@ -79,7 +81,7 @@ type presenceOptions struct {

func newPresenceScenario(t *testing.T, opts presenceOptions) *presenceScenario {
t.Helper()
cl, _ := startNetworkInterfaceEnv(t)
cl, cfg := startNetworkInterfaceEnv(t)
ctx := context.Background()

suffix := sanitizeName(strings.ToLower(t.Name()))
Expand All @@ -90,6 +92,7 @@ func newPresenceScenario(t *testing.T, opts presenceOptions) *presenceScenario {
t: t,
ctx: ctx,
hub: cl,
restConfig: cfg,
hubNamespace: "hub-" + suffix,
projectNamespace: "proj-" + suffix,
locationName: "loc-" + suffix,
Expand Down
Loading
Loading