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: wggateway controllers pod watch #2815

Merged
merged 1 commit into from
Nov 14, 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
2 changes: 2 additions & 0 deletions deployments/liqo/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ helm.sh/chart: {{ quote (include "liqo.chart" .) }}
app.kubernetes.io/version: {{ quote (include "liqo.version" .) }}
app.kubernetes.io/managed-by: {{ quote .Release.Service }}
networking.liqo.io/component: "gateway"
networking.liqo.io/gateway-name: "{{"{{ .Name }}"}}"
networking.liqo.io/gateway-namespace: "{{"{{ .Namespace }}"}}"
{{- if .isService }}
networking.liqo.io/active: "true"
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,34 @@ func clusterRoleBindingEnquerer(_ context.Context, obj client.Object) []ctrl.Req
}
}

func podEnquerer(_ context.Context, obj client.Object) []ctrl.Request {
pod, ok := obj.(*corev1.Pod)
if !ok {
return nil
}

if pod.Labels == nil {
return nil
}
gwName, ok := pod.Labels[consts.GatewayNameLabel]
if !ok {
return nil
}
gwNs, ok := pod.Labels[consts.GatewayNamespaceLabel]
if !ok {
return nil
}

return []ctrl.Request{
{
NamespacedName: types.NamespacedName{
Namespace: gwNs,
Name: gwName,
},
},
}
}

// ensureKeysSecret ensure the presence of the private and public keys for the Wireguard interface and save them inside a Secret resource and Options.
func ensureKeysSecret(ctx context.Context, cl client.Client, wgObj metav1.Object, mode gateway.Mode) error {
var controllerRef metav1.OwnerReference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func (r *WgGatewayClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
For(&networkingv1beta1.WgGatewayClient{}).
Owns(&appsv1.Deployment{}).
Owns(&corev1.ServiceAccount{}).
Watches(&corev1.Pod{}, handler.EnqueueRequestsFromMapFunc(podEnquerer)).
Watches(&rbacv1.ClusterRoleBinding{},
handler.EnqueueRequestsFromMapFunc(clusterRoleBindingEnquerer)).
Watches(&corev1.Secret{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func (r *WgGatewayServerReconciler) SetupWithManager(mgr ctrl.Manager) error {
Owns(&appsv1.Deployment{}).
Owns(&corev1.Service{}).
Owns(&corev1.ServiceAccount{}).
Watches(&corev1.Pod{}, handler.EnqueueRequestsFromMapFunc(podEnquerer)).
Watches(&rbacv1.ClusterRoleBinding{},
handler.EnqueueRequestsFromMapFunc(clusterRoleBindingEnquerer)).
Watches(&corev1.Secret{},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/cruise/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (

const (
// clustersRequired is the number of clusters required in this E2E test.
clustersRequired = 3
clustersRequired = 2
// testName is the name of this E2E test.
testName = "NETWORK"
// StressMax is the maximum number of stress iterations.
Expand Down
Loading