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 client usage in NetworkpolicyReconciler #323

Merged
merged 1 commit into from
Sep 4, 2024
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: 3 additions & 3 deletions apinetlet/controllers/networkpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (r *NetworkPolicyReconciler) fetchIPsFromNetworkInterfaces(ctx context.Cont
}

nicList := &apinetv1alpha1.NetworkInterfaceList{}
if err := r.List(ctx, nicList,
if err := r.APINetClient.List(ctx, nicList,
client.InNamespace(np.Namespace),
client.MatchingLabelsSelector{Selector: sel},
client.MatchingFields{apinetclient.NetworkInterfaceSpecNetworkRefNameField: np.Spec.NetworkRef.Name},
Expand Down Expand Up @@ -349,7 +349,7 @@ func (r *NetworkPolicyReconciler) fetchIPsFromLoadBalancers(ctx context.Context,

// TODO: apinet load balancer need to inherit labels from ironcore load balancer
lbList := &apinetv1alpha1.LoadBalancerList{}
if err := r.List(ctx, lbList,
if err := r.APINetClient.List(ctx, lbList,
client.InNamespace(np.Namespace),
client.MatchingLabelsSelector{Selector: sel},
); err != nil {
Expand Down Expand Up @@ -400,7 +400,7 @@ func (r *NetworkPolicyReconciler) applyNetworkPolicyRule(ctx context.Context, ne
return fmt.Errorf("error setting controller reference: %w", err)
}

if err := r.Patch(ctx, networkPolicyRule, client.Apply, networkPolicyFieldOwner, client.ForceOwnership); err != nil {
if err := r.APINetClient.Patch(ctx, networkPolicyRule, client.Apply, networkPolicyFieldOwner, client.ForceOwnership); err != nil {
return fmt.Errorf("error applying network policy rule: %w", err)
}
return nil
Expand Down
5 changes: 5 additions & 0 deletions cmd/apinetlet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
apinetletconfig "github.com/ironcore-dev/ironcore-net/apinetlet/client/config"
"github.com/ironcore-dev/ironcore-net/apinetlet/controllers"
"github.com/ironcore-dev/ironcore-net/client-go/ironcorenet"
apinetclient "github.com/ironcore-dev/ironcore-net/internal/client"
commonv1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1"
ipamv1alpha1 "github.com/ironcore-dev/ironcore/api/ipam/v1alpha1"
networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1"
Expand Down Expand Up @@ -237,6 +238,10 @@ func main() {
setupLog.Error(err, "unable to setup field indexer", "field", apinetletclient.NetworkPolicyNetworkNameField)
os.Exit(1)
}
if err := apinetclient.SetupNetworkInterfaceNetworkNameFieldIndexer(ctx, apiNetCluster.GetFieldIndexer()); err != nil {
setupLog.Error(err, "unable to setup field indexer", "field", apinetclient.NetworkInterfaceSpecNetworkRefNameField)
os.Exit(1)
}

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
Expand Down