Skip to content

Commit

Permalink
bugfix: addon manager watches managedclusteraddon
Browse files Browse the repository at this point in the history
Signed-off-by: yue9944882 <[email protected]>
  • Loading branch information
yue9944882 committed Mar 23, 2022
1 parent bd6789b commit 2862af8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
16 changes: 15 additions & 1 deletion pkg/addon/controllers/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,38 +55,52 @@ func SetupClusterGatewayInstallerWithManager(mgr ctrl.Manager, caPair *crypto.CA
mapper: mgr.GetRESTMapper(),
}
return ctrl.NewControllerManagedBy(mgr).
// Watches ClusterManagementAddOn singleton
For(&addonv1alpha1.ClusterManagementAddOn{}).
// Watches ClusterGatewayConfiguration singleton
Watches(
&source.Kind{
Type: &proxyv1alpha1.ClusterGatewayConfiguration{},
},
&event.ClusterGatewayConfigurationHandler{
Client: mgr.GetClient(),
}).
// Watches ManagedClusterAddon.
Watches(
&source.Kind{
Type: &addonv1alpha1.ManagedClusterAddOn{},
},
&handler.EnqueueRequestForOwner{
OwnerType: &addonv1alpha1.ClusterManagementAddOn{},
}).
// Cluster-Gateway mTLS certificate should be actively reconciled
Watches(
&source.Kind{
Type: &corev1.Secret{},
},
&handler.EnqueueRequestForOwner{
OwnerType: &addonv1alpha1.ClusterManagementAddOn{},
}).
// Secrets rotated by ManagedServiceAccount should be actively reconciled
Watches(
&source.Kind{
Type: &corev1.Secret{},
},
&event.SecretHandler{}).
// Cluster-gateway apiserver instances should be actively reconciled
Watches(
&source.Kind{
Type: &appsv1.Deployment{},
},
&handler.EnqueueRequestForOwner{
OwnerType: &addonv1alpha1.ClusterManagementAddOn{},
}).
// APIService should be actively reconciled
Watches(
&source.Kind{
Type: &apiregistrationv1.APIService{},
},
&event.APIServiceHandler{}).
&event.APIServiceHandler{WatchingName: common.ClusterGatewayAPIServiceName}).
Complete(installer)
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ const (
const (
InstallNamespace = "open-cluster-management-cluster-gateway"
)

const (
ClusterGatewayAPIServiceName = "v1alpha1.cluster.core.oam.dev"
)
7 changes: 2 additions & 5 deletions pkg/event/apiservice_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import (

var _ handler.EventHandler = &APIServiceHandler{}

const (
clusterGatewayAPIServiceName = "v1alpha1.cluster.core.oam.dev"
)

type APIServiceHandler struct {
WatchingName string
}

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

func (a *APIServiceHandler) process(apiService *apiregistrationv1.APIService, q workqueue.RateLimitingInterface) {
if apiService.Name == clusterGatewayAPIServiceName {
if apiService.Name == a.WatchingName {
q.Add(reconcile.Request{
NamespacedName: types.NamespacedName{
Name: common.AddonName,
Expand Down

0 comments on commit 2862af8

Please sign in to comment.