Skip to content

Commit 2862af8

Browse files
committed
bugfix: addon manager watches managedclusteraddon
Signed-off-by: yue9944882 <[email protected]>
1 parent bd6789b commit 2862af8

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

pkg/addon/controllers/installer.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -55,38 +55,52 @@ func SetupClusterGatewayInstallerWithManager(mgr ctrl.Manager, caPair *crypto.CA
5555
mapper: mgr.GetRESTMapper(),
5656
}
5757
return ctrl.NewControllerManagedBy(mgr).
58+
// Watches ClusterManagementAddOn singleton
5859
For(&addonv1alpha1.ClusterManagementAddOn{}).
60+
// Watches ClusterGatewayConfiguration singleton
5961
Watches(
6062
&source.Kind{
6163
Type: &proxyv1alpha1.ClusterGatewayConfiguration{},
6264
},
6365
&event.ClusterGatewayConfigurationHandler{
6466
Client: mgr.GetClient(),
6567
}).
68+
// Watches ManagedClusterAddon.
69+
Watches(
70+
&source.Kind{
71+
Type: &addonv1alpha1.ManagedClusterAddOn{},
72+
},
73+
&handler.EnqueueRequestForOwner{
74+
OwnerType: &addonv1alpha1.ClusterManagementAddOn{},
75+
}).
76+
// Cluster-Gateway mTLS certificate should be actively reconciled
6677
Watches(
6778
&source.Kind{
6879
Type: &corev1.Secret{},
6980
},
7081
&handler.EnqueueRequestForOwner{
7182
OwnerType: &addonv1alpha1.ClusterManagementAddOn{},
7283
}).
84+
// Secrets rotated by ManagedServiceAccount should be actively reconciled
7385
Watches(
7486
&source.Kind{
7587
Type: &corev1.Secret{},
7688
},
7789
&event.SecretHandler{}).
90+
// Cluster-gateway apiserver instances should be actively reconciled
7891
Watches(
7992
&source.Kind{
8093
Type: &appsv1.Deployment{},
8194
},
8295
&handler.EnqueueRequestForOwner{
8396
OwnerType: &addonv1alpha1.ClusterManagementAddOn{},
8497
}).
98+
// APIService should be actively reconciled
8599
Watches(
86100
&source.Kind{
87101
Type: &apiregistrationv1.APIService{},
88102
},
89-
&event.APIServiceHandler{}).
103+
&event.APIServiceHandler{WatchingName: common.ClusterGatewayAPIServiceName}).
90104
Complete(installer)
91105
}
92106

pkg/common/constants.go

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ const (
1616
const (
1717
InstallNamespace = "open-cluster-management-cluster-gateway"
1818
)
19+
20+
const (
21+
ClusterGatewayAPIServiceName = "v1alpha1.cluster.core.oam.dev"
22+
)

pkg/event/apiservice_handler.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ import (
1212

1313
var _ handler.EventHandler = &APIServiceHandler{}
1414

15-
const (
16-
clusterGatewayAPIServiceName = "v1alpha1.cluster.core.oam.dev"
17-
)
18-
1915
type APIServiceHandler struct {
16+
WatchingName string
2017
}
2118

2219
func (a *APIServiceHandler) Create(event event.CreateEvent, q workqueue.RateLimitingInterface) {
@@ -36,7 +33,7 @@ func (a *APIServiceHandler) Generic(event event.GenericEvent, q workqueue.RateLi
3633
}
3734

3835
func (a *APIServiceHandler) process(apiService *apiregistrationv1.APIService, q workqueue.RateLimitingInterface) {
39-
if apiService.Name == clusterGatewayAPIServiceName {
36+
if apiService.Name == a.WatchingName {
4037
q.Add(reconcile.Request{
4138
NamespacedName: types.NamespacedName{
4239
Name: common.AddonName,

0 commit comments

Comments
 (0)