Skip to content

Commit 9d1bd14

Browse files
authored
fix: Add controller=true to ownerreferences to correctly reconcile on .Owns() (#281)
1 parent a916ac0 commit 9d1bd14

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

controllers/core/node_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ func (r *NodeReconciler) SetupWithManager(mgr ctrl.Manager, healthzHandler *rcHe
113113
return ctrl.NewControllerManagedBy(mgr).
114114
For(&corev1.Node{}).
115115
WithOptions(controller.Options{MaxConcurrentReconciles: MaxNodeConcurrentReconciles}).
116-
Owns(&v1alpha1.CNINode{}).Complete(r)
116+
Owns(&v1alpha1.CNINode{}).
117+
Complete(r)
117118
}
118119

119120
func (r *NodeReconciler) Check() healthz.Checker {

pkg/k8s/wrapper.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
rcv1alpha1 "github.com/aws/amazon-vpc-resource-controller-k8s/apis/vpcresources/v1alpha1"
2222
"github.com/aws/amazon-vpc-resource-controller-k8s/pkg/config"
2323
"github.com/prometheus/client_golang/prometheus"
24+
"github.com/samber/lo"
2425

2526
appv1 "k8s.io/api/apps/v1"
2627
v1 "k8s.io/api/core/v1"
@@ -244,6 +245,7 @@ func (k *k8sWrapper) CreateCNINode(node *v1.Node) error {
244245
Kind: node.Kind,
245246
Name: node.Name,
246247
UID: node.UID,
248+
Controller: lo.ToPtr(true),
247249
},
248250
},
249251
},

0 commit comments

Comments
 (0)